From: Duy Nguyen <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>, Jeff King <peff@peff.net>,
Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCH 2/5] revision.c: group ref selection options together
Date: Thu, 26 Jan 2017 16:12:11 +0700 [thread overview]
Message-ID: <CACsJy8Dwr5g6ZvemYgfg7Lecu=PsWz734tWgfFDCkWB_Htg7Hg@mail.gmail.com> (raw)
In-Reply-To: <xmqqo9yualqn.fsf@gitster.mtv.corp.google.com>
On Thu, Jan 26, 2017 at 4:11 AM, Junio C Hamano <gitster@pobox.com> wrote:
> * I am expecting that the new one yet to be introduced will not
> share the huge "switch (selector)" part, but does its own things
> in a separate function with a similar structure. The only thing
> common between these two functions would be the structure
> (i.e. it has a big "switch(selector)" that does different things
> depending on REF_SELECT_*) and a call to clear_* function.
Yep. The "new one" is demonstrated in 5/5.
> If we were to add a new kind of REF_SELECT_* (say
> REF_SELECT_NOTES just for the sake of being concrete), what
> changes will be needed to the code if the addition of "use reflog
> from this class of refs for decoration" feature was done with or
> without this step? I have a suspicion that the change will be
> simpler without this step.
The switch/case is to deal with new REF_SELECT_* (at least it's how I
imagine it). What I was worried about was, when a user adds
--select-notes, they may not be aware that it's in the same
all/branches/tags/remotes group that's supposed to work with
--decorate-reflog as well, and as a result "--decorate-reflog
--select-notes" is the same as "--select-notes".
With the switch/case, when you add a new enum item, at the least the
compiler should warn about unhandled cases. And we can have a new
"case REF_SELECT_NOTES:" for both --exclude and --decorate-reflog.
Without the switch/case, I guess it's still possible to do something
like
if (!strcmp(arg, "--select-notes")) {
if (preceded_by_exclude())
does_one_thing();
else if (preceded_by_decorate_reflog())
does_another_thing();
}
It's probably easier to maintain though, if all
decorate-reflog-related things are grouped together, rather than
spread out per option like the above.
--
Duy
next prev parent reply other threads:[~2017-01-26 9:12 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 [this message]
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='CACsJy8Dwr5g6ZvemYgfg7Lecu=PsWz734tWgfFDCkWB_Htg7Hg@mail.gmail.com' \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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).