git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jacob Keller <jacob.keller@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Git mailing list" <git@vger.kernel.org>
Subject: Re: [PATCH 4/5] revision.c: refactor ref selection handler after --exclude
Date: Wed, 25 Jan 2017 13:30:20 -0800	[thread overview]
Message-ID: <CA+P7+xovOx9ebo6MU0e4v==+76jtoMXz45+LnBPFifHbjqFU4w@mail.gmail.com> (raw)
In-Reply-To: <20170125212721.7tbxkqsdtsv2n5mx@sigill.intra.peff.net>

On Wed, Jan 25, 2017 at 1:27 PM, Jeff King <peff@peff.net> wrote:
> On Wed, Jan 25, 2017 at 03:57:18PM -0500, Jeff King wrote:
>
>> IOW, the ref-selector options build up until a group option is given,
>> which acts on the built-up options (over that group) and then resets the
>> built-up options. Doing "--unrelated" as above is orthogonal (though I
>> think in practice nobody would do that, because it's hard to read).
>
> So here's what I would have expected your series to look more like (with
> probably one patch adding clear_ref_selection_options, and the other
> adding the decorate stuff):
>

I agree that this is how I would have expected it to work as well.

Thanks,
Jake

> diff --git a/revision.c b/revision.c
> index b37dbec37..2f67707c7 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -1156,6 +1156,11 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
>
>         if (ref_excluded(cb->all_revs->ref_excludes, path))
>             return 0;
> +       if (cb->all_revs->decorate_reflog) {
> +               /* TODO actually do it for real */
> +               warning("would decorate %s", path);
> +               return 0; /* do not add it as a tip */
> +       }
>
>         object = get_reference(cb->all_revs, path, oid->hash, cb->all_flags);
>         add_rev_cmdline(cb->all_revs, object, path, REV_CMD_REF, cb->all_flags);
> @@ -1188,6 +1193,12 @@ void add_ref_exclusion(struct string_list **ref_excludes_p, const char *exclude)
>         string_list_append(*ref_excludes_p, exclude);
>  }
>
> +static void clear_ref_selection_options(struct rev_info *revs)
> +{
> +       clear_ref_exclusion(&revs->ref_excludes);
> +       revs->decorate_reflog = 0;
> +}
> +
>  static void handle_refs(const char *submodule, struct rev_info *revs, unsigned flags,
>                 int (*for_each)(const char *, each_ref_fn, void *))
>  {
> @@ -2080,10 +2091,10 @@ static int handle_revision_pseudo_opt(const char *submodule,
>         if (!strcmp(arg, "--all")) {
>                 handle_refs(submodule, revs, *flags, for_each_ref_submodule);
>                 handle_refs(submodule, revs, *flags, head_ref_submodule);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>         } else if (!strcmp(arg, "--branches")) {
>                 handle_refs(submodule, revs, *flags, for_each_branch_ref_submodule);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>         } else if (!strcmp(arg, "--bisect")) {
>                 read_bisect_terms(&term_bad, &term_good);
>                 handle_refs(submodule, revs, *flags, for_each_bad_bisect_ref);
> @@ -2091,15 +2102,15 @@ static int handle_revision_pseudo_opt(const char *submodule,
>                 revs->bisect = 1;
>         } else if (!strcmp(arg, "--tags")) {
>                 handle_refs(submodule, revs, *flags, for_each_tag_ref_submodule);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>         } else if (!strcmp(arg, "--remotes")) {
>                 handle_refs(submodule, revs, *flags, for_each_remote_ref_submodule);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>         } else 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);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>                 return argcount;
>         } else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
>                 add_ref_exclusion(&revs->ref_excludes, optarg);
> @@ -2108,17 +2119,19 @@ static int handle_revision_pseudo_opt(const char *submodule,
>                 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);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>         } else if (starts_with(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);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
>         } else if (starts_with(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);
> -               clear_ref_exclusion(&revs->ref_excludes);
> +               clear_ref_selection_options(revs);
> +       } else if (!strcmp(arg, "--decorate-reflog")) {
> +               revs->decorate_reflog = 1;
>         } else if (!strcmp(arg, "--reflog")) {
>                 add_reflogs_to_pending(revs, *flags);
>         } else if (!strcmp(arg, "--indexed-objects")) {
> diff --git a/revision.h b/revision.h
> index 9fac1a607..c74879829 100644
> --- a/revision.h
> +++ b/revision.h
> @@ -66,6 +66,8 @@ struct rev_info {
>         /* excluding from --branches, --refs, etc. expansion */
>         struct string_list *ref_excludes;
>
> +       int decorate_reflog;
> +
>         /* Basic information */
>         const char *prefix;
>         const char *def;

  reply	other threads:[~2017-01-25 21:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 12:26 [PATCH] log: new option decorate reflog of remote refs Nguyễn Thái Ngọc Duy
2017-01-19 17:23 ` Jeff King
2017-01-20 10:55   ` Duy Nguyen
2017-01-20 14:30     ` Jeff King
2017-01-20 22:00       ` Jacob Keller
2017-01-21 12:48         ` Duy Nguyen
2017-01-21 14:08           ` Jeff King
2017-01-25 12:50             ` [PATCH 0/5] Prep steps for --decorate-reflog Nguyễn Thái Ngọc Duy
2017-01-25 12:50               ` [PATCH 1/5] rev-list-options.txt: delete an empty line Nguyễn Thái Ngọc Duy
2017-01-25 12:50               ` [PATCH 2/5] revision.c: group ref selection options together Nguyễn Thái Ngọc Duy
2017-01-25 20:50                 ` Jeff King
2017-01-26  9:18                   ` Duy Nguyen
2017-01-26 14:19                     ` Jeff King
2017-01-25 21:11                 ` Junio C Hamano
2017-01-26  9:12                   ` Duy Nguyen
2017-01-25 12:50               ` [PATCH 3/5] revision.c: allow to change pseudo opt parsing function Nguyễn Thái Ngọc Duy
2017-01-25 12:50               ` [PATCH 4/5] revision.c: refactor ref selection handler after --exclude Nguyễn Thái Ngọc Duy
2017-01-25 17:41                 ` Jacob Keller
2017-01-25 20:57                 ` Jeff King
2017-01-25 21:27                   ` Jeff King
2017-01-25 21:30                     ` Jacob Keller [this message]
2017-01-25 23:25                       ` Junio C Hamano
2017-01-26  9:28                   ` Duy Nguyen
2017-01-26 14:24                     ` Jeff King
2017-01-26 18:43                     ` Junio C Hamano
2017-01-25 21:15                 ` Junio C Hamano
2017-01-25 12:50               ` [PATCH 5/5] revision.c: add --decorate-reflog 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+P7+xovOx9ebo6MU0e4v==+76jtoMXz45+LnBPFifHbjqFU4w@mail.gmail.com' \
    --to=jacob.keller@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).