@@ -21,12 +21,10 @@ check_describe () {
21
21
shift
22
22
describe_opts=" $@ "
23
23
test_expect_success " describe $describe_opts " '
24
- R=$(git describe $describe_opts 2>err.actual) &&
25
- case "$R" in
26
- $expect) echo happy ;;
27
- *) echo "Oops - $R is not $expect" &&
28
- false ;;
29
- esac
24
+ git describe $describe_opts 2>err.actual >raw &&
25
+ sed -e "s/-g[0-9a-f]*\$/-gHASH/" <raw >actual &&
26
+ echo "$expect" >expect &&
27
+ test_cmp expect actual
30
28
'
31
29
}
32
30
@@ -59,29 +57,29 @@ test_expect_success setup '
59
57
test_commit --no-tag x file
60
58
'
61
59
62
- check_describe A-* HEAD
63
- check_describe A-* HEAD^
64
- check_describe R-* HEAD^^
65
- check_describe A-* HEAD^^2
60
+ check_describe A-8-gHASH HEAD
61
+ check_describe A-7-gHASH HEAD^
62
+ check_describe R-2-gHASH HEAD^^
63
+ check_describe A-3-gHASH HEAD^^2
66
64
check_describe B HEAD^^2^
67
- check_describe R-* HEAD^^^
65
+ check_describe R-1-gHASH HEAD^^^
68
66
69
- check_describe c-* --tags HEAD
70
- check_describe c-* --tags HEAD^
71
- check_describe e-* --tags HEAD^^
72
- check_describe c-* --tags HEAD^^2
67
+ check_describe c-7-gHASH --tags HEAD
68
+ check_describe c-6-gHASH --tags HEAD^
69
+ check_describe e-1-gHASH --tags HEAD^^
70
+ check_describe c-2-gHASH --tags HEAD^^2
73
71
check_describe B --tags HEAD^^2^
74
72
check_describe e --tags HEAD^^^
75
73
76
74
check_describe heads/main --all HEAD
77
- check_describe tags/c-* --all HEAD^
75
+ check_describe tags/c-6-gHASH --all HEAD^
78
76
check_describe tags/e --all HEAD^^^
79
77
80
- check_describe B-0-* --long HEAD^^2^
81
- check_describe A-3-* --long HEAD^^2
78
+ check_describe B-0-gHASH --long HEAD^^2^
79
+ check_describe A-3-gHASH --long HEAD^^2
82
80
83
- check_describe c-7-* --tags
84
- check_describe e-3-* --first-parent --tags
81
+ check_describe c-7-gHASH --tags
82
+ check_describe e-3-gHASH --first-parent --tags
85
83
86
84
test_expect_success ' describe --contains defaults to HEAD without commit-ish' '
87
85
echo "A^0" >expect &&
@@ -102,7 +100,7 @@ test_expect_success 'rename tag A to Q locally' '
102
100
cat - > err.expect << EOF
103
101
warning: tag 'Q' is externally known as 'A'
104
102
EOF
105
- check_describe A-* HEAD
103
+ check_describe A-8-gHASH HEAD
106
104
test_expect_success ' warning was displayed for Q' '
107
105
test_cmp err.expect err.actual
108
106
'
@@ -129,22 +127,22 @@ test_expect_success 'rename tag Q back to A' '
129
127
'
130
128
131
129
test_expect_success ' pack tag refs' ' git pack-refs'
132
- check_describe A-* HEAD
130
+ check_describe A-8-gHASH HEAD
133
131
134
132
test_expect_success ' describe works from outside repo using --git-dir' '
135
133
git clone --bare "$TRASH_DIRECTORY" "$TRASH_DIRECTORY/bare" &&
136
134
git --git-dir "$TRASH_DIRECTORY/bare" describe >out &&
137
- grep -E "^A-[1-9][0-9]? -g[0-9a-f]+$" out
135
+ grep -E "^A-8 -g[0-9a-f]+$" out
138
136
'
139
137
140
- check_describe " A-*[0-9a-f] " --dirty
138
+ check_describe " A-8-gHASH " --dirty
141
139
142
140
test_expect_success ' describe --dirty with --work-tree' '
143
141
(
144
142
cd "$TEST_DIRECTORY" &&
145
143
git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty >"$TRASH_DIRECTORY/out"
146
144
) &&
147
- grep -E "^A-[1-9][0-9]? -g[0-9a-f]+$" out
145
+ grep -E "^A-8 -g[0-9a-f]+$" out
148
146
'
149
147
150
148
test_expect_success ' set-up dirty work tree' '
@@ -157,7 +155,7 @@ test_expect_success 'describe --dirty with --work-tree (dirty)' '
157
155
cd "$TEST_DIRECTORY" &&
158
156
git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty >"$TRASH_DIRECTORY/out"
159
157
) &&
160
- grep -E "^A-[1-9][0-9]? -g[0-9a-f]+-dirty$" out &&
158
+ grep -E "^A-8 -g[0-9a-f]+-dirty$" out &&
161
159
test_cmp expected out
162
160
'
163
161
@@ -167,7 +165,7 @@ test_expect_success 'describe --dirty=.mod with --work-tree (dirty)' '
167
165
cd "$TEST_DIRECTORY" &&
168
166
git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty=.mod >"$TRASH_DIRECTORY/out"
169
167
) &&
170
- grep -E "^A-[1-9][0-9]? -g[0-9a-f]+.mod$" out &&
168
+ grep -E "^A-8 -g[0-9a-f]+.mod$" out &&
171
169
test_cmp expected out
172
170
'
173
171
@@ -191,21 +189,21 @@ test_expect_success 'set-up matching pattern tests' '
191
189
192
190
'
193
191
194
- check_describe " test-annotated-* " --match=" test-*"
192
+ check_describe " test-annotated-3-gHASH " --match=" test-*"
195
193
196
- check_describe " test1-lightweight-* " --tags --match=" test1-*"
194
+ check_describe " test1-lightweight-2-gHASH " --tags --match=" test1-*"
197
195
198
- check_describe " test2-lightweight-* " --tags --match=" test2-*"
196
+ check_describe " test2-lightweight-1-gHASH " --tags --match=" test2-*"
199
197
200
- check_describe " test2-lightweight-* " --long --tags --match=" test2-*" HEAD^
198
+ check_describe " test2-lightweight-0-gHASH " --long --tags --match=" test2-*" HEAD^
201
199
202
- check_describe " test2-lightweight-* " --long --tags --match=" test1-*" --match=" test2-*" HEAD^
200
+ check_describe " test2-lightweight-0-gHASH " --long --tags --match=" test1-*" --match=" test2-*" HEAD^
203
201
204
- check_describe " test2-lightweight-* " --long --tags --match=" test1-*" --no-match --match=" test2-*" HEAD^
202
+ check_describe " test2-lightweight-0-gHASH " --long --tags --match=" test1-*" --no-match --match=" test2-*" HEAD^
205
203
206
- check_describe " test1-lightweight-* " --long --tags --match=" test1-*" --match=" test3-*" HEAD
204
+ check_describe " test1-lightweight-2-gHASH " --long --tags --match=" test1-*" --match=" test3-*" HEAD
207
205
208
- check_describe " test1-lightweight-* " --long --tags --match=" test3-*" --match=" test1-*" HEAD
206
+ check_describe " test1-lightweight-2-gHASH " --long --tags --match=" test3-*" --match=" test1-*" HEAD
209
207
210
208
test_expect_success ' set-up branches' '
211
209
git branch branch_A A &&
@@ -215,11 +213,11 @@ test_expect_success 'set-up branches' '
215
213
git update-ref refs/original/original_branch_A test-annotated~2
216
214
'
217
215
218
- check_describe " heads/branch_A* " --all --match=" branch_*" --exclude=" branch_C" HEAD
216
+ check_describe " heads/branch_A-11-gHASH " --all --match=" branch_*" --exclude=" branch_C" HEAD
219
217
220
- check_describe " remotes/origin/remote_branch_A* " --all --match=" origin/remote_branch_*" --exclude=" origin/remote_branch_C" HEAD
218
+ check_describe " remotes/origin/remote_branch_A-11-gHASH " --all --match=" origin/remote_branch_*" --exclude=" origin/remote_branch_C" HEAD
221
219
222
- check_describe " original/original_branch_A* " --all test-annotated~1
220
+ check_describe " original/original_branch_A-6-gHASH " --all test-annotated~1
223
221
224
222
test_expect_success ' --match does not work for other types' '
225
223
test_must_fail git describe --all --match="*original_branch_*" test-annotated~1
@@ -489,7 +487,7 @@ test_expect_success 'describe commits with disjoint bases' '
489
487
git tag B -a -m B &&
490
488
git merge --no-ff --allow-unrelated-histories main -m x &&
491
489
492
- check_describe "A-3-* " HEAD
490
+ check_describe "A-3-gHASH " HEAD
493
491
)
494
492
'
495
493
@@ -515,7 +513,7 @@ test_expect_success 'describe commits with disjoint bases 2' '
515
513
git tag B -a -m B &&
516
514
git merge --no-ff --allow-unrelated-histories main -m x &&
517
515
518
- check_describe "B-3-* " HEAD
516
+ check_describe "B-3-gHASH " HEAD
519
517
)
520
518
'
521
519
0 commit comments