From ae9fca28961efed9ae643105b15152d149e695d1 Mon Sep 17 00:00:00 2001 From: Connor Behan Date: Thu, 13 Feb 2014 22:33:29 -0800 Subject: [PATCH] Prefer the argument specified to --one-top-level Content-Type: text/plain; charset="utf-8" * src/tar.c (decode_options): Only deduce one_top_level_dir if one is not specified. --- src/tar.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/tar.c b/src/tar.c index f36e151..47013bf 100644 --- a/src/tar.c +++ b/src/tar.c @@ -2547,20 +2547,23 @@ decode_options (int argc, char **argv) if (one_top_level_option) { - 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) + { + char *base; + + 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; " -- 1.8.5.3