*/
assertMakeDir("test1in", 0755);
assertChdir("test1in");
+ assertMakeDir("a", 0755);
+ assertMakeDir("a/b", 0755);
assertMakeFile("old.txt", 0644, "old.txt");
assertEqualInt(0, stat("old.txt", &st));
sleepUntilAfter(st.st_mtime);
assertEqualInt(0, stat("middle.txt", &st));
sleepUntilAfter(st.st_mtime);
assertMakeFile("new.txt", 0644, "new");
+ assertMakeFile("a/b/new.txt", 0644, "new file in old directory");
/* Test --newer-than on create */
- assertEqualInt(0, systemf("%s -cf ../test1.tar --newer-than middle.txt *.txt", testprog));
- assertEqualInt(0, systemf("%s -cf ../test2.tar *.txt", testprog));
+ assertEqualInt(0, systemf("%s -cf ../test1.tar --newer-than middle.txt *.txt a", testprog));
+ assertEqualInt(0, systemf("%s -cf ../test2.tar *.txt a", testprog));
assertChdir("..");
/* Extract test1.tar to a clean dir and verify what got archived. */
assertChdir("test1out");
assertEqualInt(0, systemf("%s xf ../test1.tar", testprog));
assertFileExists("new.txt");
+ assertFileExists("a/b/new.txt");
assertFileNotExists("middle.txt");
assertFileNotExists("old.txt");
assertChdir("..");
assertChdir("test2out");
assertEqualInt(0, systemf("%s xf ../test2.tar --newer-than ../test1in/middle.txt", testprog));
assertFileExists("new.txt");
+ assertFileExists("a/b/new.txt");
assertFileNotExists("middle.txt");
assertFileNotExists("old.txt");
assertChdir("..");
- /* TODO: old dir containing new file, should descend into dir to visit file even though we don't archive it. */
- // rm -rf t && mkdir -p t/a/b && cd t && sleep 1 && touch TIMESTAMP && sleep 1 && touch a/b/test && ../bin/bsdtar cvf /dev/null --newer-than TIMESTAMP a && cd ..
-
}
break;
}
+ if (bsdtar->option_no_subdirs)
+ descend = 0;
+
/*
* Are we about to cross to a new filesystem?
*/
} else if (descend == 0) {
/* We're not descending, so no need to check. */
} else if (bsdtar->option_dont_traverse_mounts) {
- /* User has asked us not to cross mount points. */
descend = 0;
} else {
/* We're prepared to cross a mount point. */
* In -u mode, check that the file is newer than what's
* already in the archive; in all modes, obey --newerXXX flags.
*/
- if (!new_enough(bsdtar, name, st))
+ if (!new_enough(bsdtar, name, st)) {
+ if (!descend)
+ continue;
+ if (bsdtar->option_interactive &&
+ !yes("add '%s'", name))
+ continue;
+ tree_descend(tree);
continue;
+ }
archive_entry_free(entry);
entry = archive_entry_new();
!yes("add '%s'", name))
continue;
- /* Note: if user vetoes, we won't descend. */
- if (descend && !bsdtar->option_no_subdirs)
+ if (descend)
tree_descend(tree);
/*