@matheusbsbs / matheus-bagliano / commits / 840624ff55
Fork 0

t4011: abstract away SHA-1-specific constants

Adjust the test so that it computes variables for object IDs 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 Oct 28, 2019 at 00:58 UTC 840624ff55f275c04447acad29e5ad5c1dac9af3
1 file changed +28 -12
t/t4011-diff-symlink.sh
+28 -12
@@ -9,11 +9,24 @@ test_description='Test diff of symlinks.
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/diff-lib.sh
11
12 +# Print the short OID of a symlink with the given name.
13 +symlink_oid () {
14 + local oid=$(printf "%s" "$1" | git hash-object --stdin) &&
15 + git rev-parse --short "$oid"
16 +}
17 +
18 +# Print the short OID of the given file.
19 +short_oid () {
20 + local oid=$(git hash-object "$1") &&
21 + git rev-parse --short "$oid"
22 +}
23 +
24 test_expect_success 'diff new symlink and file' '
13 - cat >expected <<-\EOF &&
25 + symlink=$(symlink_oid xyzzy) &&
26 + cat >expected <<-EOF &&
27 diff --git a/frotz b/frotz
28 new file mode 120000
16 - index 0000000..7c465af
29 + index 0000000..$symlink
30 --- /dev/null
31 +++ b/frotz
32 @@ -0,0 +1 @@
@@ -21,7 +34,7 @@ test_expect_success 'diff new symlink and file' '
34 \ No newline at end of file
35 diff --git a/nitfol b/nitfol
36 new file mode 100644
24 - index 0000000..7c465af
37 + index 0000000..$symlink
38 --- /dev/null
39 +++ b/nitfol
40 @@ -0,0 +1 @@
@@ -46,10 +59,10 @@ test_expect_success 'diff unchanged symlink and file' '
59 '
60
61 test_expect_success 'diff removed symlink and file' '
49 - cat >expected <<-\EOF &&
62 + cat >expected <<-EOF &&
63 diff --git a/frotz b/frotz
64 deleted file mode 120000
52 - index 7c465af..0000000
65 + index $symlink..0000000
66 --- a/frotz
67 +++ /dev/null
68 @@ -1 +0,0 @@
@@ -57,7 +70,7 @@ test_expect_success 'diff removed symlink and file' '
70 \ No newline at end of file
71 diff --git a/nitfol b/nitfol
72 deleted file mode 100644
60 - index 7c465af..0000000
73 + index $symlink..0000000
74 --- a/nitfol
75 +++ /dev/null
76 @@ -1 +0,0 @@
@@ -90,9 +103,10 @@ test_expect_success 'diff identical, but newly created symlink and file' '
103 '
104
105 test_expect_success 'diff different symlink and file' '
93 - cat >expected <<-\EOF &&
106 + new=$(symlink_oid yxyyz) &&
107 + cat >expected <<-EOF &&
108 diff --git a/frotz b/frotz
95 - index 7c465af..df1db54 120000
109 + index $symlink..$new 120000
110 --- a/frotz
111 +++ b/frotz
112 @@ -1 +1 @@
@@ -101,7 +115,7 @@ test_expect_success 'diff different symlink and file' '
115 +yxyyz
116 \ No newline at end of file
117 diff --git a/nitfol b/nitfol
104 - index 7c465af..df1db54 100644
118 + index $symlink..$new 100644
119 --- a/nitfol
120 +++ b/nitfol
121 @@ -1 +1 @@
@@ -137,14 +151,16 @@ test_expect_success SYMLINKS 'setup symlinks with attributes' '
151 '
152
153 test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
140 - cat >expect <<-\EOF &&
154 + file=$(short_oid file.bin) &&
155 + link=$(symlink_oid file.bin) &&
156 + cat >expect <<-EOF &&
157 diff --git a/file.bin b/file.bin
158 new file mode 100644
143 - index 0000000..d95f3ad
159 + index 0000000..$file
160 Binary files /dev/null and b/file.bin differ
161 diff --git a/link.bin b/link.bin
162 new file mode 120000
147 - index 0000000..dce41ec
163 + index 0000000..$link
164 --- /dev/null
165 +++ b/link.bin
166 @@ -0,0 +1 @@