From: Stefan Beller <stefanbeller@googlemail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH] diff: remove ternary operator evaluating always to true
Date: Mon, 12 Aug 2013 10:38:58 +0200 [thread overview]
Message-ID: <52089F22.6010106@googlemail.com> (raw)
In-Reply-To: <52089D81.5010506@googlemail.com>
[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]
On 08/12/2013 10:32 AM, Stefan Beller wrote:
>
> diff --git a/diff.c b/diff.c
> index e53ddad..de21971 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -2254,8 +2254,11 @@ static void builtin_diff(const char *name_a,
> (!two->mode || S_ISGITLINK(two->mode))) {
> const char *del = diff_get_color_opt(o, DIFF_FILE_OLD);
> const char *add = diff_get_color_opt(o, DIFF_FILE_NEW);
> - show_submodule_summary(o->file, one ? one->path : two->path,
> - line_prefix,
> + struct diff_filespec *spec = one && DIFF_FILE_VALID(one) ? one : two;
> + if (!spec && !DIFF_FILE_VALID(spec))
> + die("BUG: two invalid diff_filespec structs in diff");
> +
> + show_submodule_summary(o->file, spec->path, line_prefix,
> one->sha1, two->sha1, two->dirty_submodule,
> meta, del, add, reset);
> return;
This doesn't make sense, as we're definitely dereferencing both
one and two with ->sha1, so we do not need the "one &&" and the
"!spec &&".
I think the originally sent patches are correct, but the commit
message may need rewriting to comply with Jeffs nitpicking.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 899 bytes --]
next prev parent reply other threads:[~2013-08-12 8:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-08 18:31 [PATCH] diff: remove ternary operator evaluating always to true Stefan Beller
2013-08-10 7:21 ` Jeff King
2013-08-12 5:46 ` Junio C Hamano
2013-08-12 8:32 ` Stefan Beller
2013-08-12 8:38 ` Stefan Beller [this message]
2013-08-12 17:15 ` Junio C Hamano
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=52089F22.6010106@googlemail.com \
--to=stefanbeller@googlemail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).