t4045: 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 <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed May 21, 2018 at 02:01 UTC 5c024287ad9e523d2fbd0bce6e2786fe7231e0f3
1 file changed +4 -2
t/t4045-diff-relative.sh
+4 -2
@@ -8,6 +8,7 @@ test_expect_success 'setup' '
8 echo content >file1 &&
9 mkdir subdir &&
10 echo other content >subdir/file2 &&
11 + blob=$(git hash-object subdir/file2) &&
12 git add . &&
13 git commit -m one
14 '
@@ -17,10 +18,11 @@ check_diff () {
18 shift
19 expect=$1
20 shift
21 + short_blob=$(git rev-parse --short $blob)
22 cat >expected <<-EOF
23 diff --git a/$expect b/$expect
24 new file mode 100644
23 - index 0000000..25c05ef
25 + index 0000000..$short_blob
26 --- /dev/null
27 +++ b/$expect
28 @@ -0,0 +1 @@
@@ -68,7 +70,7 @@ check_raw () {
70 expect=$1
71 shift
72 cat >expected <<-EOF
71 - :000000 100644 0000000000000000000000000000000000000000 25c05ef3639d2d270e7fe765a67668f098092bc5 A $expect
73 + :000000 100644 0000000000000000000000000000000000000000 $blob A $expect
74 EOF
75 test_expect_success "--raw $*" "
76 git -C '$dir' diff --no-abbrev --raw $* HEAD^ >actual &&