t3306: abstract away SHA-1-specific constants
Adjust the test so that it computes variables for object IDs instead of using hard-coded hashes. Convert some single-line heredocs into inline uses of echo now that they can be expressed succinctly. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Aug 18, 2019 at 19:16 UTC
b99bfc7a6c3b78574d171ada0fbcad3af2919f76
1 file changed
+21
-24
t/t3306-notes-prune.sh
+21
-24
@@ -11,23 +11,26 @@ test_expect_success 'setup: create a few commits with notes' '
11
test_tick &&
12
git commit -m 1st &&
13
git notes add -m "Note #1" &&
14
+ first=$(git rev-parse HEAD) &&
15
: > file2 &&
16
git add file2 &&
17
test_tick &&
18
git commit -m 2nd &&
19
git notes add -m "Note #2" &&
20
+ second=$(git rev-parse HEAD) &&
21
: > file3 &&
22
git add file3 &&
23
test_tick &&
24
git commit -m 3rd &&
23
- COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
25
+ third=$(git rev-parse HEAD) &&
26
+ COMMIT_FILE=$(echo $third | sed "s!^..!.git/objects/&/!") &&
27
test -f $COMMIT_FILE &&
28
test-tool chmtime =+0 $COMMIT_FILE &&
29
git notes add -m "Note #3"
30
'
31
32
cat > expect <<END_OF_LOG
30
-commit 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
33
+commit $third
34
Author: A U Thor <author@example.com>
35
Date: Thu Apr 7 15:15:13 2005 -0700
36
@@ -36,7 +39,7 @@ Date: Thu Apr 7 15:15:13 2005 -0700
39
Notes:
40
Note #3
41
39
-commit 08341ad9e94faa089d60fd3f523affb25c6da189
42
+commit $second
43
Author: A U Thor <author@example.com>
44
Date: Thu Apr 7 15:14:13 2005 -0700
45
@@ -45,7 +48,7 @@ Date: Thu Apr 7 15:14:13 2005 -0700
48
Notes:
49
Note #2
50
48
-commit ab5f302035f2e7aaf04265f08b42034c23256e1f
51
+commit $first
52
Author: A U Thor <author@example.com>
53
Date: Thu Apr 7 15:13:13 2005 -0700
54
@@ -70,16 +73,16 @@ test_expect_success 'remove some commits' '
73
74
test_expect_success 'verify that commits are gone' '
75
73
- test_must_fail git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
74
- git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
75
- git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
76
+ test_must_fail git cat-file -p $third &&
77
+ git cat-file -p $second &&
78
+ git cat-file -p $first
79
'
80
81
test_expect_success 'verify that notes are still present' '
82
80
- git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
81
- git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
82
- git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
83
+ git notes show $third &&
84
+ git notes show $second &&
85
+ git notes show $first
86
'
87
88
test_expect_success 'prune -n does not remove notes' '
@@ -90,13 +93,10 @@ test_expect_success 'prune -n does not remove notes' '
93
test_cmp expect actual
94
'
95
93
-cat > expect <<EOF
94
-5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29
95
-EOF
96
97
test_expect_success 'prune -n lists prunable notes' '
98
99
-
99
+ echo $third >expect &&
100
git notes prune -n > actual &&
101
test_cmp expect actual
102
'
@@ -109,9 +109,9 @@ test_expect_success 'prune notes' '
109
110
test_expect_success 'verify that notes are gone' '
111
112
- test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
113
- git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
114
- git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
112
+ test_must_fail git notes show $third &&
113
+ git notes show $second &&
114
+ git notes show $first
115
'
116
117
test_expect_success 'remove some commits' '
@@ -121,21 +121,18 @@ test_expect_success 'remove some commits' '
121
git gc --prune=now
122
'
123
124
-cat > expect <<EOF
125
-08341ad9e94faa089d60fd3f523affb25c6da189
126
-EOF
127
-
124
test_expect_success 'prune -v notes' '
125
126
+ echo $second >expect &&
127
git notes prune -v > actual &&
128
test_cmp expect actual
129
'
130
131
test_expect_success 'verify that notes are gone' '
132
136
- test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
137
- test_must_fail git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
138
- git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
133
+ test_must_fail git notes show $third &&
134
+ test_must_fail git notes show $second &&
135
+ git notes show $first
136
'
137
138
test_done