Add the --refs=<pattern> option, which can be used to select a subset of refs matching the specified glob pattern. Signed-off-by: Sergey Vlasov <vsu@xxxxxxxxxxx> --- If --all-branches is too specific for the mentioned use case, what about adding a more general glob pattern match? Documentation/git-rev-list.txt | 9 +++++++++ revision.c | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index ec43c0b..d5f99ef 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -17,6 +17,7 @@ SYNOPSIS [ \--remove-empty ] [ \--not ] [ \--all ] + [ \--refs=<pattern> ] [ \--stdin ] [ \--topo-order ] [ \--parents ] @@ -179,6 +180,14 @@ limiting may be applied. Pretend as if all the refs in `$GIT_DIR/refs/` are listed on the command line as '<commit>'. +--refs='pattern':: + + Pretend as if all the refs in `$GIT_DIR/refs/` matching the + specified glob pattern are listed on the command line as + '<commit>'. The initial `refs/` part is skipped when matching, + but the subsequent `heads/`, `tags/` or `remotes/` part is + included in the text to match. + --stdin:: In addition to the '<commit>' listed on the command diff --git a/revision.c b/revision.c index 993bb66..240ff59 100644 --- a/revision.c +++ b/revision.c @@ -7,6 +7,7 @@ #include "refs.h" #include "revision.h" #include <regex.h> +#include <fnmatch.h> #include "grep.h" static char *path_name(struct name_path *path, const char *name) @@ -464,18 +465,28 @@ static void limit_list(struct rev_info * static int all_flags; static struct rev_info *all_revs; +static const char *all_pattern; static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) { - struct object *object = get_reference(all_revs, path, sha1, all_flags); + struct object *object; + + if (all_pattern) { + if (strncmp(path, "refs/", 5)) + return 0; + if (fnmatch(all_pattern, path + 5, 0)) + return 0; + } + object = get_reference(all_revs, path, sha1, all_flags); add_pending_object(all_revs, object, ""); return 0; } -static void handle_all(struct rev_info *revs, unsigned flags) +static void handle_all(struct rev_info *revs, unsigned flags, const char *pattern) { all_revs = revs; all_flags = flags; + all_pattern = pattern; for_each_ref(handle_one_ref, NULL); } @@ -800,7 +811,11 @@ int setup_revisions(int argc, const char continue; } if (!strcmp(arg, "--all")) { - handle_all(revs, flags); + handle_all(revs, flags, NULL); + continue; + } + if (!strncmp(arg, "--refs=", 7)) { + handle_all(revs, flags, arg + 7); continue; } if (!strcmp(arg, "--not")) { -- 1.4.4.1.gb0b0 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html