t1410: make hash size independent

Instead of parsing object IDs using fixed-length shell patterns, use cut to extract the first two characters of an object ID in addition to the test helper for object paths. Update another test to look up an appropriate object ID fragment from the all-zeros object ID instead of hardcoding the value. Although the test for parsing reflogs at BUFSIZ boundaries passes, mark it with the SHA1 prerequisite, as it doesn't currently usefully test anything when using a hash longer than 20 bytes. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jun 28, 2019 at 22:59 UTC ff4cb42e77a020877fdb9866d3b03e9669cc6325
1 file changed +8 -8
t/t1410-reflog.sh
+8 -8
@@ -30,14 +30,13 @@ check_fsck () {
30 }
31
32 corrupt () {
33 - aa=${1%??????????????????????????????????????} zz=${1#??}
34 - mv .git/objects/$aa/$zz .git/$aa$zz
33 + mv .git/objects/$(test_oid_to_path $1) .git/$1
34 }
35
36 recover () {
38 - aa=${1%??????????????????????????????????????} zz=${1#??}
37 + aa=$(echo $1 | cut -c 1-2)
38 mkdir -p .git/objects/$aa
40 - mv .git/$aa$zz .git/objects/$aa/$zz
39 + mv .git/$1 .git/objects/$(test_oid_to_path $1)
40 }
41
42 check_dont_have () {
@@ -55,6 +54,7 @@ check_dont_have () {
54 }
55
56 test_expect_success setup '
57 + test_oid_init &&
58 mkdir -p A/B &&
59 echo rat >C &&
60 echo ox >A/D &&
@@ -313,12 +313,12 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '
313 # Each line is 114 characters, so we need 75 to still have a few before the
314 # last 8K. The 89-character padding on the final entry lines up our
315 # newline exactly.
316 -test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '
316 +test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
317 git checkout -b reflogskip &&
318 - z38=00000000000000000000000000000000000000 &&
318 + zf=$(test_oid zero_2) &&
319 ident="abc <xyz> 0000000001 +0000" &&
320 for i in $(test_seq 1 75); do
321 - printf "$z38%02d $z38%02d %s\t" $i $(($i+1)) "$ident" &&
321 + printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
322 if test $i = 75; then
323 for j in $(test_seq 1 89); do
324 printf X
@@ -329,7 +329,7 @@ test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '
329 printf "\n"
330 done >.git/logs/refs/heads/reflogskip &&
331 git rev-parse reflogskip@{73} >actual &&
332 - echo ${z38}03 >expect &&
332 + echo ${zf}03 >expect &&
333 test_cmp expect actual
334 '
335