git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH] blame: avoid failing if ignoreRevsFile does not exist

From
FPFrancesco Nicoletta Puzzillo <francesco.nicolettap@amarulasolutions.com>
Date
Jul 3, 2025, 08:18 UTC
Message-ID
<20250703081838.190603-1-francesco.nicolettap@amarulasolutions.com>

Setting ignoreRevsFile globally makes the blame command fail in repositories that don't have the file present.

Check that the file exists before trying to parse it.
Signed-off-by: Francesco Nicoletta Puzzillo <francesco.nicolettap@amarulasolutions.com>
---
 builtin/blame.c  | 3 ++-
 t/t8002-blame.sh | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 944952e30e..e4236f0ebc 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -868,12 +868,13 @@ static void build_ignorelist(struct blame_scoreboard *sb,
 {
 	struct string_list_item *i;
 	struct object_id oid;
+	struct stat st;
 
 	oidset_init(&sb->ignore_list, 0);
 	for_each_string_list_item(i, ignore_revs_file_list) {
 		if (!strcmp(i->string, ""))
 			oidset_clear(&sb->ignore_list);
-		else
+		else if (!stat(i->string, &st))
 			oidset_parse_file_carefully(&sb->ignore_list, i->string,
 						    the_repository->hash_algo,
 						    peel_to_commit_oid, sb);
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
index 7822947f02..24010f544c 100755
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
@@ -173,4 +173,10 @@ test_expect_success 'blame with uncommitted edits in partial clone does not cras
 	git -C client blame file.txt
 '
 
+test_expect_success 'blame with ignoreRevsFile set but not present does not fail' '
+	test_commit A file line1 &&
+	git config --global blame.ignoreRevsFile .git-blame-ignore-revs &&
+	git blame file
+'
+
 test_done

base-commit: 8b6f19ccfc3aefbd0f22f6b7d56ad6a3fc5e4f37
-- 
2.43.0
Next: Kristoffer Haugsbakk
Message 1 of 3 in “blame: avoid failing if ignoreRevsFile does not exist”
  1. blame: avoid failing if ignoreRevsFile does not existFrancesco Nicoletta Puzzillo, Jul 3, 2025
  2. Kristoffer HaugsbakkJul 3, 2025
  3. Ben KnobleJul 3, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.