Skip to content

Commit 2435fea

Browse files
committed
Merge branch 'mt/cleanly-die-upon-missing-required-filter'
We had a code to diagnose and die cleanly when a required clean/smudge filter is missing, but an assert before that unnecessarily fired, hiding the end-user facing die() message. * mt/cleanly-die-upon-missing-required-filter: convert: fail gracefully upon missing clean cmd on required filter
2 parents 204333b + 6fab35f commit 2435fea

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

convert.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,6 @@ void convert_to_git_filter_fd(const struct index_state *istate,
14561456
convert_attrs(istate, &ca, path);
14571457

14581458
assert(ca.drv);
1459-
assert(ca.drv->clean || ca.drv->process);
14601459

14611460
if (!apply_filter(path, NULL, 0, fd, dst, ca.drv, CAP_CLEAN, NULL, NULL))
14621461
die(_("%s: clean filter '%s' failed"), path, ca.drv->name);

t/t0021-conversion.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,30 @@ test_expect_success 'required filter clean failure' '
257257
test_must_fail git add test.fc
258258
'
259259

260+
test_expect_success 'required filter with absent clean field' '
261+
test_config filter.absentclean.smudge cat &&
262+
test_config filter.absentclean.required true &&
263+
264+
echo "*.ac filter=absentclean" >.gitattributes &&
265+
266+
echo test >test.ac &&
267+
test_must_fail git add test.ac 2>stderr &&
268+
test_i18ngrep "fatal: test.ac: clean filter .absentclean. failed" stderr
269+
'
270+
271+
test_expect_success 'required filter with absent smudge field' '
272+
test_config filter.absentsmudge.clean cat &&
273+
test_config filter.absentsmudge.required true &&
274+
275+
echo "*.as filter=absentsmudge" >.gitattributes &&
276+
277+
echo test >test.as &&
278+
git add test.as &&
279+
rm -f test.as &&
280+
test_must_fail git checkout -- test.as 2>stderr &&
281+
test_i18ngrep "fatal: test.as: smudge filter absentsmudge failed" stderr
282+
'
283+
260284
test_expect_success 'filtering large input to small output should use little memory' '
261285
test_config filter.devnull.clean "cat >/dev/null" &&
262286
test_config filter.devnull.required true &&

0 commit comments

Comments
 (0)