aboutsummaryrefslogtreecommitdiffstats
path: root/tar/bsdtar.c
diff options
context:
space:
mode:
Diffstat (limited to 'tar/bsdtar.c')
-rw-r--r--tar/bsdtar.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/tar/bsdtar.c b/tar/bsdtar.c
index e70b3929dea4..b59963d0f822 100644
--- a/tar/bsdtar.c
+++ b/tar/bsdtar.c
@@ -129,6 +129,28 @@ static void version(void) __LA_DEAD;
(ARCHIVE_EXTRACT_SECURE_SYMLINKS \
| ARCHIVE_EXTRACT_SECURE_NODOTDOT)
+static char const * const vcs_files[] = {
+ /* CVS */
+ "CVS", ".cvsignore",
+ /* RCS */
+ "RCS",
+ /* SCCS */
+ "SCCS",
+ /* SVN */
+ ".svn",
+ /* git */
+ ".git", ".gitignore", ".gitattributes", ".gitmodules",
+ /* Arch */
+ ".arch-ids", "{arch}", "=RELEASE-ID", "=meta-update", "=update",
+ /* Bazaar */
+ ".bzr", ".bzrignore", ".bzrtags",
+ /* Mercurial */
+ ".hg", ".hgignore", ".hgtags",
+ /* darcs */
+ "_darcs",
+ NULL
+};
+
int
main(int argc, char **argv)
{
@@ -318,6 +340,15 @@ main(int argc, char **argv)
lafe_errc(1, 0,
"Couldn't exclude %s\n", bsdtar->argument);
break;
+ case OPTION_EXCLUDE_VCS: /* GNU tar */
+ for(t=0; vcs_files[t]; t++) {
+ if (archive_match_exclude_pattern(
+ bsdtar->matching,
+ vcs_files[t]) != ARCHIVE_OK)
+ lafe_errc(1, 0, "Couldn't "
+ "exclude %s\n", vcs_files[t]);
+ }
+ break;
case OPTION_FFLAGS:
bsdtar->extract_flags |= ARCHIVE_EXTRACT_FFLAGS;
bsdtar->readdisk_flags &= ~ARCHIVE_READDISK_NO_FFLAGS;
@@ -808,8 +839,6 @@ main(int argc, char **argv)
break;
}
}
- if (bsdtar->flags & OPTFLAG_NO_SUBDIRS)
- only_mode(bsdtar, "-n", "cru");
if (bsdtar->flags & OPTFLAG_STDOUT)
only_mode(bsdtar, "-O", "xt");
if (bsdtar->flags & OPTFLAG_UNLINK_FIRST)
@@ -859,6 +888,16 @@ main(int argc, char **argv)
only_mode(bsdtar, buff, "cru");
}
+ /*
+ * When creating an archive from a directory tree, the directory
+ * walking code will already avoid entering directories when
+ * recursive inclusion of directory content is disabled, therefore
+ * changing the matching behavior has no effect for creation modes.
+ * It is relevant for extraction or listing.
+ */
+ archive_match_set_inclusion_recursion(bsdtar->matching,
+ !(bsdtar->flags & OPTFLAG_NO_SUBDIRS));
+
/* Filename "-" implies stdio. */
if (strcmp(bsdtar->filename, "-") == 0)
bsdtar->filename = NULL;