@matheusbsbs / matheus-bagliano / commits / b7bb760d5e
Fork 0

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>

Linus Torvalds committed Sep 29, 2007 at 09:50 UTC b7bb760d5ed4881422673d32f869d140221d3564
1 file changed +8 -2
revision.c
+8 -2
@@ -1209,8 +1209,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1209
1210 opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i);
1211 if (opts > 0) {
1212 - if (strcmp(argv[i], "-z"))
1213 - revs->diff = 1;
1212 i += opts - 1;
1213 continue;
1214 }
@@ -1254,6 +1252,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
1252 add_pending_object_with_mode(revs, object, def, mode);
1253 }
1254
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 +
1263 if (revs->topo_order)
1264 revs->limited = 1;
1265