From: Junio C Hamano <gitster@pobox•com>
To: Jeremiah Mahler <jmmahler@gmail•com>
Cc: Jeff King <peff@peff•net>, git@vger•kernel.org
Subject: Re: [PATCH v2] format-patch --signature-file <file>
Date: Mon, 19 May 2014 09:54:33 -0700 [thread overview]
Message-ID: <xmqqd2f93e0m.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20140517153943.GB31912@hudson.localdomain> (Jeremiah Mahler's message of "Sat, 17 May 2014 08:39:43 -0700")
Jeremiah Mahler <jmmahler@gmail•com> writes:
> On Sat, May 17, 2014 at 06:00:14AM -0400, Jeff King wrote:
>>
>> If you wanted to know whether it was set, I guess you'd have to compare
>> it to the default, like:
>>
>> if (signature_file) {
>> if (signature && signature != git_version_string)
>> die("you cannot specify both a signature and a signature-file");
>> ... read signature file ...
>> }
>>
>
> That works until someone changes the default value.
> But if they did that then some tests should fail.
>
> I like the address comparision which avoids a string comparision.
Well, "avoids" is not quite a correct phrasing, because !strcmp()
would be wrong there. You cannot tell "the user did not set
anything and the variable stayed as the default" and "the user
explicitly gave us a string but it happened to be the same as the
default" apart with !strcmp(). Address comparison is not just
"avoids" but is the right thing to do in this case.
>> though it's a bit ugly that this code has to know what the default is.
Avoiding that is easy with an indirection, no? Something like this
at the top:
static const char *the_default_signature = git_version_string;
static const char *signature = the_default_signature;
and comparing to see if signature points at the same address as
the_default_signature would give you what you want, I think.
next prev parent reply other threads:[~2014-05-19 16:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-16 1:31 [PATCH v2] format-patch --signature-file <file> Jeremiah Mahler
2014-05-16 1:31 ` Jeremiah Mahler
2014-05-16 8:14 ` Jeff King
2014-05-17 7:25 ` Jeremiah Mahler
2014-05-17 7:42 ` Jeff King
2014-05-17 8:59 ` Jeremiah Mahler
2014-05-17 10:00 ` Jeff King
2014-05-17 15:39 ` Jeremiah Mahler
2014-05-19 16:54 ` Junio C Hamano [this message]
2014-05-20 5:46 ` Jeremiah Mahler
2014-05-20 6:21 ` Jeff King
2014-05-20 15:06 ` Junio C Hamano
2014-05-21 0:45 ` Jeremiah Mahler
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=xmqqd2f93e0m.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=jmmahler@gmail$(echo .)com \
--cc=peff@peff$(echo .)net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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