From eb9874dc455a603e05fa3f764339d8b9f16bd017 Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <cyril.brulebois@enst-bretagne.fr>
Date: Thu, 31 Jan 2008 05:23:34 +0100
Subject: [PATCH] Assume every missing file in the manifest is an empty directory.

---
 pristine-tar |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/pristine-tar b/pristine-tar
index 90d80ae..2defb32 100755
--- a/pristine-tar
+++ b/pristine-tar
@@ -158,6 +158,7 @@ sub gentarball {
 	# for a given set of input files. So don't include file metadata
 	# in the tarball, since it can easily vary.
 	my $full_sweep=0;
+	my @missing=();
 	foreach my $file (@manifest) {
 		if (-l "$tempdir/workdir/$file") {
 			# Can't set timestamp of a symlink, so
@@ -169,6 +170,7 @@ sub gentarball {
 		elsif (! -e "$tempdir/workdir/$file") {
 			debug("$file is listed in the manifest but may not be present in the source directory");
 			$full_sweep=1;
+                        push @missing, $file;
 		}
 		
 		if (-d "$tempdir/workdir/$file" && (-u _ || -g _ || -k _)) {
@@ -180,7 +182,14 @@ sub gentarball {
 		}
 		utime 0, 0, "$tempdir/workdir/$file" || die "utime: $!";
 	}
-	
+
+	# Currently: assume every missing file is an empty directory.
+	# TODO: Check for an entry in manifest-empty and only mkpath
+	# in this case.
+	foreach my $file (@missing) {
+		mkpath "$tempdir/workdir/$file";
+	}
+
 	# If some files couldn't be matched up with the manifest,
 	# it's possible they do exist, but just with names that make sense
 	# to tar, but not to this program. To work around this and make sure
-- 
1.5.3.7

