From 9241abbdc1b0c2b416bfd39ce5d230c3d9702b14 Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <cyril.brulebois@enst-bretagne.fr>
Date: Thu, 31 Jan 2008 05:32:04 +0100
Subject: [PATCH] =?utf-8?q?Add=20-e/--empty=20option=20to=20activate=20the=20=E2=80=9Cmissing=20files=20are=20empty=20directories=E2=80=9D=20mode.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

---
 pristine-tar |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/pristine-tar b/pristine-tar
index 2defb32..c0f09d7 100755
--- a/pristine-tar
+++ b/pristine-tar
@@ -47,6 +47,13 @@ Debug mode.
 
 Don't clean up the temporary directory on exit.
 
+=item -e
+
+When running gentar, assume missing files (from the manifest) are
+empty directories, and create them on the fly. Particularly useful
+when the revision control system doesn't track paths but rather
+content (which is the case of git).
+
 =head1 AUTHOR
 
 Joey Hess <joeyh@debian.org>
@@ -71,14 +78,15 @@ use constant GZIP_METHOD_DEFLATE => 0x08;
 my $verbose=0;
 my $debug=0;
 my $keep=0;
-	
+my $empty=0;
+
 # Force locale to C since tar may output utf-8 filenames differently
 # depending on the locale.
 $ENV{LANG}='C';
 
 sub usage {
-	print STDERR "Usage: pristine-tar [-vdk] gentar delta tarball\n";
-	print STDERR "       pristine-tar [-vdk] gendelta tarball delta\n";
+	print STDERR "Usage: pristine-tar [-vdke] gentar delta tarball\n";
+	print STDERR "       pristine-tar [-vdke] gendelta tarball delta\n";
 }
 
 sub debug {
@@ -183,11 +191,12 @@ sub gentarball {
 		utime 0, 0, "$tempdir/workdir/$file" || die "utime: $!";
 	}
 
-	# Currently: assume every missing file is an empty directory.
+	# Currently: assume every missing file is an empty directory
+	# if the user asked for that behaviour.
 	# TODO: Check for an entry in manifest-empty and only mkpath
 	# in this case.
 	foreach my $file (@missing) {
-		mkpath "$tempdir/workdir/$file";
+		mkpath "$tempdir/workdir/$file" if $empty;
 	}
 
 	# If some files couldn't be matched up with the manifest,
@@ -346,6 +355,7 @@ if (! GetOptions(
 	"v|verbose!" => \$verbose,
 	"d|debug!" => \$debug,
 	"k|keep!" => \$keep,
+	"e|empty!" => \$empty,
    ) || @ARGV != 3) {
 	usage();
 	exit 1;
-- 
1.5.3.7

