Package: pristine-tar
Version: 1.40
Severity: wishlist
Tags: patch

pristine-tar gentar doesn't have a way to create missing directories
like commit and checkout do.  This causes problems if one wants to store
the pristine-tar directory in a subdirectory of a Git repository instead
of in a separate branch at the top level.

Attached is a patch to implement a --create-missing option, which simply
enables the internal create_missing flag that checkout and commit use,
but for gentar.

I've verified that it works as expected by using gendelta and gentar in
a subdirectory of a Git repository using the git-2.14.1.tar.gz tarball.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.11.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages pristine-tar depends on:
ii  libbz2-1.0  1.0.6-8.1
ii  libc6       2.24-14
ii  perl        5.26.0-5
ii  tar         1.29b-2
ii  xdelta      1.1.3-9.1+b1
ii  xdelta3     3.0.11-dfsg-1+b1
ii  zlib1g      1:1.2.8.dfsg-5

Versions of packages pristine-tar recommends:
ii  bzip2     1.0.6-8.1
ii  pbzip2    1.1.9-1+b1
ii  xz-utils  5.2.2-1.3

pristine-tar suggests no packages.

-- no debconf information

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204
From b42ac744f532baa4c2f8614dc4e4f38a5b27eceb Mon Sep 17 00:00:00 2001
From: "brian m. carlson" <[email protected]>
Date: Fri, 18 Aug 2017 00:56:50 +0000
Subject: [PATCH] Add a --create-missing option to gentar

pristine-tar handles the automatic recreation of empty directories with
the checkout command, since some version control systems, like Git,
don't store empty directories.  This is done by the internal use of a
flag, create_missing.

However, some workflows do not use checkout and commit for various
reasons, and hence cannot make use of this functionality.  Expose the
functionality using a flag, --create-missing, that recreates these
directories automatically.
---
 pristine-tar | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/pristine-tar b/pristine-tar
index d4f4b0e..9a1c7b1 100755
--- a/pristine-tar
+++ b/pristine-tar
@@ -8,7 +8,7 @@ pristine-tar - regenerate pristine tarballs
 
 B<pristine-tar> [-vdk] gendelta I<tarball> I<delta>
 
-B<pristine-tar> [-vdk] gentar I<delta> I<tarball>
+B<pristine-tar> [-vdk] [--create-missing] gentar I<delta> I<tarball>
 
 B<pristine-tar> [-vdk] [-m message] commit I<tarball> [I<upstream>]
 
@@ -120,6 +120,10 @@ Don't clean up the temporary directory on exit.
 
 Use this option to specify a custom commit message to pristine-tar commit.
 
+=item --create-missing
+
+When regenerating a tarball, create any missing empty directories.
+
 =back
 
 =head1 EXAMPLES
@@ -227,6 +231,7 @@ use constant {
 };
 
 my $message;
+my $create_missing;
 my $genversion =
   version_from_env(XDELTA3, "xdelta" => XDELTA, "xdelta3" => XDELTA3);
 
@@ -244,6 +249,7 @@ dispatch(
   },
   options => {
     "m|message=s" => \$message,
+    "create-missing" => \$create_missing,
   },
 );
 
@@ -343,7 +349,7 @@ sub recreatetarball {
       );
       $full_sweep = 1;
 
-      if ($options{create_missing}) {
+      if ($create_missing || $options{create_missing}) {
         # Avoid tar failing on the nonexistent item by
         # creating a dummy directory.
         debug("creating missing $unquoted_file");
-- 
2.14.1.480.gb18f417b89

Attachment: signature.asc
Description: PGP signature

Reply via email to