Skip to content

Commit c714d05

Browse files
rscharfegitster
authored andcommitted
blame: silently ignore invalid ignore file objects
Since 610e2b9 (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 <[email protected]> Signed-off-by: René Scharfe <[email protected]> Reviewed-by: Barret Rhoden <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 610e2b9 commit c714d05

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

oidset.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ void oidset_parse_file_carefully(struct oidset *set, const char *path,
7272
if (!sb.len)
7373
continue;
7474

75-
if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0' ||
76-
(fn && fn(&oid, cbdata)))
75+
if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
7776
die("invalid object name: %s", sb.buf);
77+
if (fn && fn(&oid, cbdata))
78+
continue;
7879
oidset_insert(set, &oid);
7980
}
8081
if (ferror(fp))

t/t8013-blame-ignore-revs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ test_expect_success 'validate --ignore-rev' '
3939
test_must_fail git blame --ignore-rev X^{tree} file
4040
'
4141

42-
# Ensure bogus --ignore-revs-file requests are caught
42+
# Ensure bogus --ignore-revs-file requests are silently accepted
4343
test_expect_success 'validate --ignore-revs-file' '
4444
git rev-parse X^{tree} >ignore_x &&
45-
test_must_fail git blame --ignore-revs-file ignore_x file
45+
git blame --ignore-revs-file ignore_x file
4646
'
4747

4848
for I in X XT

0 commit comments

Comments
 (0)