aboutsummaryrefslogtreecommitdiff
path: root/builtin/blame.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-21 13:52:25 -0700
committerJunio C Hamano <gitster@pobox.com>2012-09-21 13:52:25 -0700
commit3d1aa56671e7f33740dcd2cf0642d5ce09bd6a95 (patch)
tree47812eabc3ec1c53def5bb11aba989258adfeed7 /builtin/blame.c
parentaebbcf57972961c221c75dee039a17be8cfae1ad (diff)
downloadgit-3d1aa56671e7f33740dcd2cf0642d5ce09bd6a95.tar.gz
git-3d1aa56671e7f33740dcd2cf0642d5ce09bd6a95.tar.xz
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>
Diffstat (limited to 'builtin/blame.c')
-rw-r--r--builtin/blame.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index cad4111a3..bfa6086b0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -42,6 +42,7 @@ static int blank_boundary;
static int incremental;
static int xdl_opts;
static int abbrev = -1;
+static int no_whole_file_rename;
static enum date_mode blame_date_mode = DATE_ISO8601;
static size_t blame_date_width;
@@ -1226,7 +1227,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
* The first pass looks for unrenamed path to optimize for
* common cases, then we look for renames in the second pass.
*/
- for (pass = 0; pass < 2; pass++) {
+ for (pass = 0; pass < 2 - no_whole_file_rename; pass++) {
struct origin *(*find)(struct scoreboard *,
struct commit *, struct origin *);
find = pass ? find_rename : find_origin;
@@ -2344,6 +2345,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
init_revisions(&revs, NULL);
revs.date_mode = blame_date_mode;
DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
+ DIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);
save_commit_buffer = 0;
dashdash_pos = 0;
@@ -2367,6 +2369,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
}
parse_done:
+ no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
+ DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
argc = parse_options_end(&ctx);
if (0 < abbrev)