Skip to content
Snippets Groups Projects
Commit 5a688ad6 authored by Gregory Szorc's avatar Gregory Szorc
Browse files

Verify tree and parent objects are in Git repo

When exporting Git commits, verify that the tree and parents objects
exist in the repository before allowing the commit to be exported. If a
tree or parent commit is missing, then the repository is not valid and
the export should not be allowed.
parent c9faba7d
No related branches found
No related tags found
No related merge requests found
......@@ -384,6 +384,10 @@
hgsha = hex(parent.node())
git_sha = self.map_git_get(hgsha)
if git_sha:
if git_sha not in self.git.object_store:
raise hgutil.Abort(_('Parent SHA-1 not present in Git'
'repo: %s' % git_sha))
commit.parents.append(git_sha)
commit.message = self.get_git_message(ctx)
......@@ -392,6 +396,10 @@
commit.encoding = extra['encoding']
tree_sha = commit_tree(self.git.object_store, self.iterblobs(ctx))
if tree_sha not in self.git.object_store:
raise hgutil.Abort(_('Tree SHA-1 not present in Git repo: %s' %
tree_sha))
commit.tree = tree_sha
self.git.object_store.add_object(commit)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment