diff --git a/libwyag.py b/libwyag.py index 4e3c7bf..ef6433f 100644 --- a/libwyag.py +++ b/libwyag.py @@ -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,