6334ff4
From fecf72d73021fa47956ea551f6ccc804213452ce Mon Sep 17 00:00:00 2001
c075bd4
From: Pavel Raiskup <praiskup@redhat.com>
c075bd4
Date: Wed, 4 Apr 2012 18:04:53 +0200
6334ff4
Subject: [PATCH 5/9] Bad cooperation of -C and -u options
c075bd4
c075bd4
Previously, tar did not update archive with newly created files in archived
c075bd4
directory --  it failed instead  with "file not found" error (because it looked
c075bd4
in bad directory in filesystem).
6334ff4
c075bd4
---
6334ff4
 src/update.c       |  2 +-
6334ff4
 tests/Makefile.am  |  1 +
6334ff4
 tests/testsuite.at |  1 +
6334ff4
 tests/update03.at  | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
6334ff4
 4 files changed, 62 insertions(+), 1 deletion(-)
c075bd4
 create mode 100644 tests/update03.at
c075bd4
c075bd4
diff --git a/src/update.c b/src/update.c
6334ff4
index c8fca0c..9a9c4e2 100644
c075bd4
--- a/src/update.c
c075bd4
+++ b/src/update.c
6334ff4
@@ -152,7 +152,7 @@ update_archive (void)
c075bd4
 
c075bd4
 			    for (p = dirp; *p; p += strlen (p) + 1)
c075bd4
 			      addname (namebuf_name (nbuf, p),
c075bd4
-				       0, false, NULL);
c075bd4
+				       name->change_dir, false, NULL);
c075bd4
 
c075bd4
 			    namebuf_free (nbuf);
c075bd4
 			    free (dirp);
c075bd4
diff --git a/tests/Makefile.am b/tests/Makefile.am
6334ff4
index 6684d1d..2a2e1cc 100644
c075bd4
--- a/tests/Makefile.am
c075bd4
+++ b/tests/Makefile.am
6334ff4
@@ -208,6 +208,7 @@ TESTSUITE_AT = \
c075bd4
  update.at\
c075bd4
  update01.at\
c075bd4
  update02.at\
c075bd4
+ update03.at\
c075bd4
  volsize.at\
c075bd4
  volume.at\
c075bd4
  verbose.at\
c075bd4
diff --git a/tests/testsuite.at b/tests/testsuite.at
6334ff4
index 7f8e4c4..f1ce58f 100644
c075bd4
--- a/tests/testsuite.at
c075bd4
+++ b/tests/testsuite.at
6334ff4
@@ -360,6 +360,7 @@ AT_BANNER([Updates])
c075bd4
 m4_include([update.at])
c075bd4
 m4_include([update01.at])
c075bd4
 m4_include([update02.at])
c075bd4
+m4_include([update03.at])
c075bd4
 
6777584
 AT_BANNER([Verifying the archive])
c075bd4
 m4_include([verify.at])
c075bd4
diff --git a/tests/update03.at b/tests/update03.at
c075bd4
new file mode 100644
c075bd4
index 0000000..185f9eb
c075bd4
--- /dev/null
c075bd4
+++ b/tests/update03.at
c075bd4
@@ -0,0 +1,59 @@
c075bd4
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
c075bd4
+
c075bd4
+# Test suite for GNU tar.
c075bd4
+# Copyright (C) 2012 Free Software Foundation, Inc.
c075bd4
+
c075bd4
+# This program is free software; you can redistribute it and/or modify it under
c075bd4
+# the terms of the GNU General Public License as published by the Free Software
c075bd4
+# Foundation; either version 3, or (at your option) any later version.
c075bd4
+
c075bd4
+# This program is distributed in the hope that it will be useful, but WITHOUT
c075bd4
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
c075bd4
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
c075bd4
+# details.
c075bd4
+
c075bd4
+# You should have received a copy of the GNU General Public License along with
c075bd4
+# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
c075bd4
+# Street, Fifth Floor, Boston, MA 02110-1301, USA.
c075bd4
+
c075bd4
+# Description:
c075bd4
+#   Test if the '--update' option works with the '--directory DIR' option
c075bd4
+#   properly.  In version <= 1.26 tar this combination caused problems.
c075bd4
+#
c075bd4
+# References:
c075bd4
+#   https://bugzilla.redhat.com/show_bug.cgi?id=688567
c075bd4
+#
c075bd4
+# Last-Affected-Version:  1.26.90
c075bd4
+
c075bd4
+AT_SETUP([update & change directory (-C)])
c075bd4
+AT_KEYWORDS([update update03])
c075bd4
+
c075bd4
+AT_TAR_CHECK([
c075bd4
+AT_SORT_PREREQ
c075bd4
+
c075bd4
+# prepare filesystem
c075bd4
+mkdir dir
c075bd4
+mkdir dir/subdir
c075bd4
+genfile --file dir/subdir/a
c075bd4
+
c075bd4
+# crate archive of subdir
c075bd4
+tar -C dir -cf file.tar subdir
c075bd4
+
c075bd4
+# update filesystem
c075bd4
+mkdir dir/subdir/b
c075bd4
+genfile --file dir/subdir/b/c
c075bd4
+
c075bd4
+# sync the 'file.tar' archive
c075bd4
+tar -C dir -uf file.tar subdir
c075bd4
+
c075bd4
+# print contents
c075bd4
+tar -tf file.tar | sort || exit 1
c075bd4
+],
c075bd4
+[0],
c075bd4
+[subdir/
c075bd4
+subdir/a
c075bd4
+subdir/b/
c075bd4
+subdir/b/c
c075bd4
+])
c075bd4
+
c075bd4
+AT_CLEANUP
c075bd4
-- 
6334ff4
1.9.3
c075bd4