From 239bee091c4ef29092b115a3e9a5e0130b43aee2 Mon Sep 17 00:00:00 2001
From: Yurii Kolesnykov <root@yurikoles.com>
Date: Sun, 2 Sep 2018 14:43:18 +0300
Subject: [PATCH] Add short option '-D' as alias for '--zstd'

Signed-off-by: Yurii Kolesnykov <root@yurikoles.com>
---
 doc/tar.1    |  2 +-
 doc/tar.texi | 13 +++++++++++--
 src/buffer.c |  1 +
 src/tar.c    |  9 ++++-----
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/doc/tar.1 b/doc/tar.1
index 96a2308..1e88bbe 100644
--- a/doc/tar.1
+++ b/doc/tar.1
@@ -832,7 +832,7 @@ Filter the archive through
 Filter the archive through
 .BR compress (1).
 .TP
-\fB\-\-zstd\fR
+\fB\-D\fR, \fB\-\-zstd\fR
 Filter the archive through
 .BR zstd (1).
 .SS Local file selection
diff --git a/doc/tar.texi b/doc/tar.texi
index 1362216..fe2f8d1 100644
--- a/doc/tar.texi
+++ b/doc/tar.texi
@@ -3713,7 +3713,9 @@ only attributes from the user namespace.
 @itemx -J
 Use @command{xz} for compressing or decompressing the archives.  @xref{gzip}.
 
+@opsummary{zstd}
 @item --zstd
+@itemx -D
 Use @command{zstd} for compressing or decompressing the archives.  @xref{gzip}.
 
 @end table
@@ -3733,6 +3735,8 @@ them with the equivalent long option.
 
 @item -C @tab @ref{--directory}.
 
+@item -D @tab @ref{--zstd}.
+
 @item -F @tab @ref{--info-script}.
 
 @item -G @tab @ref{--incremental}.
@@ -9527,7 +9531,7 @@ switch to @samp{posix}.
 @GNUTAR{} is able to create and read compressed archives.  It supports
 a wide variety of compression programs, namely: @command{gzip},
 @command{bzip2}, @command{lzip}, @command{lzma}, @command{lzop},
-@command{xz} and traditional @command{compress}. The latter is
+@command{xz}, @command{zstd} and traditional @command{compress}. The latter is
 supported mostly for backward compatibility, and we recommend
 against using it, because it is by far less effective than the other
 compression programs@footnote{It also had patent problems in the past.}.
@@ -9545,7 +9549,7 @@ table below:
 @item @option{--lzip}     @tab             @tab @command{lzip}
 @item @option{--lzma}     @tab             @tab @command{lzma}
 @item @option{--lzop}     @tab             @tab @command{lzop}
-@item @option{--zstd}     @tab             @tab @command{zstd}
+@item @option{--zstd}     @tab @option{-D} @tab @command{zstd}
 @item @option{--compress} @tab @option{-Z} @tab @command{compress}
 @end multitable
 
@@ -9669,6 +9673,11 @@ Filter the archive through @command{lzma}.
 @item --lzop
 Filter the archive through @command{lzop}.
 
+@opindex zstd
+@item -D
+@itemx --zstd
+Filter the archive through @command{zstd}.
+
 @opindex compress
 @opindex uncompress
 @item -Z
diff --git a/src/buffer.c b/src/buffer.c
index b710c6a..4258f8c 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -328,6 +328,7 @@ static struct zip_program zip_program[] = {
   { ct_lzop,     LZOP_PROGRAM,     "--lzop" },
   { ct_xz,       XZ_PROGRAM,       "-J" },
   { ct_zstd,     ZSTD_PROGRAM,     "--zstd" },
+  { ct_zstd,     ZSTD_PROGRAM,     "-D" },
   { ct_none }
 };
 
diff --git a/src/tar.c b/src/tar.c
index 02fa561..4551bfd 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -349,7 +349,6 @@ enum
   XATTR_OPTION,
   XATTR_EXCLUDE,
   XATTR_INCLUDE,
-  ZSTD_OPTION,
 };
 
 static char const doc[] = N_("\
@@ -683,7 +682,7 @@ static struct argp_option options[] = {
   {"lzma", LZMA_OPTION, 0, 0, NULL, GRID+1 },
   {"lzop", LZOP_OPTION, 0, 0, NULL, GRID+1 },
   {"xz", 'J', 0, 0, NULL, GRID+1 },
-  {"zstd", ZSTD_OPTION, 0, 0, NULL, GRID+1 },
+  {"zstd", 'D', 0, 0, NULL, GRID+1 },
 #undef GRID
 
 #define GRID 100
@@ -850,7 +849,7 @@ option_conflict_error (const char *a, const char *b)
 /* Classes of options that can conflict: */
 enum option_class
   {
-    OC_COMPRESS,                 /* Compress options: -JjZz, -I, etc. */
+    OC_COMPRESS,                 /* Compress options: -DJjZz, -I, etc. */
     OC_OCCURRENCE,               /* --occurrence */
     OC_LISTED_INCREMENTAL,       /* --listed-incremental */
     OC_NEWER,                    /* --newer, --newer-mtime, --after-date */
@@ -1131,7 +1130,7 @@ tar_help_filter (int key, const char *text, void *input)
       s = xasprintf (_("filter the archive through %s"), XZ_PROGRAM);
       break;
 
-    case ZSTD_OPTION:
+    case 'D':
       s = xasprintf (_("filter the archive through %s"), ZSTD_PROGRAM);
       break;
 
@@ -1656,7 +1655,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
       set_use_compress_program_option (COMPRESS_PROGRAM, args->loc);
       break;
 
-    case ZSTD_OPTION:
+    case 'D':
       set_use_compress_program_option (ZSTD_PROGRAM, args->loc);
       break;
 
-- 
2.18.0

