mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-04-26 03:20:40 +00:00
Simplify one_top_level_dir logic
* src/tar.c (one_top_level_option): Remove. All uses removed. All external uses changed to equivalent of !!one_top_level_dir. (decode_options): Set one_top_level_dir to be consistent with the old one_top_level_option.
This commit is contained in:
@@ -243,7 +243,6 @@ extern bool numeric_owner_option;
|
||||
extern bool one_file_system_option;
|
||||
|
||||
/* Create a top-level directory for extracting based on the archive name. */
|
||||
extern bool one_top_level_option;
|
||||
extern char *one_top_level_dir;
|
||||
|
||||
/* Specified value to be put into tar file in place of stat () results, or
|
||||
|
||||
@@ -170,7 +170,7 @@ transform_stat_info (char typeflag, struct tar_stat_info *stat_info)
|
||||
break;
|
||||
}
|
||||
|
||||
if (one_top_level_option)
|
||||
if (one_top_level_dir)
|
||||
enforce_one_top_level (&stat_info->file_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
17
src/tar.c
17
src/tar.c
@@ -73,7 +73,6 @@ char *set_mtime_format;
|
||||
int recursion_option;
|
||||
bool numeric_owner_option;
|
||||
bool one_file_system_option;
|
||||
bool one_top_level_option;
|
||||
char *one_top_level_dir;
|
||||
char const *owner_name_option;
|
||||
uid_t owner_option;
|
||||
@@ -1630,7 +1629,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
|
||||
|
||||
case ONE_TOP_LEVEL_OPTION:
|
||||
optloc_save (OC_ONE_TOP_LEVEL, args->loc);
|
||||
one_top_level_option = true;
|
||||
one_top_level_dir = arg;
|
||||
break;
|
||||
|
||||
@@ -2656,10 +2654,8 @@ decode_options (int argc, char **argv)
|
||||
same_order_option = false;
|
||||
}
|
||||
|
||||
if (one_top_level_option)
|
||||
if (optloc_lookup (OC_ONE_TOP_LEVEL))
|
||||
{
|
||||
char *base;
|
||||
|
||||
if (absolute_names_option)
|
||||
{
|
||||
struct option_locus *one_top_level_loc =
|
||||
@@ -2669,17 +2665,16 @@ decode_options (int argc, char **argv)
|
||||
|
||||
if (optloc_eq (one_top_level_loc, absolute_names_loc))
|
||||
option_conflict_error ("--one-top-level", "--absolute-names");
|
||||
else if (one_top_level_loc->source == OPTS_COMMAND_LINE)
|
||||
if (one_top_level_loc->source == OPTS_COMMAND_LINE)
|
||||
absolute_names_option = false;
|
||||
else
|
||||
one_top_level_option = false;
|
||||
one_top_level_dir = NULL;
|
||||
}
|
||||
|
||||
if (!one_top_level_dir && one_top_level_option)
|
||||
if (!absolute_names_option && !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]);
|
||||
/* Determine name now; the directory is created later if needed. */
|
||||
char *base = base_name (archive_name_array[0]);
|
||||
one_top_level_dir = strip_compression_suffix (base);
|
||||
free (base);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user