Skip to content

Commit f2fffc1

Browse files
bk2204gitster
authored andcommitted
t4020: abstract away SHA-1-specific constants
Adjust the test so that it computes variables for blobs instead of using hard-coded hashes. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bdee9cd commit f2fffc1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

t/t4020-diff-external.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ test_expect_success setup '
1313
1414
test_tick &&
1515
echo second >file &&
16+
before=$(git hash-object file) &&
17+
before=$(git rev-parse --short $before) &&
1618
git add file &&
1719
git commit -m second &&
1820
@@ -180,9 +182,13 @@ test_expect_success 'no diff with -diff' '
180182
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
181183

182184
test_expect_success 'force diff with "diff"' '
185+
after=$(git hash-object file) &&
186+
after=$(git rev-parse --short $after) &&
183187
echo >.gitattributes "file diff" &&
184188
git diff >actual &&
185-
test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
189+
sed -e "s/^index .*/index $before..$after 100644/" \
190+
"$TEST_DIRECTORY"/t4020/diff.NUL >expected-diff &&
191+
test_cmp expected-diff actual
186192
'
187193

188194
test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '
@@ -237,7 +243,7 @@ test_expect_success 'diff --cached' '
237243
git update-index --assume-unchanged file &&
238244
echo second >file &&
239245
git diff --cached >actual &&
240-
test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
246+
test_cmp expected-diff actual
241247
'
242248

243249
test_expect_success 'clean up crlf leftovers' '

0 commit comments

Comments
 (0)