Allow first commit in repo

Before you had to do it through vanilla git
This commit is contained in:
Nathan McRae 2024-07-20 09:29:52 -07:00
parent 77bdcc1024
commit 08771733b1

View File

@ -1487,6 +1487,7 @@ def tree_from_index(repo, index, commit_map, author, commit_time, message):
if path in commit_map:
(subcommit_hash, subcommit) = commit_map[path]
else:
subcommit_hash = None
subcommit = None
if subcommit == None or subcommit.kvlm[b'tree'] != sha.encode('ascii'):
@ -1530,12 +1531,18 @@ def cmd_commit(args):
repo = repo_find()
index = index_read(repo)
root_commit_sha = object_find(repo, "HEAD")
root_commit = object_read(repo, root_commit_sha)
if root_commit_sha:
root_commit = object_read(repo, root_commit_sha)
else:
root_commit = None
commit_time = datetime.now()
author = gitconfig_user_get(gitconfig_read())
commit_map = create_commit_map(repo, root_commit)
if root_commit:
commit_map = create_commit_map(repo, root_commit)
else:
commit_map = dict()
tree = tree_from_index(repo,
index,