X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Ftar.c;h=a1e2936fbc66a72dcdf25bd5bd378add4fcf7617;hb=6060d613d1791632b0d6eaafc7d83210f791799a;hp=e21a6466f40249ff530ffed978ebc053d43f6b8e;hpb=ca856c2585cbb2e0ca6774c23a0f53447dbf3bf7;p=chaz%2Ftar diff --git a/src/tar.c b/src/tar.c index e21a646..a1e2936 100644 --- a/src/tar.c +++ b/src/tar.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any later + Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -260,6 +259,7 @@ enum EXCLUDE_TAG_OPTION, EXCLUDE_TAG_UNDER_OPTION, EXCLUDE_TAG_ALL_OPTION, + EXCLUDE_VCS_OPTION, FORCE_LOCAL_OPTION, GROUP_OPTION, HANG_OPTION, @@ -622,6 +622,8 @@ static struct argp_option options[] = { N_("exclude everything under directories containing FILE"), GRID+1 }, {"exclude-tag-all", EXCLUDE_TAG_ALL_OPTION, N_("FILE"), 0, N_("exclude directories containing FILE"), GRID+1 }, + {"exclude-vcs", EXCLUDE_VCS_OPTION, NULL, 0, + N_("exclude version control system directories"), GRID+1 }, {"no-recursion", NO_RECURSION_OPTION, 0, 0, N_("avoid descending automatically in directories"), GRID+1 }, {"one-file-system", ONE_FILE_SYSTEM_OPTION, 0, 0, @@ -785,6 +787,7 @@ struct tar_args /* Variables used during option parsing */ bool input_files; /* True if some input files where given */ }; + #define MAKE_EXCL_OPTIONS(args) \ ((((args)->wildcards != disable_wildcards) ? EXCLUDE_WILDCARDS : 0) \ | (args)->matching_flags \ @@ -796,6 +799,37 @@ struct tar_args /* Variables used during option parsing */ | (args)->matching_flags \ | recursion_option) +void +exclude_vcs_files () +{ + int i; + static char *vcs_file[] = { + /* CVS: */ + "CVS", + ".cvsignore", + /* RCS: */ + "RCS", + /* SCCS: */ + "SCCS", + /* SVN: */ + ".svn", + /* git: */ + ".git", + ".gitignore", + /* Arch: */ + ".arch-ids", + "{arch}", + "=RELEASE-ID", + "=meta-update", + "=update", + NULL + }; + + for (i = 0; vcs_file[i]; i++) + add_exclude (excluded, vcs_file[i], 0); +} + + #ifdef REMOTE_SHELL # define DECL_SHOW_DEFAULT_SETTINGS(stream, printer) \ { \ @@ -1548,6 +1582,10 @@ parse_opt (int key, char *arg, struct argp_state *state) add_exclusion_tag (arg, exclusion_tag_all, NULL); break; + case EXCLUDE_VCS_OPTION: + exclude_vcs_files (); + break; + case FORCE_LOCAL_OPTION: force_local_option = true; break; @@ -1934,23 +1972,23 @@ usage (int status) /* Parse the options for tar. */ static struct argp_option * -find_argp_option (struct argp_option *options, int letter) +find_argp_option (struct argp_option *o, int letter) { for (; - !(options->name == NULL - && options->key == 0 - && options->arg == 0 - && options->flags == 0 - && options->doc == NULL); options++) - if (options->key == letter) - return options; + !(o->name == NULL + && o->key == 0 + && o->arg == 0 + && o->flags == 0 + && o->doc == NULL); o++) + if (o->key == letter) + return o; return NULL; } static void decode_options (int argc, char **argv) { - int index; + int idx; struct tar_args args; /* Set some default option values. */ @@ -2041,7 +2079,7 @@ decode_options (int argc, char **argv) prepend_default_options (getenv ("TAR_OPTIONS"), &argc, &argv); if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_HELP, - &index, &args)) + &idx, &args)) exit (TAREXIT_FAILURE); @@ -2069,9 +2107,9 @@ decode_options (int argc, char **argv) } /* Handle operands after any "--" argument. */ - for (; index < argc; index++) + for (; idx < argc; idx++) { - name_add_name (argv[index], MAKE_INCL_OPTIONS (&args)); + name_add_name (argv[idx], MAKE_INCL_OPTIONS (&args)); args.input_files = true; } @@ -2408,6 +2446,7 @@ tar_stat_destroy (struct tar_stat_info *st) free (st->gname); free (st->sparse_map); free (st->dumpdir); + xheader_destroy (&st->xhdr); memset (st, 0, sizeof (*st)); }