]> git.ipfire.org Git - thirdparty/git.git/commitdiff
archive-tar: report filter start error only once
authorRené Scharfe <l.s.r@web.de>
Sat, 29 Oct 2022 10:06:06 +0000 (12:06 +0200)
committerTaylor Blau <me@ttaylorr.com>
Sun, 30 Oct 2022 23:50:43 +0000 (19:50 -0400)
A missing tar filter is reported by start_command() using error(), but
also by its caller, write_tar_filter_archive(), using die():

   $ git -c tar.invalid.command=foo archive --format=invalid HEAD
   error: cannot run foo: No such file or directory
   fatal: unable to start 'foo' filter: No such file or directory

The second message contains all relevant information and even says that
the failed command was intended to be used as a filter.  Silence the
first one because it's redundant.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
archive-tar.c
t/t5000-tar-tree.sh

index 3e4822b68409b85d36436bd42da862991274cd81..f8fad2946ef97324756b78363fb90d329f504209 100644 (file)
@@ -498,6 +498,7 @@ static int write_tar_filter_archive(const struct archiver *ar,
        strvec_push(&filter.args, cmd.buf);
        filter.use_shell = 1;
        filter.in = -1;
+       filter.silent_exec_failure = 1;
 
        if (start_command(&filter) < 0)
                die_errno(_("unable to start '%s' filter"), cmd.buf);
index eaa0b22ece4ff3ce7d79faed2edf8ab829c97051..d473048138466322e505f4b3b249e89f19101b0b 100755 (executable)
@@ -342,6 +342,13 @@ test_expect_success 'only enabled filters are available remotely' '
        test_cmp_bin remote.bar config.bar
 '
 
+test_expect_success 'invalid filter is reported only once' '
+       test_must_fail git -c tar.invalid.command= archive --format=invalid \
+               HEAD >out 2>err &&
+       test_must_be_empty out &&
+       test_line_count = 1 err
+'
+
 test_expect_success 'git archive --format=tgz' '
        git archive --format=tgz HEAD >j.tgz
 '