-
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 'mh/reporting-broken-refs-from-for-each-ref'
"git for-each-ref" reported "missing object" for 0{40} when it encounters a broken ref. The lack of object whose name is 0{40} is not the problem; the ref being broken is. * mh/reporting-broken-refs-from-for-each-ref: read_loose_refs(): treat NULL_SHA1 loose references as broken read_loose_refs(): simplify function logic for-each-ref: report broken references correctly t6301: new tests of for-each-ref error handling
- Loading branch information
Showing
3 changed files
with
83 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
test_description='for-each-ref errors for broken refs' | ||
|
||
. ./test-lib.sh | ||
|
||
ZEROS=$_z40 | ||
MISSING=abababababababababababababababababababab | ||
|
||
test_expect_success setup ' | ||
git commit --allow-empty -m "Initial" && | ||
git tag testtag && | ||
git for-each-ref >full-list && | ||
git for-each-ref --format="%(objectname) %(refname)" >brief-list | ||
' | ||
|
||
test_expect_success 'Broken refs are reported correctly' ' | ||
r=refs/heads/bogus && | ||
: >.git/$r && | ||
test_when_finished "rm -f .git/$r" && | ||
echo "warning: ignoring broken ref $r" >broken-err && | ||
git for-each-ref >out 2>err && | ||
test_cmp full-list out && | ||
test_cmp broken-err err | ||
' | ||
|
||
test_expect_success 'NULL_SHA1 refs are reported correctly' ' | ||
r=refs/heads/zeros && | ||
echo $ZEROS >.git/$r && | ||
test_when_finished "rm -f .git/$r" && | ||
echo "warning: ignoring broken ref $r" >zeros-err && | ||
git for-each-ref >out 2>err && | ||
test_cmp full-list out && | ||
test_cmp zeros-err err && | ||
git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err && | ||
test_cmp brief-list brief-out && | ||
test_cmp zeros-err brief-err | ||
' | ||
|
||
test_expect_success 'Missing objects are reported correctly' ' | ||
r=refs/heads/missing && | ||
echo $MISSING >.git/$r && | ||
test_when_finished "rm -f .git/$r" && | ||
echo "fatal: missing object $MISSING for $r" >missing-err && | ||
test_must_fail git for-each-ref 2>err && | ||
test_cmp missing-err err && | ||
( | ||
cat brief-list && | ||
echo "$MISSING $r" | ||
) | sort -k 2 >missing-brief-expected && | ||
git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err && | ||
test_cmp missing-brief-expected brief-out && | ||
test_must_be_empty brief-err | ||
' | ||
|
||
test_done |