git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] diff: remove another ternary expression always evaluating to true
@ 2013-08-08 18:55 Stefan Beller
  2013-08-08 21:01 ` Johannes Schindelin
  2013-08-08 21:36 ` [PATCH] diff: remove another ternary expression always evaluating to true Philip Oakley
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Beller @ 2013-08-08 18:55 UTC (permalink / raw)
  To: Jens.Lehmann, johannes.schindelin, gitster, git; +Cc: Stefan Beller

The condition before the changed line dereferences 'one' to query the mode,
so if the condition evaluates to true, the variable one must not be null.
Therefore we do not need the ternary operator depending on one, giving
either one->path or two->path. This always evaluates to one->path, so
we can remove the ternary operator.

The condition and the usage of the ternary operator have been introduced
by the same commit (752c0c24, 2009-10-19, Add the --submodule option to
the diff option family). As that commit message refers to a GitTogether
I'd assume that patch was crafted in a hurry, so maybe overlooking the
need for a ternary operator there.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
---
 diff.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/diff.c b/diff.c
index 80f8439..f30b7e4 100644
--- a/diff.c
+++ b/diff.c
@@ -2252,8 +2252,7 @@ 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,
+		show_submodule_summary(o->file, one->path, line_prefix,
 				one->sha1, two->sha1, two->dirty_submodule,
 				meta, del, add, reset);
 		return;
-- 
1.8.4.rc1.25.gd121ba2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-08-08 22:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-08 18:55 [PATCH] diff: remove another ternary expression always evaluating to true Stefan Beller
2013-08-08 21:01 ` Johannes Schindelin
2013-08-08 21:22   ` Stefan Beller
2013-08-08 21:36     ` Johannes Schindelin
2013-08-08 22:03       ` Junio C Hamano
2013-08-08 22:11         ` [PATCH] diff: fix a possible null pointer dereference Stefan Beller
2013-08-08 21:36 ` [PATCH] diff: remove another ternary expression always evaluating to true Philip Oakley
2013-08-08 22:17   ` Stefan Beller

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).