t9301: make hash size independent

Instead of using a hard-coded all-zeros object ID, use $ZERO_OID.
Compute the length of the object IDs in use and use this instead of
hard-coding the constant 40.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
brian m. carlson 2020-07-29 23:14:12 +00:00 коммит произвёл Junio C Hamano
Родитель 287bb3abb3
Коммит b6e50052ac
1 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -470,12 +470,13 @@ test_expect_success 'add lots of commits and notes' '
' '
test_expect_success 'verify that lots of notes trigger a fanout scheme' ' test_expect_success 'verify that lots of notes trigger a fanout scheme' '
hexsz=$(test_oid hexsz) &&
# None of the entries in the top-level notes tree should be a full SHA1 # None of the entries in the top-level notes tree should be a full SHA1
git ls-tree --name-only refs/notes/many_notes | git ls-tree --name-only refs/notes/many_notes |
while read path while read path
do do
if test $(expr length "$path") -ge 40 if test $(expr length "$path") -ge $hexsz
then then
return 1 return 1
fi fi
@ -518,7 +519,7 @@ test_expect_success 'verify that importing a notes tree respects the fanout sche
git ls-tree --name-only refs/notes/other_notes | git ls-tree --name-only refs/notes/other_notes |
while read path while read path
do do
if test $(expr length "$path") -ge 40 if test $(expr length "$path") -ge $hexsz
then then
return 1 return 1
fi fi
@ -593,7 +594,7 @@ test_expect_success 'verify that changing notes respect existing fanout' '
git ls-tree --name-only refs/notes/many_notes | git ls-tree --name-only refs/notes/many_notes |
while read path while read path
do do
if test $(expr length "$path") -ge 40 if test $(expr length "$path") -ge $hexsz
then then
return 1 return 1
fi fi
@ -616,7 +617,7 @@ i=$(($num_commits - $remaining_notes))
for sha1 in $(git rev-list -n $i refs/heads/many_commits) for sha1 in $(git rev-list -n $i refs/heads/many_commits)
do do
cat >>input <<INPUT_END cat >>input <<INPUT_END
N 0000000000000000000000000000000000000000 $sha1 N $ZERO_OID $sha1
INPUT_END INPUT_END
done done
@ -646,7 +647,6 @@ test_expect_success 'remove lots of notes' '
' '
test_expect_success 'verify that removing notes trigger fanout consolidation' ' test_expect_success 'verify that removing notes trigger fanout consolidation' '
# All entries in the top-level notes tree should be a full SHA1 # All entries in the top-level notes tree should be a full SHA1
git ls-tree --name-only -r refs/notes/many_notes | git ls-tree --name-only -r refs/notes/many_notes |
while read path while read path
@ -656,7 +656,7 @@ test_expect_success 'verify that removing notes trigger fanout consolidation' '
test "$path" = "deadbeef" && continue test "$path" = "deadbeef" && continue
test "$path" = "de/adbeef" && continue test "$path" = "de/adbeef" && continue
if test $(expr length "$path") -ne 40 if test $(expr length "$path") -ne $hexsz
then then
return 1 return 1
fi fi