Skip to content

Commit 4ed19a3

Browse files
Michael Dresselgitster
authored andcommitted
describe: match pattern for lightweight tags too
The <pattern> given "git describe --match" was used only to filter tag objects, and not to filter lightweight tags. This fixes it. [jc: made the log to clarify this is a bugfix, not an enhancement, with additional test] Signed-off-by: Michael Dressel <[email protected]> Acked-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28bc302 commit 4ed19a3

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

builtin-describe.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
8080
* Otherwise only annotated tags are used.
8181
*/
8282
if (might_be_tag) {
83-
if (is_tag) {
83+
if (is_tag)
8484
prio = 2;
85-
if (pattern && fnmatch(pattern, path + 10, 0))
86-
prio = 0;
87-
} else
85+
else
8886
prio = 1;
87+
88+
if (pattern && fnmatch(pattern, path + 10, 0))
89+
prio = 0;
8990
}
9091
else
9192
prio = 0;

t/t6120-describe.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,26 @@ test_expect_success 'rename tag Q back to A' '
117117
test_expect_success 'pack tag refs' 'git pack-refs'
118118
check_describe A-* HEAD
119119

120+
test_expect_success 'set-up matching pattern tests' '
121+
git tag -a -m test-annotated test-annotated &&
122+
echo >>file &&
123+
test_tick &&
124+
git commit -a -m "one more" &&
125+
git tag test1-lightweight &&
126+
echo >>file &&
127+
test_tick &&
128+
git commit -a -m "yet another" &&
129+
git tag test2-lightweight &&
130+
echo >>file &&
131+
test_tick &&
132+
git commit -a -m "even more"
133+
134+
'
135+
136+
check_describe "test-annotated-*" --match="test-*"
137+
138+
check_describe "test1-lightweight-*" --tags --match="test1-*"
139+
140+
check_describe "test2-lightweight-*" --tags --match="test2-*"
141+
120142
test_done

0 commit comments

Comments
 (0)