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

3 messages from 2025-07-03 to 2025-07-03. Participants: Francesco Nicoletta Puzzillo, Kristoffer Haugsbakk, Ben Knoble.
Thread: https://gitlist.dev/t/63734

## Francesco Nicoletta Puzzillo, 2025-07-03 08:18

Subject: [RFC PATCH] blame: avoid failing if ignoreRevsFile does not exist
Message-ID: <20250703081838.190603-1-francesco.nicolettap@amarulasolutions.com>
URL: https://gitlist.dev/e/20250703081838.190603-1-francesco.nicolettap%40amarulasolutions.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


```

## Kristoffer Haugsbakk, 2025-07-03 08:25

Subject: Re: [RFC PATCH] blame: avoid failing if ignoreRevsFile does not exist
Message-ID: <099c2a59-ac60-474b-a535-ec7dcb1f44f8@app.fastmail.com>
URL: https://gitlist.dev/e/099c2a59-ac60-474b-a535-ec7dcb1f44f8%40app.fastmail.com
In-Reply-To: <20250703081838.190603-1-francesco.nicolettap@amarulasolutions.com>

```
On Thu, Jul 3, 2025, at 10:18, Francesco Nicoletta Puzzillo wrote:
> 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>

Relevant thread

https://lore.kernel.org/git/20210807202752.1278672-1-noah.pendleton@gmail.com/

```

## Ben Knoble, 2025-07-03 13:18

Subject: Re: [RFC PATCH] blame: avoid failing if ignoreRevsFile does not exist
Message-ID: <93842D18-3051-4169-B314-AD5A1407575D@gmail.com>
URL: https://gitlist.dev/e/93842D18-3051-4169-B314-AD5A1407575D%40gmail.com
In-Reply-To: <099c2a59-ac60-474b-a535-ec7dcb1f44f8@app.fastmail.com>

```

> Le 3 juil. 2025 à 04:26, Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> a écrit :
> 
> ﻿On Thu, Jul 3, 2025, at 10:18, Francesco Nicoletta Puzzillo wrote:
>> 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>
> 
> Relevant thread
> 
> https://lore.kernel.org/git/20210807202752.1278672-1-noah.pendleton@gmail.com/
> 

Indeed. IIRC there was some polish to do on Junio’s patches, which I intend to get to unless someone beats me to it ;)
```
