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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux