@matheusbsbs / matheus-bagliano / commits / 4ed19a3c17
Fork 0

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 <MichaelTiloDressel@t-online.de> Acked-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Dressel committed Jun 4, 2008 at 21:06 UTC 4ed19a3c178d22fbd424af78b42b65533a8d1ebb
2 files changed +27 -4
builtin-describe.c
+5 -4
@@ -80,12 +80,13 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void
80 * Otherwise only annotated tags are used.
81 */
82 if (might_be_tag) {
83 - if (is_tag) {
83 + if (is_tag)
84 prio = 2;
85 - if (pattern && fnmatch(pattern, path + 10, 0))
86 - prio = 0;
87 - } else
85 + else
86 prio = 1;
87 +
88 + if (pattern && fnmatch(pattern, path + 10, 0))
89 + prio = 0;
90 }
91 else
92 prio = 0;
t/t6120-describe.sh
+22
@@ -117,4 +117,26 @@ test_expect_success 'rename tag Q back to A' '
117 test_expect_success 'pack tag refs' 'git pack-refs'
118 check_describe A-* HEAD
119
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 +
142 test_done