e726270
diff --git a/src/tar.c b/src/tar.c
e726270
index e244808..18277e4 100644
e726270
--- a/src/tar.c
e726270
+++ b/src/tar.c
e726270
@@ -162,6 +162,14 @@ set_archive_format (char const *name)
e726270
   archive_format = p->fmt;
e726270
 }
e726270
 
e726270
+static void
e726270
+set_xattr_option (int value)
e726270
+{
e726270
+  if (value == 1)
e726270
+    set_archive_format ("posix");
e726270
+  xattrs_option = value;
e726270
+}
e726270
+
e726270
 const char *
e726270
 archive_format_string (enum archive_format fmt)
e726270
 {
e726270
@@ -2141,16 +2149,16 @@ parse_opt (int key, char *arg, struct argp_state *state)
e726270
       break;
e726270
 
e726270
     case XATTR_OPTION:
e726270
-      set_archive_format ("posix");
e726270
-      xattrs_option = 1;
e726270
+      set_xattr_option (1);
e726270
       break;
e726270
 
e726270
     case NO_XATTR_OPTION:
e726270
-      xattrs_option = -1;
e726270
+      set_xattr_option (-1);
e726270
       break;
e726270
 
e726270
     case XATTR_INCLUDE:
e726270
     case XATTR_EXCLUDE:
e726270
+      set_xattr_option (1);
e726270
       xattrs_mask_add (arg, (key == XATTR_INCLUDE));
e726270
       break;
e726270