On 13/02/14 09:21 AM, Sergey Poznyakoff wrote:
> I have fixed it in commit c86b0c21.
This commit causes one_top_level_dir to be the stripped archive name
even if the user wants it to be different. Here is a patch fixing this.

A separate issue I have is that for some usage patterns, it makes sense
to alias tar='tar --one-top-level' in .bashrc. This is not possible if
it conflicts with SUBCL_READ. Using --one-top-level with -c is currently
harmless and in the future it might be overloaded to add a layer of
depth to the created archive. Do you think we can take out this conflict?
From ae9fca28961efed9ae643105b15152d149e695d1 Mon Sep 17 00:00:00 2001
From: Connor Behan <[email protected]>
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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to