]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Fix interaction of -u with -C
authorSergey Poznyakoff <gray@gnu.org.ua>
Mon, 26 Sep 2016 10:17:26 +0000 (13:17 +0300)
committerSergey Poznyakoff <gray@gnu.org.ua>
Mon, 26 Sep 2016 10:53:50 +0000 (13:53 +0300)
* src/update.c (update_archive): Pass correct change_dir
value for addname
* tests/update03.at: New file.
* tests/Makefile.am: Add update03.at
* tests/testsuite.at: Include update03.at

src/update.c
tests/Makefile.am
tests/testsuite.at
tests/update03.at [new file with mode: 0644]

index ad7a6bf78be480efa1ecdb71866c90340c892020..d54cbdbc7193b7b2b35dc510ecf6da2bac854e58 100644 (file)
@@ -152,7 +152,7 @@ update_archive (void)
 
                            for (p = dirp; *p; p += strlen (p) + 1)
                              addname (namebuf_name (nbuf, p),
-                                      0, false, NULL);
+                                      name->change_dir, false, NULL);
 
                            namebuf_free (nbuf);
                            free (dirp);
index 3e638e37e9b942c4a8aad58ff68c23db78225a9e..537618091543da1d531dba1ba7afa63bf02956f5 100644 (file)
@@ -226,6 +226,7 @@ TESTSUITE_AT = \
  update.at\
  update01.at\
  update02.at\
+ update03.at\
  volsize.at\
  volume.at\
  verbose.at\
index 6fe5f89c88c8d5ed85f3added2bd110459c558f6..1f1897b28b1ff135973067f8d09038922ff59eb3 100644 (file)
@@ -396,6 +396,7 @@ AT_BANNER([Updates])
 m4_include([update.at])
 m4_include([update01.at])
 m4_include([update02.at])
+m4_include([update03.at])
 
 AT_BANNER([Verifying the archive])
 m4_include([verify.at])
diff --git a/tests/update03.at b/tests/update03.at
new file mode 100644 (file)
index 0000000..0a38e27
--- /dev/null
@@ -0,0 +1,51 @@
+# 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/>.
+
+AT_SETUP([update with chdir])
+AT_KEYWORDS([update update03 chdir])
+
+# Tar <=1.29 failed to chdir when -u was used with -C
+# Reported by: Ivan Kalvachev <ikalvachev@gmail.com>
+# References: <CABA=pqfSq-4PJYp7W2ezGOz+fR2uh74AyA7kOeXJBzg2o-oQBA@mail.gmail.com>,
+#             http://lists.gnu.org/archive/html/bug-tar/2016-08/msg00003.html
+AT_TAR_CHECK([
+mkdir dir1
+mkdir dir2
+mkdir dir1/subdir1 dir2/subdir2
+genfile --file dir1/subdir1/a
+genfile --file dir2/subdir2/a
+echo Create
+tar -vcf arc.tar -C dir1 subdir1 -C ../dir2 subdir2
+genfile --file dir1/subdir1/b
+genfile --file dir2/subdir2/c
+echo Update
+tar -vuf arc.tar -C dir1 subdir1 -C ../dir2 subdir2
+],
+[0],
+[Create
+subdir1/
+subdir1/a
+subdir2/
+subdir2/a
+Update
+subdir1/b
+subdir2/c
+])
+
+AT_CLEANUP
\ No newline at end of file