{"thread":{"id":"56235","subject":"[PATCH 0/1] blame: Skip missing ignore-revs file","startedAt":"2021-08-07T20:29:18Z","lastAt":"2021-08-07T20:29:30Z","messageCount":2,"participants":["Noah Pendleton"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"432256","messageId":"20210807202902.1279624-1-noah.pendleton@gmail.com","threadId":"56235","inReplyTo":null,"subject":"[PATCH 0/1] blame: Skip missing ignore-revs file","fromName":"Noah Pendleton","fromEmail":"noah.pendleton@gmail.com","sentAt":"2021-08-07T20:29:01Z","receivedAt":"2021-08-07T20:29:18Z","isPatch":true,"sender":{"key":"noah.pendleton@gmail.com","avatar":"https://gravatar.com/avatar/254bdb2e93ea199f3615ec3880e1a1cee7664e079a0dce9bec08a38ce7e882ba?d=mp&s=160"},"body":"Setting a global `blame.ignoreRevsFile` can be convenient, since I\nusually use `.git-blame-ignore-revs` in repos. If the file is missing,\nthough, `git blame` exits with failure. This patch changes it to skip\nover non-existent ignore-rev files instead of erroring.\n\n\nNoah Pendleton (1):\n  blame: skip missing ignore-revs-file's\n\n Documentation/blame-options.txt |  2 +-\n Documentation/config/blame.txt  |  3 ++-\n builtin/blame.c                 |  2 +-\n t/t8013-blame-ignore-revs.sh    | 10 ++++++----\n 4 files changed, 10 insertions(+), 7 deletions(-)\n\n-- \n2.32.0\n\n"},{"id":"432257","messageId":"20210807202902.1279624-2-noah.pendleton@gmail.com","threadId":"56235","inReplyTo":"20210807202902.1279624-1-noah.pendleton@gmail.com","subject":"[PATCH 1/1] blame: skip missing ignore-revs-file's","fromName":"Noah Pendleton","fromEmail":"noah.pendleton@gmail.com","sentAt":"2021-08-07T20:29:02Z","receivedAt":"2021-08-07T20:29:30Z","isPatch":true,"sender":{"key":"noah.pendleton@gmail.com","avatar":"https://gravatar.com/avatar/254bdb2e93ea199f3615ec3880e1a1cee7664e079a0dce9bec08a38ce7e882ba?d=mp&s=160"},"body":"Setting the config option `blame.ignoreRevsFile` globally to eg\n`.git-blame-ignore-revs` causes `git blame` to error when the file\ndoesn't exist in the current repository:\n\n```\nfatal: could not open object name list: .git-blame-ignore-revs\n```\n\nInstead, just skip over ignore-rev files that don't exist.\n\nSigned-off-by: Noah Pendleton <noah.pendleton@gmail.com>\n---\n Documentation/blame-options.txt |  2 +-\n Documentation/config/blame.txt  |  3 ++-\n builtin/blame.c                 |  2 +-\n t/t8013-blame-ignore-revs.sh    | 10 ++++++----\n 4 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt\nindex 117f4cf806..2a8f54cc9c 100644\n--- a/Documentation/blame-options.txt\n+++ b/Documentation/blame-options.txt\n@@ -134,7 +134,7 @@ take effect.\n \t`fsck.skipList`.  This option may be repeated, and these files will be\n \tprocessed after any files specified with the `blame.ignoreRevsFile` config\n \toption.  An empty file name, `\"\"`, will clear the list of revs from\n-\tpreviously processed files.\n+\tpreviously processed files. Any files that do not exist will be skipped.\n \n -h::\n \tShow help message.\ndiff --git a/Documentation/config/blame.txt b/Documentation/config/blame.txt\nindex 4d047c1790..f7f49a4ac2 100644\n--- a/Documentation/config/blame.txt\n+++ b/Documentation/config/blame.txt\n@@ -25,7 +25,8 @@ blame.ignoreRevsFile::\n \tline, in linkgit:git-blame[1].  Whitespace and comments beginning with\n \t`#` are ignored.  This option may be repeated multiple times.  Empty\n \tfile names will reset the list of ignored revisions.  This option will\n-\tbe handled before the command line option `--ignore-revs-file`.\n+\tbe handled before the command line option `--ignore-revs-file`. If the\n+\tspecified file does not exist it will be skipped.\n \n blame.markUnblamableLines::\n \tMark lines that were changed by an ignored revision that we could not\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 641523ff9a..e5b45eddf4 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -835,7 +835,7 @@ static void build_ignorelist(struct blame_scoreboard *sb,\n \tfor_each_string_list_item(i, ignore_revs_file_list) {\n \t\tif (!strcmp(i->string, \"\"))\n \t\t\toidset_clear(&sb->ignore_list);\n-\t\telse\n+\t\telse if (file_exists(i->string))\n \t\t\toidset_parse_file_carefully(&sb->ignore_list, i->string,\n \t\t\t\t\t\t    peel_to_commit_oid, sb);\n \t}\ndiff --git a/t/t8013-blame-ignore-revs.sh b/t/t8013-blame-ignore-revs.sh\nindex b18633dee1..56956adb14 100755\n--- a/t/t8013-blame-ignore-revs.sh\n+++ b/t/t8013-blame-ignore-revs.sh\n@@ -127,18 +127,20 @@ test_expect_success override_ignore_revs_file '\n \tgrep -E \"^[0-9a-f]+ [0-9]+ 2\" blame_raw | sed -e \"s/ .*//\" >actual &&\n \ttest_cmp expect actual\n \t'\n-test_expect_success bad_files_and_revs '\n+test_expect_success bad_revs '\n \ttest_must_fail git blame file --ignore-rev NOREV 2>err &&\n \ttest_i18ngrep \"cannot find revision NOREV to ignore\" err &&\n \n-\ttest_must_fail git blame file --ignore-revs-file NOFILE 2>err &&\n-\ttest_i18ngrep \"could not open.*: NOFILE\" err &&\n-\n \techo NOREV >ignore_norev &&\n \ttest_must_fail git blame file --ignore-revs-file ignore_norev 2>err &&\n \ttest_i18ngrep \"invalid object name: NOREV\" err\n '\n \n+# Non-existent ignore-revs-file should be ignored.\n+test_expect_success bad_file '\n+\tgit blame file --ignore-revs-file NOFILE\n+'\n+\n # For ignored revs that have added 'unblamable' lines, mark those lines with a\n # '*'\n # \tA--B--X--Y\n-- \n2.32.0\n\n"}]}