[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] [PATCH] Fix --add-file not working
From: |
James Clarke |
Subject: |
[Bug-tar] [PATCH] Fix --add-file not working |
Date: |
Sat, 12 Nov 2016 00:02:46 +0000 |
* src/names.c (names_options): Move add-file...
* src/tar.c (options): ...to here
* tests/add-file.at: New testcase.
* tests/testsuite.at: Mention new testcase.
* tests/Makefile.am: Likewise.
---
src/names.c | 2 --
src/tar.c | 2 ++
tests/Makefile.am | 1 +
tests/add-file.at | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/testsuite.at | 1 +
5 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/src/names.c b/src/names.c
index 219aa77..c0943a9 100644
--- a/src/names.c
+++ b/src/names.c
@@ -67,8 +67,6 @@ static struct argp_option names_options[] = {
{NULL, 0, NULL, 0,
N_("Local file name selection:"), GRID },
- {"add-file", ARGP_KEY_ARG, N_("FILE"), 0,
- N_("add given FILE to the archive (useful if its name starts with a
dash)"), GRID+1 },
{"directory", 'C', N_("DIR"), 0,
N_("change to directory DIR"), GRID+1 },
{"files-from", 'T', N_("FILE"), 0,
diff --git a/src/tar.c b/src/tar.c
index 35bac38..e45d8d4 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -687,6 +687,8 @@ static struct argp_option options[] = {
#define GRID 100
{NULL, 0, NULL, 0,
N_("Local file selection:"), GRID },
+ {"add-file", ARGP_KEY_ARG, N_("FILE"), 0,
+ N_("add given FILE to the archive (useful if its name starts with a
dash)"), GRID+1 },
{"one-file-system", ONE_FILE_SYSTEM_OPTION, 0, 0,
N_("stay in local file system when creating archive"), GRID+1 },
{"absolute-names", 'P', 0, 0,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 127d90b..a41b59a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -55,6 +55,7 @@ TESTSUITE_AT = \
T-mult.at\
T-nest.at\
testsuite.at\
+ add-file.at\
append.at\
append01.at\
append02.at\
diff --git a/tests/add-file.at b/tests/add-file.at
new file mode 100644
index 0000000..5347f6a
--- /dev/null
+++ b/tests/add-file.at
@@ -0,0 +1,64 @@
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
+
+# Test suite for GNU tar.
+# Copyright 2016 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/>.
+
+# Version 1.29 would give "tar: Cowardly refusing to create an empty archive"
+# if only --add-file arguments were used, and would give "tar: unhandled
+# positional option 0" when handling the --add-file if at least one file was
+# also given normally.
+
+AT_SETUP([--add-file option])
+AT_KEYWORDS([add-file])
+
+AT_TAR_CHECK([
+genfile --files-from - --length 10240 <<EOF
+file
+-file
+EOF
+
+echo Creating the first archive
+tar -cf archive.tar --add-file=file
+echo Testing the first archive
+tar -tf archive.tar
+
+echo Creating the second archive
+tar -cf archive.tar --add-file=-file file
+echo Testing the second archive
+tar -tf archive.tar
+
+echo Creating the third archive
+tar -cf archive.tar --add-file=-file --add-file=file
+echo Testing the third archive
+tar -tf archive.tar
+],
+[0],
+[Creating the first archive
+Testing the first archive
+file
+Creating the second archive
+Testing the second archive
+-file
+file
+Creating the third archive
+Testing the third archive
+-file
+file
+])
+
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 52e42eb..eeb8b07 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -241,6 +241,7 @@ m4_include([recurse.at])
m4_include([recurs02.at])
m4_include([shortrec.at])
m4_include([numeric.at])
+m4_include([add-file.at])
AT_BANNER([The --same-order option])
m4_include([same-order01.at])
--
2.10.2
- [Bug-tar] [PATCH] Fix --add-file not working,
James Clarke <=