blame: pay attention to --no-follow

If you know your history did not have renames, or if you care only about the history after a large rename that happened some time ago, "git blame --no-follow $path" is a way to tell the command not to bother about renames. When you use -C, the lines that came from the renamed file will still be found without the whole-file rename detection, so it is not all that interesting either way, though. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 21, 2012 at 13:52 UTC 3d1aa56671e7f33740dcd2cf0642d5ce09bd6a95
1 file changed +5 -1
builtin/blame.c
+5 -1
@@ -42,6 +42,7 @@ static int blank_boundary;
42 static int incremental;
43 static int xdl_opts;
44 static int abbrev = -1;
45 +static int no_whole_file_rename;
46
47 static enum date_mode blame_date_mode = DATE_ISO8601;
48 static size_t blame_date_width;
@@ -1226,7 +1227,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
1227 * The first pass looks for unrenamed path to optimize for
1228 * common cases, then we look for renames in the second pass.
1229 */
1229 - for (pass = 0; pass < 2; pass++) {
1230 + for (pass = 0; pass < 2 - no_whole_file_rename; pass++) {
1231 struct origin *(*find)(struct scoreboard *,
1232 struct commit *, struct origin *);
1233 find = pass ? find_rename : find_origin;
@@ -2344,6 +2345,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2345 init_revisions(&revs, NULL);
2346 revs.date_mode = blame_date_mode;
2347 DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
2348 + DIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);
2349
2350 save_commit_buffer = 0;
2351 dashdash_pos = 0;
@@ -2367,6 +2369,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2369 parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
2370 }
2371 parse_done:
2372 + no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
2373 + DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
2374 argc = parse_options_end(&ctx);
2375
2376 if (0 < abbrev)