>From 134662bcecd2f443d9396b03147ea33fb7b6348c Mon Sep 17 00:00:00 2001 From: Marco Nenciarini <[email protected]> Date: Wed, 11 Mar 2026 19:18:26 +0100 Subject: [PATCH] Respect --ignore-failed-read in file_removed_diag (bug#68075)
* src/misc.c (file_removed_diag): Guard set_exit_status call with !ignore_failed_read_option, consistent with stat_diag and other diagnostic functions. * tests/filerem03.at: New test. * tests/testsuite.at: Include it. * tests/Makefile.am: Add it. Copyright-paperwork-exempt: yes Signed-off-by: Marco Nenciarini <[email protected]> --- src/misc.c | 3 ++- tests/Makefile.am | 1 + tests/filerem03.at | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/filerem03.at diff --git a/src/misc.c b/src/misc.c index 02dfbcb4..ee5dcdca 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1445,7 +1445,8 @@ file_removed_diag (const char *name, bool top_level, { warnopt (WARN_FILE_REMOVED, 0, _("%s: File removed before we read it"), quotearg_colon (name)); - set_exit_status (TAREXIT_DIFFERS); + if (!ignore_failed_read_option) + set_exit_status (TAREXIT_DIFFERS); } else diagfn (name); diff --git a/tests/Makefile.am b/tests/Makefile.am index 45d249b3..ae8bd3ff 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -143,6 +143,7 @@ TESTSUITE_AT = \ extrac31.at\ filerem01.at\ filerem02.at\ + filerem03.at\ grow.at\ gzip.at\ ignfail.at\ diff --git a/tests/filerem03.at b/tests/filerem03.at new file mode 100644 index 00000000..002b3293 --- /dev/null +++ b/tests/filerem03.at @@ -0,0 +1,46 @@ +# Process this file with autom4te to create testsuite. -*- Autotest -*- + +# Test suite for GNU tar. +# Copyright 2026 Free Software Foundation, Inc. + +# This file is part of GNU tar. + +# GNU tar is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# GNU tar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Description: see filerem01.at +# This test case verifies that --ignore-failed-read makes tar exit +# with code 0 when a file disappears during archiving, instead of +# TAREXIT_DIFFERS (1). + +AT_SETUP([file removed with --ignore-failed-read]) +AT_KEYWORDS([create incremental listed filechange filerem filerem03]) + +AT_TAR_CHECK([ +mkdir dir +mkdir dir/sub +genfile --file dir/file1 +genfile --file dir/sub/file2 + +genfile --run --checkpoint=3 --unlink dir/file1 -- \ + tar --blocking-factor=1 -c -f archive.tar \ + --listed-incremental db --ignore-failed-read -v dir >/dev/null +], +[0], +[ignore], +[tar: dir: Directory is new +tar: dir/sub: Directory is new +tar: dir/file1: File removed before we read it +],[],[],[gnu, posix]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index f03bbbff..63458eae 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -393,6 +393,7 @@ m4_include([incr11.at]) AT_BANNER([Files removed while archiving]) m4_include([filerem01.at]) m4_include([filerem02.at]) +m4_include([filerem03.at]) AT_BANNER([Directories removed while archiving]) m4_include([dirrem01.at]) -- 2.47.3
