]> Dogcows Code - chaz/tar/blobdiff - src/tar.c
tar: imply --xattrs when --xattrs-{inc,exc}lude used
[chaz/tar] / src / tar.c
index f36e1518455baa8e91abac3473abca73608de25f..08f334f554f50f0376576baaf51aa2199549f9de 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -167,6 +167,14 @@ set_archive_format (char const *name)
   archive_format = p->fmt;
 }
 
+static void
+set_xattr_option (int value)
+{
+  if (value == 1)
+    set_archive_format ("posix");
+  xattrs_option = value;
+}
+
 const char *
 archive_format_string (enum archive_format fmt)
 {
@@ -2095,16 +2103,16 @@ parse_opt (int key, char *arg, struct argp_state *state)
       break;
 
     case XATTR_OPTION:
-      set_archive_format ("posix");
-      xattrs_option = 1;
+      set_xattr_option (1);
       break;
 
     case NO_XATTR_OPTION:
-      xattrs_option = -1;
+      set_xattr_option (-1);
       break;
 
     case XATTR_INCLUDE:
     case XATTR_EXCLUDE:
+      set_xattr_option (1);
       xattrs_mask_add (arg, (key == XATTR_INCLUDE));
       break;
 
@@ -2549,22 +2557,22 @@ decode_options (int argc, char **argv)
     {
       char *base;
       
-      if (!IS_SUBCOMMAND_CLASS (SUBCL_READ))
-       option_conflict_error ("--one-top-level",
-                              subcommand_string (subcommand_option));
       if (absolute_names_option)
        option_conflict_error ("--one-top-level", "--absolute-names");
       
-      /* If the user wants to guarantee that everything is under one directory,
-        determine its name now and let it be created later.  */
-      base = base_name (archive_name_array[0]);
-      one_top_level_dir = strip_compression_suffix (base);
-      free (base);
-         
       if (!one_top_level_dir)
-       USAGE_ERROR ((0, 0,
-                     _("Cannot deduce top-level directory name; "
-                       "please set it explicitly with --one-top-level=DIR")));
+       {
+         /* If the user wants to guarantee that everything is under one
+            directory, determine its name now and let it be created later.  */
+         base = base_name (archive_name_array[0]);
+         one_top_level_dir = strip_compression_suffix (base);
+         free (base);
+
+         if (!one_top_level_dir)
+           USAGE_ERROR ((0, 0,
+                         _("Cannot deduce top-level directory name; "
+                           "please set it explicitly with --one-top-level=DIR")));
+       }
     }
 
   /* If ready to unlink hierarchies, so we are for simpler files.  */
This page took 0.021441 seconds and 4 git commands to generate.