From: Eric Sunshine <sunshine@sunshineco.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Quentin Neill <quentin.neill@gmail.com>, Git List <git@vger.kernel.org>
Subject: Re: [PATCH] blame: add blame.showemail config option
Date: Mon, 27 Apr 2015 15:23:25 -0400 [thread overview]
Message-ID: <CAPig+cRTfB9aiinhSJp=jY7-__6dRvfAqhWZYVN3+Ut=Y79LcQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqwq0xwige.fsf@gitster.dls.corp.google.com>
On Mon, Apr 27, 2015 at 2:10 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Quentin Neill <quentin.neill@gmail.com> writes:
>> Eric Sunshine <sunshine@sunshineco.com> writes:
>>> Quentin Neill <quentin.neill@gmail.com> writes:
>>>> - if (opt & OUTPUT_SHOW_EMAIL)
>>>> + if ((opt & OUTPUT_SHOW_EMAIL) || show_email)
>>>
>>> The desired behavior is for a configuration setting to provide a
>>> fallback, and for a command-line option to override the fallback. So,
>>> for instance, if blame.showemail is "true", then --no-show-email
>>> should countermand that. Unfortunately, the way this patch is
>>> implemented, it's impossible to override the setting from the
>>> command-line since show_email==true will always win (when
>>> blame.showemail is "true").
>>>
>> I followed the code for blame.showRoot and blame.blankboundary.
>
> If you truly followed this code pattern, I would expect that there
> will not be a separate show_email variable introduced to support
> this new configuration variable. The OUTPUT_SHOW_EMAIL bit in the
> opt flag word corresponds to show_root and blank_boundary variables,
> so the code to read configuration variable would set that bit in the
> opt flag word before the command line parser would kick in. And the
> code that checks "opt & OUTPUT_SHOW_EMAIL" currently does not have
> to change at all.
Right. Rather than having a separate global 'show_email' variable and
consulting that variable in parallel with OUTPUT_SHOW_EMAIL throughout
the code, instead set the OUTPUT_SHOW_EMAIL bit in git_blame_config().
To do this, take advantage of the "callback data" argument of
git_config(), which will arrive in git_blame_config() as its 'void
*cb' argument. So, for instance, something like this:
static int git_blame_config(var, value, void *cb)
{
...
if (!strcmp(var, "blame.showemail")) {
if (git_config_bool(var, value)) {
int *output_options = cb;
*output_options |= OUTPUT_SHOW_EMAIL;
}
return 0;
}
...
}
int cmd_blame(...)
{
...
git_config(git_blame_config, &output_options);
...
parse_options(...);
...
}
next prev parent reply other threads:[~2015-04-27 19:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-24 2:13 [PATCH] blame: add blame.showemail config option Quentin Neill
2015-04-24 5:22 ` Eric Sunshine
2015-04-27 13:46 ` Quentin Neill
2015-04-27 18:10 ` Junio C Hamano
2015-04-27 19:23 ` Eric Sunshine [this message]
2015-04-28 7:08 ` Junio C Hamano
2015-04-30 14:03 ` Quentin Neill
2015-04-30 16:10 ` Junio C Hamano
2015-04-30 21:33 ` Eric Sunshine
2015-04-30 21:43 ` Junio C Hamano
2015-04-27 19:57 ` Eric Sunshine
2015-05-29 19:40 ` Junio C Hamano
2015-05-30 20:31 ` Quentin Neill
2015-05-30 21:38 ` [PATCH v2] blame: add blame.showEmail configuration Quentin Neill
2015-05-31 18:13 ` Junio C Hamano
2015-05-31 19:24 ` Quentin Neill
2015-05-31 19:27 ` [PATCH v3] " Quentin Neill
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='CAPig+cRTfB9aiinhSJp=jY7-__6dRvfAqhWZYVN3+Ut=Y79LcQ@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=quentin.neill@gmail.com \
/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 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 NNTP newsgroup(s).