diff --git a/builtin/blame.c b/builtin/blame.c index 1eddabaf60f4ea..956520edcd9a13 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -69,6 +69,7 @@ static int coloring_mode; static struct string_list ignore_revs_file_list = STRING_LIST_INIT_DUP; static int mark_unblamable_lines; static int mark_ignored_lines; +static int override_ignore_revs = 0; static struct date_mode blame_date_mode = { DATE_ISO8601 }; static size_t blame_date_width; @@ -901,6 +902,7 @@ int cmd_blame(int argc, OPT_BIT('w', NULL, &xdl_opts, N_("ignore whitespace differences"), XDF_IGNORE_WHITESPACE), OPT_STRING_LIST(0, "ignore-rev", &ignore_rev_list, N_("rev"), N_("ignore when blaming")), OPT_STRING_LIST(0, "ignore-revs-file", &ignore_revs_file_list, N_("file"), N_("ignore revisions from ")), + OPT_BOOL('O', "override-ignore-revs", &override_ignore_revs, N_("override all configurations that exclude revisions")), OPT_BIT(0, "color-lines", &output_option, N_("color redundant metadata from previous line differently"), OUTPUT_COLOR_LINE), OPT_BIT(0, "color-by-age", &output_option, N_("color lines by age"), OUTPUT_SHOW_AGE_WITH_COLOR), OPT_BIT(0, "minimal", &xdl_opts, N_("spend extra cycles to find better match"), XDF_NEED_MINIMAL), @@ -1119,7 +1121,11 @@ int cmd_blame(int argc, sb.reverse = reverse; sb.repo = the_repository; sb.path = path; - build_ignorelist(&sb, &ignore_revs_file_list, &ignore_rev_list); + + if (!override_ignore_revs) { + build_ignorelist(&sb, &ignore_revs_file_list, &ignore_rev_list); + } + string_list_clear(&ignore_revs_file_list, 0); string_list_clear(&ignore_rev_list, 0); setup_scoreboard(&sb, &o); diff --git a/t/t8016-blame-override-ignore-revs.sh b/t/t8016-blame-override-ignore-revs.sh new file mode 100755 index 00000000000000..b5899729f8e08d --- /dev/null +++ b/t/t8016-blame-override-ignore-revs.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +test_description='default revisions to ignore when blaming' + +TEST_PASSES_SANITIZE_LEAK=true +. ./test-lib.sh + +test_expect_success 'blame: override-ignore-revs' ' + test_commit first-commit hello.txt hello && + + echo world >>hello.txt && + test_commit second-commit hello.txt && + + sed "1s/hello/hi/" hello.txt.tmp && + mv hello.txt.tmp hello.txt && + test_commit third-commit hello.txt && + + git blame hello.txt >expect && + git rev-parse HEAD >.git-blame-ignore-revs && + git blame -O hello.txt >actual && + + test_cmp expect actual +' + +test_done