Skip to content

Commit 90d0b8a

Browse files
committed
Merge branch 'jc/blame-no-follow'
Teaches "--no-follow" option to "git blame" to disable its whole-file rename detection. * jc/blame-no-follow: blame: pay attention to --no-follow diff: accept --no-follow option
2 parents 6f3f710 + 3d1aa56 commit 90d0b8a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

builtin/blame.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static int blank_boundary;
4242
static int incremental;
4343
static int xdl_opts;
4444
static int abbrev = -1;
45+
static int no_whole_file_rename;
4546

4647
static enum date_mode blame_date_mode = DATE_ISO8601;
4748
static size_t blame_date_width;
@@ -1226,7 +1227,7 @@ static void pass_blame(struct scoreboard *sb, struct origin *origin, int opt)
12261227
* The first pass looks for unrenamed path to optimize for
12271228
* common cases, then we look for renames in the second pass.
12281229
*/
1229-
for (pass = 0; pass < 2; pass++) {
1230+
for (pass = 0; pass < 2 - no_whole_file_rename; pass++) {
12301231
struct origin *(*find)(struct scoreboard *,
12311232
struct commit *, struct origin *);
12321233
find = pass ? find_rename : find_origin;
@@ -2403,6 +2404,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
24032404
init_revisions(&revs, NULL);
24042405
revs.date_mode = blame_date_mode;
24052406
DIFF_OPT_SET(&revs.diffopt, ALLOW_TEXTCONV);
2407+
DIFF_OPT_SET(&revs.diffopt, FOLLOW_RENAMES);
24062408

24072409
save_commit_buffer = 0;
24082410
dashdash_pos = 0;
@@ -2426,6 +2428,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
24262428
parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
24272429
}
24282430
parse_done:
2431+
no_whole_file_rename = !DIFF_OPT_TST(&revs.diffopt, FOLLOW_RENAMES);
2432+
DIFF_OPT_CLR(&revs.diffopt, FOLLOW_RENAMES);
24292433
argc = parse_options_end(&ctx);
24302434

24312435
if (0 < abbrev)

diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3626,6 +3626,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
36263626
DIFF_OPT_SET(options, FIND_COPIES_HARDER);
36273627
else if (!strcmp(arg, "--follow"))
36283628
DIFF_OPT_SET(options, FOLLOW_RENAMES);
3629+
else if (!strcmp(arg, "--no-follow"))
3630+
DIFF_OPT_CLR(options, FOLLOW_RENAMES);
36293631
else if (!strcmp(arg, "--color"))
36303632
options->use_color = 1;
36313633
else if (!prefixcmp(arg, "--color=")) {

0 commit comments

Comments
 (0)