t1404: demonstrate a bug resolving references
Add some tests checking that it is possible to work with a reference even if there is an empty directory where the loose ref would be stored. One of the new tests demonstrates a bug that has been with us since at least 2.5.0--single reference lookup gives up when it sees the directory, even if the reference exists as a packed ref. This probably hasn't been reported before because Git usually cleans up empty directories when packing references. This bug will be fixed shortly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
This commit is contained in:
parent
3ad15fd5e1
commit
19dd7d06e5
@ -28,7 +28,9 @@ Q="'"
|
|||||||
test_expect_success 'setup' '
|
test_expect_success 'setup' '
|
||||||
|
|
||||||
git commit --allow-empty -m Initial &&
|
git commit --allow-empty -m Initial &&
|
||||||
C=$(git rev-parse HEAD)
|
C=$(git rev-parse HEAD) &&
|
||||||
|
git commit --allow-empty -m Second &&
|
||||||
|
D=$(git rev-parse HEAD)
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
@ -104,4 +106,76 @@ test_expect_success 'one new ref is a simple prefix of another' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_failure 'empty directory should not fool rev-parse' '
|
||||||
|
prefix=refs/e-rev-parse &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
echo "$C" >expected &&
|
||||||
|
git rev-parse $prefix/foo >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool for-each-ref' '
|
||||||
|
prefix=refs/e-for-each-ref &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git for-each-ref $prefix >expected &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
git for-each-ref $prefix >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool create' '
|
||||||
|
prefix=refs/e-create &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
printf "create %s $C\n" $prefix/foo |
|
||||||
|
git update-ref --stdin
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool verify' '
|
||||||
|
prefix=refs/e-verify &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
printf "verify %s $C\n" $prefix/foo |
|
||||||
|
git update-ref --stdin
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool 1-arg update' '
|
||||||
|
prefix=refs/e-update-1 &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
printf "update %s $D\n" $prefix/foo |
|
||||||
|
git update-ref --stdin
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool 2-arg update' '
|
||||||
|
prefix=refs/e-update-2 &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
printf "update %s $D $C\n" $prefix/foo |
|
||||||
|
git update-ref --stdin
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool 0-arg delete' '
|
||||||
|
prefix=refs/e-delete-0 &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
printf "delete %s\n" $prefix/foo |
|
||||||
|
git update-ref --stdin
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty directory should not fool 1-arg delete' '
|
||||||
|
prefix=refs/e-delete-1 &&
|
||||||
|
git update-ref $prefix/foo $C &&
|
||||||
|
git pack-refs --all &&
|
||||||
|
mkdir -p .git/$prefix/foo/bar/baz &&
|
||||||
|
printf "delete %s $C\n" $prefix/foo |
|
||||||
|
git update-ref --stdin
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user