Michael <[email protected]> ha escrit:

> 1. I was wondering how much work it would be to make
> "--listed-incremental" option work with "--no-recursion" option?

That's rather simple. Please, try the attached patch. Let me know if it
works for you.

> 2. And whether such a modification would need to be applied to
> extractor code as well?

No, it need not. Previous versions of tar should be able to correctly
handle archives created by this one.

Regards,
Sergey

Index: src/incremen.c
===================================================================
RCS file: /cvsroot/tar/tar/src/incremen.c,v
retrieving revision 1.65
diff -p -u -r1.65 incremen.c
--- src/incremen.c	7 Sep 2008 08:49:11 -0000	1.65
+++ src/incremen.c	29 Dec 2008 09:15:26 -0000
@@ -407,11 +407,14 @@ update_parent_directory (const char *nam
   free (p);
 }
 
+#define PD_VERBOSE        0x10
+#define PD_FORCE_CHILDREN 0x20
+#define PD_CHILDREN(f) ((f) & 3)
+
 static struct directory *
 procdir (char *name_buffer, struct stat *stat_data,
 	 dev_t device,
-	 enum children children,
-	 bool verbose,
+	 int flag,
 	 char *entry)
 {
   struct directory *directory;
@@ -485,7 +488,7 @@ procdir (char *name_buffer, struct stat 
 	{
 	  if (strcmp (d->name, name_buffer))
 	    {
-	      if (verbose)
+	      if (flag & PD_VERBOSE)
 		WARN ((0, 0, _("%s: Directory has been renamed from %s"),
 		       quotearg_colon (name_buffer),
 		       quote_n (1, d->name)));
@@ -498,7 +501,7 @@ procdir (char *name_buffer, struct stat 
       else
 	{
 	  DIR_SET_FLAG (directory, DIRF_NEW);
-	  if (verbose)
+	  if (flag & PD_VERBOSE)
 	    WARN ((0, 0, _("%s: Directory is new"),
 		   quotearg_colon (name_buffer)));
 	  directory->children =
@@ -517,43 +520,44 @@ procdir (char *name_buffer, struct stat 
       /* ... except if it was explicitely given in the command line */
       && !is_individual_file (name_buffer))
     directory->children = NO_CHILDREN;
-  else if (children == ALL_CHILDREN)
-    directory->children = ALL_CHILDREN;
+  else if (flag & PD_FORCE_CHILDREN)
+    directory->children = PD_CHILDREN(flag);
 
   DIR_SET_FLAG (directory, DIRF_INIT);
 
-  {
-    const char *tag_file_name;
-
-    switch (check_exclusion_tags (name_buffer, &tag_file_name))
-      {
-      case exclusion_tag_all:
-	/* This warning can be duplicated by code in dump_file0, but only
-	   in case when the topmost directory being archived contains
-	   an exclusion tag. */
-	exclusion_tag_warning (name_buffer, tag_file_name,
-			       _("directory not dumped"));
-	if (entry)
-	  *entry = 'N';
-	directory->children = NO_CHILDREN;
-	break;
-
-      case exclusion_tag_contents:
-	exclusion_tag_warning (name_buffer, tag_file_name,
-			       _("contents not dumped"));
-	directory->children = NO_CHILDREN;
-	break;
+  if (directory->children != NO_CHILDREN)
+    {
+      const char *tag_file_name;
 
-      case exclusion_tag_under:
-	exclusion_tag_warning (name_buffer, tag_file_name,
-			       _("contents not dumped"));
-	directory->tagfile = tag_file_name;
-	break;
+      switch (check_exclusion_tags (name_buffer, &tag_file_name))
+	{
+	case exclusion_tag_all:
+	  /* This warning can be duplicated by code in dump_file0, but only
+	     in case when the topmost directory being archived contains
+	     an exclusion tag. */
+	  exclusion_tag_warning (name_buffer, tag_file_name,
+				 _("directory not dumped"));
+	  if (entry)
+	    *entry = 'N';
+	  directory->children = NO_CHILDREN;
+	  break;
 
-      case exclusion_tag_none:
-	break;
-      }
-  }
+	case exclusion_tag_contents:
+	  exclusion_tag_warning (name_buffer, tag_file_name,
+				 _("contents not dumped"));
+	  directory->children = NO_CHILDREN;
+	  break;
+	  
+	case exclusion_tag_under:
+	  exclusion_tag_warning (name_buffer, tag_file_name,
+				 _("contents not dumped"));
+	  directory->tagfile = tag_file_name;
+	  break;
+	  
+	case exclusion_tag_none:
+	  break;
+	}
+    }
 
   return directory;
 }
@@ -645,7 +649,7 @@ scan_directory (char *dir, dev_t device)
   size_t name_length;		/* used length in name_buffer */
   struct stat stat_data;
   struct directory *directory;
-
+  
   if (! dirp)
     savedir_error (dir);
 
@@ -667,8 +671,7 @@ scan_directory (char *dir, dev_t device)
       return NULL;
     }
 
-  directory = procdir (name_buffer, &stat_data, device, NO_CHILDREN, false,
-		       NULL);
+  directory = procdir (name_buffer, &stat_data, device, 0, NULL);
 
   if (dirp && directory->children != NO_CHILDREN)
     {
@@ -709,8 +712,11 @@ scan_directory (char *dir, dev_t device)
 		{
 		  *entry = 'D';
 		  procdir (name_buffer, &stat_data, device,
-			   directory->children,
-			   verbose_option, entry);
+			   (verbose_option ? PD_VERBOSE : 0) |
+			    PD_FORCE_CHILDREN |
+			    (recursion_option ?
+			      directory->children : NO_CHILDREN),
+			   entry);
 		}
 
 	      else if (one_file_system_option && device != stat_data.st_dev)

Reply via email to