Blame SOURCES/tar-1.26-update-with-change-directory.patch

b77676
From 207b445ca7018a95f2f96d9514b8d87c80e8e11e Mon Sep 17 00:00:00 2001
b77676
From: Pavel Raiskup <praiskup@redhat.com>
b77676
Date: Wed, 4 Apr 2012 18:04:53 +0200
b77676
Subject: [PATCH] Bad cooperation of -C and -u options
b77676
b77676
Previously, tar did not update archive with newly created files in archived
b77676
directory --  it failed instead  with "file not found" error (because it looked
b77676
in bad directory in filesystem).
b77676
---
b77676
 src/update.c       |    4 +-
b77676
 tests/Makefile.am  |    3 +-
b77676
 tests/testsuite.at |    3 +-
b77676
 tests/update03.at  |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
b77676
 4 files changed, 65 insertions(+), 4 deletions(-)
b77676
 create mode 100644 tests/update03.at
b77676
b77676
diff --git a/src/update.c b/src/update.c
b77676
index e3228d4..4739e0d 100644
b77676
--- a/src/update.c
b77676
+++ b/src/update.c
b77676
@@ -1,7 +1,7 @@
b77676
 /* Update a tar archive.
b77676
 
b77676
    Copyright (C) 1988, 1992, 1994, 1996, 1997, 1999, 2000, 2001, 2003,
b77676
-   2004, 2005, 2007, 2010 Free Software Foundation, Inc.
b77676
+   2004, 2005, 2007, 2010, 2011, 2012 Free Software Foundation, Inc.
b77676
 
b77676
    This program is free software; you can redistribute it and/or modify it
b77676
    under the terms of the GNU General Public License as published by the
b77676
@@ -159,7 +159,7 @@ update_archive (void)
b77676
 
b77676
 			    for (p = dirp; *p; p += strlen (p) + 1)
b77676
 			      addname (namebuf_name (nbuf, p),
b77676
-				       0, false, NULL);
b77676
+				       name->change_dir, false, NULL);
b77676
 
b77676
 			    namebuf_free (nbuf);
b77676
 			    free (dirp);
b77676
diff --git a/tests/Makefile.am b/tests/Makefile.am
b77676
index ab7d104..119f1f3 100644
b77676
--- a/tests/Makefile.am
b77676
+++ b/tests/Makefile.am
b77676
@@ -1,7 +1,7 @@
b77676
 # Makefile for GNU tar regression tests.
b77676
 
b77676
 # Copyright (C) 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2005,
b77676
-# 2006, 2007, 2009 Free Software Foundation, Inc.
b77676
+# 2006, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
b77676
 
b77676
 # François Pinard <pinard@iro.umontreal.ca>, 1988.
b77676
 # Sergey Poznyakoff <gray@mirddin.farlep.net>, 2004.
b77676
@@ -156,6 +156,7 @@ TESTSUITE_AT = \
b77676
  update.at\
b77676
  update01.at\
b77676
  update02.at\
b77676
+ update03.at\
b77676
  volsize.at\
b77676
  volume.at\
b77676
  verbose.at\
b77676
diff --git a/tests/testsuite.at b/tests/testsuite.at
b77676
index 8366ef0..13f7506 100644
b77676
--- a/tests/testsuite.at
b77676
+++ b/tests/testsuite.at
b77676
@@ -1,7 +1,7 @@
b77676
 # Process this file with autom4te to create testsuite. -*- Autotest -*-
b77676
 
b77676
 # Test suite for GNU tar.
b77676
-# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Free Software
b77676
+# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 Free Software
b77676
 # Foundation, Inc.
b77676
 
b77676
 # This program is free software; you can redistribute it and/or modify
b77676
@@ -241,6 +241,7 @@ m4_include([spmvp10.at])
b77676
 m4_include([update.at])
b77676
 m4_include([update01.at])
b77676
 m4_include([update02.at])
b77676
+m4_include([update03.at])
b77676
 
b77676
 m4_include([verify.at])
b77676
 
b77676
diff --git a/tests/update03.at b/tests/update03.at
b77676
new file mode 100644
b77676
index 0000000..185f9eb
b77676
--- /dev/null
b77676
+++ b/tests/update03.at
b77676
@@ -0,0 +1,59 @@
b77676
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
b77676
+
b77676
+# Test suite for GNU tar.
b77676
+# Copyright (C) 2012 Free Software Foundation, Inc.
b77676
+
b77676
+# This program is free software; you can redistribute it and/or modify it under
b77676
+# the terms of the GNU General Public License as published by the Free Software
b77676
+# Foundation; either version 3, or (at your option) any later version.
b77676
+
b77676
+# This program is distributed in the hope that it will be useful, but WITHOUT
b77676
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
b77676
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
b77676
+# details.
b77676
+
b77676
+# You should have received a copy of the GNU General Public License along with
b77676
+# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
b77676
+# Street, Fifth Floor, Boston, MA 02110-1301, USA.
b77676
+
b77676
+# Description:
b77676
+#   Test if the '--update' option works with the '--directory DIR' option
b77676
+#   properly.  In version <= 1.26 tar this combination caused problems.
b77676
+#
b77676
+# References:
b77676
+#   https://bugzilla.redhat.com/show_bug.cgi?id=688567
b77676
+#
b77676
+# Last-Affected-Version:  1.26.90
b77676
+
b77676
+AT_SETUP([update & change directory (-C)])
b77676
+AT_KEYWORDS([update update03])
b77676
+
b77676
+AT_TAR_CHECK([
b77676
+AT_SORT_PREREQ
b77676
+
b77676
+# prepare filesystem
b77676
+mkdir dir
b77676
+mkdir dir/subdir
b77676
+genfile --file dir/subdir/a
b77676
+
b77676
+# crate archive of subdir
b77676
+tar -C dir -cf file.tar subdir
b77676
+
b77676
+# update filesystem
b77676
+mkdir dir/subdir/b
b77676
+genfile --file dir/subdir/b/c
b77676
+
b77676
+# sync the 'file.tar' archive
b77676
+tar -C dir -uf file.tar subdir
b77676
+
b77676
+# print contents
b77676
+tar -tf file.tar | sort || exit 1
b77676
+],
b77676
+[0],
b77676
+[subdir/
b77676
+subdir/a
b77676
+subdir/b/
b77676
+subdir/b/c
b77676
+])
b77676
+
b77676
+AT_CLEANUP
b77676
-- 
b77676
1.7.7.6
b77676