Signed-off-by: Matthieu Moy <Matthieu.Moy@xxxxxxx> --- revision.c | 31 +++++++++++++++++++++++-------- t/t6018-rev-list-glob.sh | 6 ++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/revision.c b/revision.c index 5d62340..93e6233 100644 --- a/revision.c +++ b/revision.c @@ -1486,6 +1486,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s { int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0; const char **prune_data = NULL; + const char *optarg; /* First, search for "--" */ seen_dashdash = 0; @@ -1501,6 +1502,20 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s break; } + /* + * Variant of IF_LONG_OPT, for setup_revisions (use argv[i+1] + * instead of argv[1], increment i directly) + */ +#define IF_LONG_OPT_SR(optname) \ + ((!strcmp(arg, "--" #optname) \ + && (argv[i+1] || (die("Option `" #optname "' requires a value"), 1), \ + optarg = argv[i+1], \ + i++, \ + 1)) || \ + (!prefixcmp(arg, "--" #optname "=") \ + && (optarg = arg + strlen("--" #optname "="), \ + 1))) + /* Second, deal with arguments and options */ flags = 0; read_from_stdin = 0; @@ -1532,28 +1547,28 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s handle_refs(revs, flags, for_each_remote_ref); continue; } - if (!prefixcmp(arg, "--glob=")) { + if (IF_LONG_OPT_SR(glob)) { struct all_refs_cb cb; init_all_refs_cb(&cb, revs, flags); - for_each_glob_ref(handle_one_ref, arg + 7, &cb); + for_each_glob_ref(handle_one_ref, optarg, &cb); continue; } - if (!prefixcmp(arg, "--branches=")) { + if (IF_LONG_OPT_SR(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); + for_each_glob_ref_in(handle_one_ref, optarg, "refs/heads/", &cb); continue; } - if (!prefixcmp(arg, "--tags=")) { + if (IF_LONG_OPT_SR(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); + for_each_glob_ref_in(handle_one_ref, optarg, "refs/tags/", &cb); continue; } - if (!prefixcmp(arg, "--remotes=")) { + if (IF_LONG_OPT_SR(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); + for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb); continue; } if (!strcmp(arg, "--reflog")) { diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh index 58428d9..fb8291c 100755 --- a/t/t6018-rev-list-glob.sh +++ b/t/t6018-rev-list-glob.sh @@ -123,6 +123,12 @@ test_expect_success 'rev-list --glob=refs/heads/subspace/*' ' ' +test_expect_success 'rev-list --glob refs/heads/subspace/*' ' + + compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*" + +' + test_expect_success 'rev-list --glob=heads/subspace/*' ' compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*" -- 1.7.2.25.g9ebe3 -- 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