summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cc21682)
raw | patch | inline | side by side (parent: cc21682)
author | Pierre Habouzit <madcoder@debian.org> | |
Fri, 21 Dec 2007 21:49:54 +0000 (22:49 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 23 Dec 2007 05:13:50 +0000 (21:13 -0800) |
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-describe.txt | patch | blob | history | |
builtin-describe.c | patch | blob | history |
index ac23e28f2759222bb67fcf2445c229e918d96211..9c7a0323429af93520026374620f5620d79e8cb6 100644 (file)
being employed to standard error. The tag name will still
be printed to standard out.
+--match <pattern>::
+ Only consider tags matching the given pattern (can be used to avoid
+ leaking private tags made from the repository).
+
EXAMPLES
--------
diff --git a/builtin-describe.c b/builtin-describe.c
index 7a148a2c26591d82e6057d610182445eae5fe171..18eab47f6aea0f1388d457c722ea51b63699627f 100644 (file)
--- a/builtin-describe.c
+++ b/builtin-describe.c
static int tags; /* But allow any tags if --tags is specified */
static int abbrev = DEFAULT_ABBREV;
static int max_candidates = 10;
+const char *pattern = NULL;
struct commit_name {
int prio; /* annotated tag = 2, tag = 1, head = 0 */
* Otherwise only annotated tags are used.
*/
if (!prefixcmp(path, "refs/tags/")) {
- if (object->type == OBJ_TAG)
+ if (object->type == OBJ_TAG) {
prio = 2;
- else
+ if (pattern && fnmatch(pattern, path + 10, 0))
+ prio = 0;
+ } else
prio = 1;
}
else
OPT_BOOLEAN(0, "tags", &tags, "use any tag in .git/refs/tags"),
OPT__ABBREV(&abbrev),
OPT_INTEGER(0, "candidates", &max_candidates,
- "consider <n> most recent tags (default: 10)"),
+ "consider <n> most recent tags (default: 10)"),
+ OPT_STRING(0, "match", &pattern, "pattern",
+ "only consider tags matching <pattern>"),
OPT_END(),
};
save_commit_buffer = 0;
if (contains) {
- const char **args = xmalloc((4 + argc) * sizeof(char*));
+ const char **args = xmalloc((5 + argc) * sizeof(char*));
int i = 0;
args[i++] = "name-rev";
args[i++] = "--name-only";
- if (!all)
+ if (!all) {
args[i++] = "--tags";
+ if (pattern) {
+ char *s = xmalloc(strlen("--refs=refs/tags/") + strlen(pattern) + 1);
+ sprintf(s, "--refs=refs/tags/%s", pattern);
+ args[i++] = s;
+ }
+ }
memcpy(args + i, argv, argc * sizeof(char*));
args[i + argc] = NULL;
return cmd_name_rev(i + argc, args, prefix);