chiark / gitweb /
Dgit.pm: read_tree_*: Treat '' as meaning 'delete this'
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Jun 2019 16:08:39 +0000 (17:08 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Jun 2019 20:11:17 +0000 (21:11 +0100)
No functional change with existing callers.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm

index d60de77b6dc0790cdaf10cfb0377e94649c06198..887fbb599caa978c5ce3c499487dec73a3cfab20 100644 (file)
@@ -689,8 +689,11 @@ sub rm_subdir_cached ($) {
 
 sub read_tree_subdir ($$) {
     my ($subdir, $new_tree_object) = @_;
 
 sub read_tree_subdir ($$) {
     my ($subdir, $new_tree_object) = @_;
+    # If $new_tree_object is '', the subtree is deleted.
+    confess unless defined $new_tree_object;
     rm_subdir_cached $subdir;
     rm_subdir_cached $subdir;
-    runcmd qw(git read-tree), "--prefix=$subdir/", $new_tree_object;
+    runcmd qw(git read-tree), "--prefix=$subdir/", $new_tree_object
+       if length $new_tree_object;
 }
 
 sub read_tree_debian ($) {
 }
 
 sub read_tree_debian ($) {
@@ -702,9 +705,10 @@ sub read_tree_debian ($) {
 sub read_tree_upstream ($;$$) {
     my ($treeish, $keep_patches, $tree_with_debian) = @_;
     # if $tree_with_debian is supplied, will use that for debian/
 sub read_tree_upstream ($;$$) {
     my ($treeish, $keep_patches, $tree_with_debian) = @_;
     # if $tree_with_debian is supplied, will use that for debian/
-    # otherwise will save and restore it.
+    # otherwise will save and restore it.  If $tree_with_debian
+    # is '' then debian/ is deleted.
     my $debian =
     my $debian =
-       $tree_with_debian ? "$tree_with_debian:debian"
+       defined $tree_with_debian ? "$tree_with_debian:debian"
        : cmdoutput qw(git write-tree --prefix=debian/);
     runcmd qw(git read-tree), $treeish;
     read_tree_subdir 'debian', $debian;
        : cmdoutput qw(git write-tree --prefix=debian/);
     runcmd qw(git read-tree), $treeish;
     read_tree_subdir 'debian', $debian;