From: Sergey Poznyakoff Date: Thu, 13 Aug 2009 13:45:49 +0000 (+0300) Subject: Fix interaction between --listed-incremental and -C X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=006c1efbe8ab3cbc335e8d22971ae4496577294c;p=chaz%2Ftar Fix interaction between --listed-incremental and -C * src/incremen.c (read_directory_file): Execute eventual -C dir after opening the snapshot file. (collect_and_sort_names): Remove call to chdir_do * tests/incr05.at, tests/incr06.at: Use relative file names for snapshot files. --- diff --git a/src/incremen.c b/src/incremen.c index 02cae38..bb2ba2f 100644 --- a/src/incremen.c +++ b/src/incremen.c @@ -1324,6 +1324,13 @@ read_directory_file (void) return; } + /* Consume the first name from the name list and reset the + list afterwards. This is done to change to the new + directory, if the first name is a chdir request (-C dir), + which is necessary to recreate absolute file names. */ + name_from_list (); + blank_name_list (); + if (0 < getline (&buf, &bufsize, listed_incremental_stream)) { char *ebuf; diff --git a/src/names.c b/src/names.c index 6e251e3..b12efe1 100644 --- a/src/names.c +++ b/src/names.c @@ -903,7 +903,7 @@ collect_and_sort_names (void) _("Only one -C option is allowed with " "--listed-incremental"))); } - chdir_do (namelist->change_dir); + read_directory_file (); } diff --git a/tests/incr05.at b/tests/incr05.at index 7b740d0..098c52e 100644 --- a/tests/incr05.at +++ b/tests/incr05.at @@ -25,14 +25,12 @@ mkdir dir/sub genfile --file dir/file1 genfile --file dir/sub/file2 -dbfile=`pwd`/db - echo Level 0 -tar -c -f archive.tar -g $dbfile -C dir -v --warning=no-new-dir . +tar -c -f archive.tar -g db -C dir -v --warning=no-new-dir . genfile --file dir/file3 echo Level 1 -tar -c -f archive.tar -g $dbfile -C dir -v --warning=no-new-dir . +tar -c -f archive.tar -g db -C dir -v --warning=no-new-dir . ], [0], [Level 0 diff --git a/tests/incr06.at b/tests/incr06.at index 6fcac3a..7efd3f2 100644 --- a/tests/incr06.at +++ b/tests/incr06.at @@ -28,20 +28,18 @@ genfile --file dir/file1 genfile --file dir/sub/file2 genfile --file dir/sub/a/file3 -dbfile=`pwd`/db - echo Level 0 . sub -tar -c -f archive-0.1.tar -g $dbfile.1 -C dir -v --warning=no-new-dir . sub +tar -c -f archive-0.1.tar -g db.1 -C dir -v --warning=no-new-dir . sub echo Level 0 sub . -tar -c -f archive-0.2.tar -g $dbfile.2 -C dir -v --warning=no-new-dir sub . +tar -c -f archive-0.2.tar -g db.2 -C dir -v --warning=no-new-dir sub . mkdir dir/c genfile --file dir/sub/b/file4 echo Level 1 . sub -tar -c -f archive-1.1.tar -g $dbfile.1 -C dir -v --warning=no-new-dir . sub +tar -c -f archive-1.1.tar -g db.1 -C dir -v --warning=no-new-dir . sub echo Level 1 sub . -tar -c -f archive-1.2.tar -g $dbfile.2 -C dir -v --warning=no-new-dir sub . +tar -c -f archive-1.2.tar -g db.2 -C dir -v --warning=no-new-dir sub . ], [0], [Level 0 . sub