chiark / gitweb /
git-debrebase: make-patches: Handle case when there are no patches
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Aug 2018 12:35:55 +0000 (13:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Aug 2018 12:35:55 +0000 (13:35 +0100)
Previously, we would bomb out.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index d0fc8fd75032c963a2f8dff319af890d0cff3a08..10dadc55cab4f731768601f65e47a409ff132e69 100755 (executable)
@@ -2407,12 +2407,17 @@ sub make_patches_staged ($) {
 sub make_patches ($) {
     my ($head) = @_;
     keycommits $head, 0, \&snag;
-    make_patches_staged $head;
+    my $any = make_patches_staged $head;
     my $out;
     in_workarea sub {
-       my $ptree = cmdoutput @git, qw(write-tree --prefix=debian/patches/);
+       my $ptree = !$any ? undef :
+           cmdoutput @git, qw(write-tree --prefix=debian/patches/);
        runcmd @git, qw(read-tree), $head;
-       read_tree_subdir 'debian/patches', $ptree;
+       if ($ptree) {
+           read_tree_subdir 'debian/patches', $ptree;
+       } else {
+           rm_subdir_cached 'debian/patches';
+       }
        $out = make_commit [$head], [
             'Commit patch queue (exported by git-debrebase)',
             '[git-debrebase make-patches: export and commit patches]',