From: "Stefan Beller" <stefanbel...@googlemail.com>
Sent: Thursday, August 08, 2013 7:55 PM
Subject: [PATCH] diff: remove another ternary expression always evaluating to true

Have these issues (and the earlier expression simplifications patches $gmane/231916, $gmane/231912 ) been discovered with the "STACK" tool I'd noted in $gmane/230542 which you were also interested in (I've not had chance to run the tool).

If so, it's probably worth referencing the tool and the paper which explains the broader issues.

Philip


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 <stefanbel...@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

--

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to