git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Git Mailing List <git@vger.kernel.org>,
	Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCH 2/5] revision.c: group ref selection options together
Date: Thu, 26 Jan 2017 16:18:06 +0700	[thread overview]
Message-ID: <CACsJy8CeUWD9ux3Q-VRhwR4-qbSD69CzH2mmztVH_-cx=31h8w@mail.gmail.com> (raw)
In-Reply-To: <20170125205037.cg3aebh5rsx4zb2l@sigill.intra.peff.net>

On Thu, Jan 26, 2017 at 3:50 AM, Jeff King <peff@peff.net> wrote:
> On Wed, Jan 25, 2017 at 07:50:51PM +0700, Nguyễn Thái Ngọc Duy wrote:
>
>> These options have on thing in common: when specified right after
>> --exclude, they will de-select refs instead of selecting them by
>> default.
>>
>> This change makes it possible to introduce new options that use these
>> options in the same way as --exclude. Such an option would just
>> implement something like handle_refs_pseudo_opt().
>>
>> parse_ref_selector_option() is taken out of handle_refs_pseudo_opt() so
>> that similar functions like handle_refs_pseudo_opt() are forced to
>> handle all ref selector options, not skipping some by mistake, which may
>> revert the option back to default behavior (rev selection).
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>>  revision.c | 134 +++++++++++++++++++++++++++++++++++++++++++++----------------
>>  1 file changed, 100 insertions(+), 34 deletions(-)
>
> Hmm. I see what you're trying to do here, and abstract the repeated
> bits. But I'm not sure the line-count reflects a real simplification.
> Everything ends up converted to an enum, and then that enum just expands
> to similar C code.

It's not simplification, but hopefully for better maintainability. This

if (strcmp(arg, "--remotes")) {
   if (preceded_by_exclide())
      does_something();
   else if (preceded_by_decorate())
      does_another()
} else if (strcmp(arg, "--branches")) {
   if (preceded_by_exclide())
      does_something();
   else if (preceded_by_decorate())
      does_another()
}

starts to look ugly especially when the third "preceded_by_" comes
into picture. Putting all "does_something" in one group and
"does_another" in another, I think, gives us a better view how ref
selection is handled for a specific operation like --exclude or
--decorate-ref.

> I kind of expected that clear_ref_exclusion() would just become a more
> abstract clear_ref_selection(). For now it would clear exclusions, and
> then later learn to clear the decoration flags.

It may go that way, depending on how we handle these options for
decorate-reflog. The current load_ref_decorations() is not really
suited for fine-grained ref selection yet.
--
Duy

  reply	other threads:[~2017-01-26  9:18 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 [this message]
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
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='CACsJy8CeUWD9ux3Q-VRhwR4-qbSD69CzH2mmztVH_-cx=31h8w@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.keller@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).