From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 08/19] rev-parseopt: convert --remotes
Date: Wed, 8 May 2019 18:12:38 +0700 [thread overview]
Message-ID: <20190508111249.15262-9-pclouds@gmail.com> (raw)
In-Reply-To: <20190508111249.15262-1-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
revision.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/revision.c b/revision.c
index 5183cdf66d..bcfca8856f 100644
--- a/revision.c
+++ b/revision.c
@@ -2425,6 +2425,27 @@ static int rev_opt_branches(const struct option *opt,
return 0;
}
+static int rev_opt_remotes(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct rev_info *revs = opt->value;
+ int flags = *revs->pseudo_flags;
+ struct ref_store *refs = revs->pseudo_refs;
+
+ BUG_ON_OPT_NEG(unset);
+ if (arg) {
+ struct all_refs_cb cb;
+
+ init_all_refs_cb(&cb, revs, flags);
+ for_each_glob_ref_in(handle_one_ref, arg, "refs/remotes/", &cb);
+ clear_ref_exclusion(&revs->ref_excludes);
+ } else {
+ handle_refs(refs, revs, flags, refs_for_each_remote_ref);
+ clear_ref_exclusion(&revs->ref_excludes);
+ }
+ return 0;
+}
+
static int rev_opt_tags(const struct option *opt,
const char *arg, int unset)
{
@@ -2471,6 +2492,9 @@ static void make_pseudo_options(struct rev_info *revs)
OPT_REV_OPTARG(0, "tags", N_("<pattern>"),
N_("include all refs in refs/tags (optionally matches pattern)"),
rev_opt_tags),
+ OPT_REV_OPTARG(0, "remotes", N_("<pattern>"),
+ N_("include all refs in refs/remotes (optionally matches pattern)"),
+ rev_opt_remotes),
OPT_END()
};
ALLOC_ARRAY(revs->pseudo_options, ARRAY_SIZE(options));
@@ -2511,10 +2535,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
if (argc)
return argc;
- if (!strcmp(arg, "--remotes")) {
- handle_refs(refs, revs, *flags, refs_for_each_remote_ref);
- clear_ref_exclusion(&revs->ref_excludes);
- } else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
+ if ((argcount = parse_long_opt("glob", argv, &optarg))) {
struct all_refs_cb cb;
init_all_refs_cb(&cb, revs, *flags);
for_each_glob_ref(handle_one_ref, optarg, &cb);
@@ -2523,11 +2544,6 @@ static int handle_revision_pseudo_opt(const char *submodule,
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
add_ref_exclusion(&revs->ref_excludes, optarg);
return argcount;
- } else if (skip_prefix(arg, "--remotes=", &optarg)) {
- struct all_refs_cb cb;
- init_all_refs_cb(&cb, revs, *flags);
- for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb);
- clear_ref_exclusion(&revs->ref_excludes);
} else if (!strcmp(arg, "--reflog")) {
add_reflogs_to_pending(revs, *flags);
} else if (!strcmp(arg, "--indexed-objects")) {
--
2.21.0.1141.gd54ac2cb17
next prev parent reply other threads:[~2019-05-08 11:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 11:12 [PATCH 00/19] Convert revision.c to parseopt part 1/4 Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 01/19] revision.h: avoid bit fields in struct rev_info Nguyễn Thái Ngọc Duy
2019-05-08 14:07 ` Derrick Stolee
2019-05-08 14:41 ` Duy Nguyen
2019-05-08 15:52 ` Derrick Stolee
2019-05-09 9:56 ` Duy Nguyen
2019-05-09 12:11 ` Derrick Stolee
2019-05-08 11:12 ` [PATCH 02/19] revision.h: move repo field down Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 03/19] revision.c: prepare to convert handle_revision_pseudo_opt() Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 04/19] rev-parseopt: convert --all Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 05/19] rev-parseopt: convert --branches Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 06/19] rev-parseopt: convert --bisect Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 07/19] rev-parseopt: convert --tags Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` Nguyễn Thái Ngọc Duy [this message]
2019-05-08 11:12 ` [PATCH 09/19] rev-parseopt: convert --glob Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 10/19] rev-parseopt: convert --exclude Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 11/19] rev-parseopt: convert --reflog Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 12/19] rev-parseopt: convert --indexed-objects Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 13/19] rev-parseopt: convert --not Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 14/19] rev-parseopt: convert --no-walk and --do-walk Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 15/19] rev-parseopt: convert --single-worktree Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 16/19] rev-parseopt: prepare to convert handle_revision_opt() Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 17/19] rev-parseopt: convert --max-count Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 18/19] rev-parseopt: convert --skip Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 19/19] rev-parseopt: convert --min-age and --max-age Nguyễn Thái Ngọc Duy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190508111249.15262-9-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.