Merge branch 'il/rev-glob'

* il/rev-glob:
  Documentation: improve description of --glob=pattern and friends
  rev-parse --branches/--tags/--remotes=pattern
  rev-parse --glob
This commit is contained in:
Junio C Hamano
2010-01-22 16:08:16 -08:00
9 changed files with 356 additions and 18 deletions

View File

@ -700,12 +700,18 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag,
return 0;
}
static void init_all_refs_cb(struct all_refs_cb *cb, struct rev_info *revs,
unsigned flags)
{
cb->all_revs = revs;
cb->all_flags = flags;
}
static void handle_refs(struct rev_info *revs, unsigned flags,
int (*for_each)(each_ref_fn, void *))
{
struct all_refs_cb cb;
cb.all_revs = revs;
cb.all_flags = flags;
init_all_refs_cb(&cb, revs, flags);
for_each(handle_one_ref, &cb);
}
@ -1362,6 +1368,30 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
handle_refs(revs, flags, for_each_remote_ref);
continue;
}
if (!prefixcmp(arg, "--glob=")) {
struct all_refs_cb cb;
init_all_refs_cb(&cb, revs, flags);
for_each_glob_ref(handle_one_ref, arg + 7, &cb);
continue;
}
if (!prefixcmp(arg, "--branches=")) {
struct all_refs_cb cb;
init_all_refs_cb(&cb, revs, flags);
for_each_glob_ref_in(handle_one_ref, arg + 11, "refs/heads/", &cb);
continue;
}
if (!prefixcmp(arg, "--tags=")) {
struct all_refs_cb cb;
init_all_refs_cb(&cb, revs, flags);
for_each_glob_ref_in(handle_one_ref, arg + 7, "refs/tags/", &cb);
continue;
}
if (!prefixcmp(arg, "--remotes=")) {
struct all_refs_cb cb;
init_all_refs_cb(&cb, revs, flags);
for_each_glob_ref_in(handle_one_ref, arg + 10, "refs/remotes/", &cb);
continue;
}
if (!strcmp(arg, "--reflog")) {
handle_reflog(revs, flags);
continue;