]> git.ipfire.org Git - thirdparty/git.git/commitdiff
blame: silently ignore invalid ignore file objects
authorRené Scharfe <l.s.r@web.de>
Tue, 10 Nov 2020 11:38:27 +0000 (12:38 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Nov 2020 21:05:06 +0000 (13:05 -0800)
Since 610e2b9240 (blame: validate and peel the object names on the
ignore list, 2020-09-24) git blame reports checks if objects specified
with --ignore-rev and in files loaded with --ignore-revs-file and config
option blame.ignoreRevsFile are actual objects and dies if they aren't.
The intent is to report typos to the user.

This also breaks the ability to use a single ignore file for multiple
repositories.  Typos are presumably less likely in files than on the
command line, so alerting is less useful here.  Restore that feature by
skipping non-commits without dying.

Reported-by: Jean-Yves Avenard <jyavenard@mozilla.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Barret Rhoden <brho@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
oidset.c
t/t8013-blame-ignore-revs.sh

index 2d0ab76fb569be21dacc68e66098a4814191325b..5aac633c1f405580447001dfae114660e6120e90 100644 (file)
--- a/oidset.c
+++ b/oidset.c
@@ -72,9 +72,10 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path,
                if (!sb.len)
                        continue;
 
-               if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0' ||
-                   (fn && fn(&oid, cbdata)))
+               if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
                        die("invalid object name: %s", sb.buf);
+               if (fn && fn(&oid, cbdata))
+                       continue;
                oidset_insert(set, &oid);
        }
        if (ferror(fp))
index 24ae5018e8850d065da1ce0c6c33d81533ce0240..b18633dee1bfb2339033f1d0ab708979e98da018 100755 (executable)
@@ -39,10 +39,10 @@ test_expect_success 'validate --ignore-rev' '
        test_must_fail git blame --ignore-rev X^{tree} file
 '
 
-# Ensure bogus --ignore-revs-file requests are caught
+# Ensure bogus --ignore-revs-file requests are silently accepted
 test_expect_success 'validate --ignore-revs-file' '
        git rev-parse X^{tree} >ignore_x &&
-       test_must_fail git blame --ignore-revs-file ignore_x file
+       git blame --ignore-revs-file ignore_x file
 '
 
 for I in X XT