-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tb/commit-graph-harden'
The code to parse and use the commit-graph file has been made more robust against corrupted input. * tb/commit-graph-harden: commit-graph.c: handle corrupt/missing trees commit-graph.c: handle commit parsing errors t/t5318: introduce failing 'git commit-graph write' tests
- Loading branch information
Showing
3 changed files
with
54 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -621,4 +621,47 @@ test_expect_success 'get_commit_tree_in_graph works for non-the_repository' ' | |
test_cmp expect actual | ||
' | ||
|
||
test_expect_success 'corrupt commit-graph write (broken parent)' ' | ||
rm -rf repo && | ||
git init repo && | ||
( | ||
cd repo && | ||
empty="$(git mktree </dev/null)" && | ||
cat >broken <<-EOF && | ||
tree $empty | ||
parent 0000000000000000000000000000000000000000 | ||
author whatever <[email protected]> 1234 -0000 | ||
committer whatever <[email protected]> 1234 -0000 | ||
broken commit | ||
EOF | ||
broken="$(git hash-object -w -t commit --literally broken)" && | ||
git commit-tree -p "$broken" -m "good commit" "$empty" >good && | ||
test_must_fail git commit-graph write --stdin-commits \ | ||
<good 2>test_err && | ||
test_i18ngrep "unable to parse commit" test_err | ||
) | ||
' | ||
|
||
test_expect_success 'corrupt commit-graph write (missing tree)' ' | ||
rm -rf repo && | ||
git init repo && | ||
( | ||
cd repo && | ||
tree="$(git mktree </dev/null)" && | ||
cat >broken <<-EOF && | ||
parent 0000000000000000000000000000000000000000 | ||
author whatever <[email protected]> 1234 -0000 | ||
committer whatever <[email protected]> 1234 -0000 | ||
broken commit | ||
EOF | ||
broken="$(git hash-object -w -t commit --literally broken)" && | ||
git commit-tree -p "$broken" -m "good" "$tree" >good && | ||
test_must_fail git commit-graph write --stdin-commits \ | ||
<good 2>test_err && | ||
test_i18ngrep "unable to get tree for" test_err | ||
) | ||
' | ||
|
||
test_done |