Skip to content

Commit b7bb760

Browse files
torvaldsgitster
authored andcommitted
Fix revision log diff setup, avoid unnecessary diff generation
We used to incorrectly start calculating diffs whenever any argument but '-z' was recognized by the diff options parsing. That was bogus, since not all arguments result in diffs being needed, so we just waste a lot of time and effort on calculating diffs that don't matter. This actually also fixes another bug in "git log". Try this: git log -C and notice how it prints an extra empty line in between log entries, even though it never prints the actual diff (because we didn't ask for any diff format, so the diff machinery never prints anything). With this patch, that bogus empty line is gone, because "revs->diff" is never set. So this isn't just a "wasted time and effort" issue, it's also a slight semantic fix. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent ee8245b commit b7bb760

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

revision.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,8 +1209,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
12091209

12101210
opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
12111211
if (opts > 0) {
1212-
if (strcmp(argv[i], "-z"))
1213-
revs->diff = 1;
12141212
i += opts - 1;
12151213
continue;
12161214
}
@@ -1254,6 +1252,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
12541252
add_pending_object_with_mode(revs, object, def, mode);
12551253
}
12561254

1255+
/* Did the user ask for any diff output? Run the diff! */
1256+
if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
1257+
revs->diff = 1;
1258+
1259+
/* Pickaxe needs diffs */
1260+
if (revs->diffopt.pickaxe)
1261+
revs->diff = 1;
1262+
12571263
if (revs->topo_order)
12581264
revs->limited = 1;
12591265

0 commit comments

Comments
 (0)