summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53756f2)
raw | patch | inline | side by side (parent: 53756f2)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Sat, 17 Feb 2007 18:22:35 +0000 (19:22 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 17 Feb 2007 19:26:49 +0000 (11:26 -0800) |
Instead of (or, in addition to) --tags, to use only tags for naming,
you can now use --refs=<pattern> to specify a shell glob pattern
which the refs must match to be used for naming.
Example:
$ git name-rev --refs=*v1* 33db5f4d
33db5f4d tags/v1.0rc1^0~1593
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
you can now use --refs=<pattern> to specify a shell glob pattern
which the refs must match to be used for naming.
Example:
$ git name-rev --refs=*v1* 33db5f4d
33db5f4d tags/v1.0rc1^0~1593
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-name-rev.txt | patch | blob | history | |
builtin-name-rev.c | patch | blob | history |
index 37fbf66efb91ff74bf57d1b33b5ab95a248713cd..5b5c4c865f49d1da36fa1fbbcae96a33fd8da9a4 100644 (file)
SYNOPSIS
--------
-'git-name-rev' [--tags] ( --all | --stdin | <committish>... )
+'git-name-rev' [--tags] [--refs=<pattern>]
+ ( --all | --stdin | <committish>... )
DESCRIPTION
-----------
--tags::
Do not use branch names, but only tags to name the commits
+--refs=<pattern>::
+ Only use refs whose names match a given shell pattern.
+
--all::
List all commits reachable from all refs
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index b4f15cc38ab7fa045fc5cf025ca3fd6251a01973..36f1ba6d384d963c3ef3af1c82aff360f2409995 100644 (file)
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
#include "refs.h"
static const char name_rev_usage[] =
- "git-name-rev [--tags] ( --all | --stdin | committish [committish...] )\n";
+ "git-name-rev [--tags | --refs=<pattern>] ( --all | --stdin | committish [committish...] )\n";
typedef struct rev_name {
const char *tip_name;
}
}
+struct name_ref_data {
+ int tags_only;
+ const char *ref_filter;
+};
+
static int name_ref(const char *path, const unsigned char *sha1, int flags, void *cb_data)
{
struct object *o = parse_object(sha1);
- int tags_only = *(int*)cb_data;
+ struct name_ref_data *data = cb_data;
int deref = 0;
- if (tags_only && strncmp(path, "refs/tags/", 10))
+ if (data->tags_only && strncmp(path, "refs/tags/", 10))
+ return 0;
+
+ if (data->ref_filter && fnmatch(data->ref_filter, path, 0))
return 0;
while (o && o->type == OBJ_TAG) {
{
struct object_array revs = { 0, 0, NULL };
int as_is = 0, all = 0, transform_stdin = 0;
- int tags_only = 0;
+ struct name_ref_data data = { 0, NULL };
git_config(git_default_config);
as_is = 1;
continue;
} else if (!strcmp(*argv, "--tags")) {
- tags_only = 1;
+ data.tags_only = 1;
+ continue;
+ } else if (!strncmp(*argv, "--refs=", 7)) {
+ data.ref_filter = *argv + 7;
continue;
} else if (!strcmp(*argv, "--all")) {
if (argc > 1)
add_object_array((struct object *)commit, *argv, &revs);
}
- for_each_ref(name_ref, &tags_only);
+ for_each_ref(name_ref, &data);
if (transform_stdin) {
char buffer[2048];