Commit d9f62dfa authored by Jeff King's avatar Jeff King Committed by Junio C Hamano

show_dirstat: simplify same-content check

We use two nested conditionals to store a content_changed
variable, but only bother to look at the result once,
directly after we set it. We can drop the variable entirely
and just use a single "if".

This needless complexity is the result of 2ff3a803 (Teach
--dirstat not to completely ignore rearranged lines within a
file, 2011-04-11). Before that, we held onto the
content_changed variable much longer.

While we're touching the condition, we can swap out oidcmp()
for !oideq(). Our coccinelle patches didn't previously find
this case because of the intermediate variable, but now it's
a simple boolean in a conditional.
Signed-off-by: default avatarJeff King <[email protected]>
Signed-off-by: default avatarJunio C Hamano <[email protected]>
parent 6a29d7b7
......@@ -2933,16 +2933,11 @@ static void show_dirstat(struct diff_options *options)
struct diff_filepair *p = q->queue[i];
const char *name;
unsigned long copied, added, damage;
int content_changed;
name = p->two->path ? p->two->path : p->one->path;
if (p->one->oid_valid && p->two->oid_valid)
content_changed = oidcmp(&p->one->oid, &p->two->oid);
else
content_changed = 1;
if (!content_changed) {
if (p->one->oid_valid && p->two->oid_valid &&
oideq(&p->one->oid, &p->two->oid)) {
/*
* The SHA1 has not changed, so pre-/post-content is
* identical. We can therefore skip looking at the
......@@ -2989,7 +2984,7 @@ static void show_dirstat(struct diff_options *options)
* made to the preimage.
* If the resulting damage is zero, we know that
* diffcore_count_changes() considers the two entries to
* be identical, but since content_changed is true, we
* be identical, but since the oid changed, we
* know that there must have been _some_ kind of change,
* so we force all entries to have damage > 0.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment