Skip to content

Commit ff4cb42

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 56d8892 commit ff4cb42

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

t/t1410-reflog.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ check_fsck () {
3030
}
3131

3232
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
3534
}
3635

3736
recover () {
38-
aa=${1%??????????????????????????????????????} zz=${1#??}
37+
aa=$(echo $1 | cut -c 1-2)
3938
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)
4140
}
4241

4342
check_dont_have () {
@@ -55,6 +54,7 @@ check_dont_have () {
5554
}
5655

5756
test_expect_success setup '
57+
test_oid_init &&
5858
mkdir -p A/B &&
5959
echo rat >C &&
6060
echo ox >A/D &&
@@ -313,12 +313,12 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '
313313
# Each line is 114 characters, so we need 75 to still have a few before the
314314
# last 8K. The 89-character padding on the final entry lines up our
315315
# newline exactly.
316-
test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '
316+
test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
317317
git checkout -b reflogskip &&
318-
z38=00000000000000000000000000000000000000 &&
318+
zf=$(test_oid zero_2) &&
319319
ident="abc <xyz> 0000000001 +0000" &&
320320
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" &&
322322
if test $i = 75; then
323323
for j in $(test_seq 1 89); do
324324
printf X
@@ -329,7 +329,7 @@ test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '
329329
printf "\n"
330330
done >.git/logs/refs/heads/reflogskip &&
331331
git rev-parse reflogskip@{73} >actual &&
332-
echo ${z38}03 >expect &&
332+
echo ${zf}03 >expect &&
333333
test_cmp expect actual
334334
'
335335

0 commit comments

Comments
 (0)