Skip to content

Commit 501ec0d

Browse files
committed
Merge branch 'jk/describe-omit-some-refs' into maint
"git describe --match" learned to take multiple patterns in v2.13 series, but the feature ignored the patterns after the first one and did not work at all. This has been fixed. * jk/describe-omit-some-refs: describe: fix matching to actually match all patterns
2 parents 8dc1d0b + da769d2 commit 501ec0d

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

builtin/describe.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,21 @@ static int get_name(const char *path, const struct object_id *oid, int flag, voi
155155
* pattern.
156156
*/
157157
if (patterns.nr) {
158+
int found = 0;
158159
struct string_list_item *item;
159160

160161
if (!is_tag)
161162
return 0;
162163

163164
for_each_string_list_item(item, &patterns) {
164-
if (!wildmatch(item->string, path + 10, 0))
165+
if (!wildmatch(item->string, path + 10, 0)) {
166+
found = 1;
165167
break;
168+
}
169+
}
166170

167-
/* If we get here, no pattern matched. */
171+
if (!found)
168172
return 0;
169-
}
170173
}
171174

172175
/* Is it annotated? */

t/t6120-describe.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,14 @@ check_describe "test2-lightweight-*" --tags --match="test2-*"
182182

183183
check_describe "test2-lightweight-*" --long --tags --match="test2-*" HEAD^
184184

185-
check_describe "test1-lightweight-*" --long --tags --match="test1-*" --match="test2-*" HEAD^
185+
check_describe "test2-lightweight-*" --long --tags --match="test1-*" --match="test2-*" HEAD^
186186

187187
check_describe "test2-lightweight-*" --long --tags --match="test1-*" --no-match --match="test2-*" HEAD^
188188

189+
check_describe "test1-lightweight-*" --long --tags --match="test1-*" --match="test3-*" HEAD
190+
191+
check_describe "test1-lightweight-*" --long --tags --match="test3-*" --match="test1-*" HEAD
192+
189193
test_expect_success 'name-rev with exact tags' '
190194
echo A >expect &&
191195
tag_object=$(git rev-parse refs/tags/A) &&

0 commit comments

Comments
 (0)