Skip to content

Commit 98de0b2

Browse files
bk2204gitster
authored andcommitted
t8002: make hash size independent
Compute the length of an object ID instead of hard-coding 40-based values. Signed-off-by: brian m. carlson <[email protected]> Reviewed-by: Eric Sunshine <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a5587b8 commit 98de0b2

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

t/t8002-blame.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ test_description='git blame'
66
PROG='git blame -c'
77
. "$TEST_DIRECTORY"/annotate-tests.sh
88

9+
test_expect_success 'setup' '
10+
hexsz=$(test_oid hexsz)
11+
'
12+
913
test_expect_success 'blame untracked file in empty repo' '
1014
>untracked &&
1115
test_must_fail git blame untracked
@@ -105,17 +109,17 @@ test_expect_success 'blame --abbrev=<n> works' '
105109
'
106110

107111
test_expect_success 'blame -l aligns regular and boundary commits' '
108-
check_abbrev 40 -l HEAD &&
109-
check_abbrev 39 -l ^HEAD
112+
check_abbrev $hexsz -l HEAD &&
113+
check_abbrev $((hexsz - 1)) -l ^HEAD
110114
'
111115

112-
test_expect_success 'blame --abbrev=40 behaves like -l' '
113-
check_abbrev 40 --abbrev=40 HEAD &&
114-
check_abbrev 39 --abbrev=40 ^HEAD
116+
test_expect_success 'blame --abbrev with full length behaves like -l' '
117+
check_abbrev $hexsz --abbrev=$hexsz HEAD &&
118+
check_abbrev $((hexsz - 1)) --abbrev=$hexsz ^HEAD
115119
'
116120

117-
test_expect_success '--no-abbrev works like --abbrev=40' '
118-
check_abbrev 40 --no-abbrev
121+
test_expect_success '--no-abbrev works like --abbrev with full length' '
122+
check_abbrev $hexsz --no-abbrev
119123
'
120124

121125
test_expect_success '--exclude-promisor-objects does not BUG-crash' '

0 commit comments

Comments
 (0)