mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-08-16 22:36:05 +00:00
Save work if one_top_level_dir is absolute
* src/misc.c (chdir_arg): Optimize --one-top-level=X where X is an absolute file name.
This commit is contained in:
@@ -1047,6 +1047,7 @@ ensure_wd (void)
|
||||
/* DIR is the operand of a -C option; add it to vector of chdir targets,
|
||||
and return the index of its location. If --one-top-level-dir, add
|
||||
two targets to the vector. However, if DIR is "." or an equivalent,
|
||||
or if --one-top-level-dir is an absolute file name,
|
||||
just reuse the last item in the vector. */
|
||||
idx_t
|
||||
chdir_arg (char *dir)
|
||||
@@ -1062,6 +1063,10 @@ chdir_arg (char *dir)
|
||||
return wd_count - 1;
|
||||
}
|
||||
|
||||
/* Optimize --one-top-level=X where X is an absolute file name. */
|
||||
if (one_top_level_dir && IS_ABSOLUTE_FILE_NAME (one_top_level_dir))
|
||||
return wd_count - 1;
|
||||
|
||||
ptrdiff_t shortage = 1 + !!one_top_level_dir - (wd_alloc - wd_count);
|
||||
if (0 < shortage)
|
||||
wd = xpalloc (wd, &wd_alloc, shortage, -1, sizeof *wd);
|
||||
|
||||
Reference in New Issue
Block a user