]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t4020: abstract away SHA-1-specific constants
authorbrian m. carlson <sandals@crustytoothpaste.net>
Mon, 21 May 2018 02:01:37 +0000 (02:01 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 May 2018 04:55:48 +0000 (13:55 +0900)
Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4020-diff-external.sh

index 49d3f54b298c6519cf83dd59a3886fed9bdf4d96..e009826fcbe5a893df748a47d162e010b95d758b 100755 (executable)
@@ -13,6 +13,8 @@ test_expect_success setup '
 
        test_tick &&
        echo second >file &&
+       before=$(git hash-object file) &&
+       before=$(git rev-parse --short $before) &&
        git add file &&
        git commit -m second &&
 
@@ -180,9 +182,13 @@ test_expect_success 'no diff with -diff' '
 echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
 
 test_expect_success 'force diff with "diff"' '
+       after=$(git hash-object file) &&
+       after=$(git rev-parse --short $after) &&
        echo >.gitattributes "file diff" &&
        git diff >actual &&
-       test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
+       sed -e "s/^index .*/index $before..$after 100644/" \
+               "$TEST_DIRECTORY"/t4020/diff.NUL >expected-diff &&
+       test_cmp expected-diff actual
 '
 
 test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '
@@ -237,7 +243,7 @@ test_expect_success 'diff --cached' '
        git update-index --assume-unchanged file &&
        echo second >file &&
        git diff --cached >actual &&
-       test_cmp "$TEST_DIRECTORY"/t4020/diff.NUL actual
+       test_cmp expected-diff actual
 '
 
 test_expect_success 'clean up crlf leftovers' '