>From e222c514347afbc1230015df59a1fe1c521645a4 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup
Date: Wed, 15 Aug 2012 16:56:03 +0200 Subject: [PATCH 2/3] Fix for bad cooperation of --wildcard and --update. --- src/common.h | 3 ++- src/names.c | 15 ++++++++------- src/tar.c | 2 +- src/update.c | 5 ++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/common.h b/src/common.h index c51ab11..7b2e785 100644 --- a/src/common.h +++ b/src/common.h @@ -668,7 +668,8 @@ void name_term (void); const char *name_next (int change_dirs); void name_gather (void); struct name *addname (char const *string, int change_dir, - bool cmdline, struct name *parent); + bool cmdline, struct name *parent, int + mask_matching_flags); void remname (struct name *name); bool name_match (const char *name); void names_notfound (void); diff --git a/src/names.c b/src/names.c index eee6bde..bdb2de5 100644 --- a/src/names.c +++ b/src/names.c @@ -414,7 +414,7 @@ name_gather (void) namelist = nametail = buffer; } else if (change_dir) - addname (0, change_dir, false, NULL); + addname (0, change_dir, false, NULL, 0); } else { @@ -428,11 +428,11 @@ name_gather (void) change_dir = chdir_arg (xstrdup (ep->v.name)); if (ep) - addname (ep->v.name, change_dir, true, NULL); + addname (ep->v.name, change_dir, true, NULL, 0); else { if (change_dir != change_dir0) - addname (NULL, change_dir, false, NULL); + addname (NULL, change_dir, false, NULL, 0); break; } } @@ -441,14 +441,15 @@ name_gather (void) /* Add a name to the namelist. */ struct name * -addname (char const *string, int change_dir, bool cmdline, struct name *parent) +addname (char const *string, int change_dir, bool cmdline, struct name *parent, + int mask_matching_flags) { struct name *name = make_name (string); name->prev = nametail; name->next = NULL; name->found_count = 0; - name->matching_flags = matching_flags; + name->matching_flags = matching_flags & ~mask_matching_flags; name->change_dir = change_dir; name->directory = NULL; name->parent = parent; @@ -829,7 +830,7 @@ add_hierarchy_to_namelist (struct tar_stat_info *st, struct name *name) namebuf = xrealloc (namebuf, allocated_length + 1); } strcpy (namebuf + name_length, string + 1); - np = addname (namebuf, change_dir, false, name); + np = addname (namebuf, change_dir, false, name, 0); if (!child_head) child_head = np; else @@ -934,7 +935,7 @@ collect_and_sort_names (void) name_gather (); if (!namelist) - addname (".", 0, false, NULL); + addname (".", 0, false, NULL, 0); if (listed_incremental_option) { diff --git a/src/tar.c b/src/tar.c index 8c4f656..ddcd700 100644 --- a/src/tar.c +++ b/src/tar.c @@ -1553,7 +1553,7 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'K': starting_file_option = true; - addname (arg, 0, true, NULL); + addname (arg, 0, true, NULL, 0); break; case ONE_FILE_SYSTEM_OPTION: diff --git a/src/update.c b/src/update.c index 17f9e05..89d2a38 100644 --- a/src/update.c +++ b/src/update.c @@ -158,8 +158,11 @@ update_archive (void) namebuf_t nbuf = namebuf_create (name->name); for (p = dirp; *p; p += strlen (p) + 1) + /* we are adding new file name based on actual + directory contents - we don't want to use + wildcards later on. */ addname (namebuf_name (nbuf, p), - 0, false, NULL); + 0, false, NULL, EXCLUDE_WILDCARDS); namebuf_free (nbuf); free (dirp); -- 1.7.11.2