chiark / gitweb /
git-debrebase: Break out gbp_pq_export (nfc)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 10 Aug 2018 11:33:10 +0000 (12:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 10 Aug 2018 11:35:13 +0000 (12:35 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 0d3162fd9a50d9c7a00969bf91997d017b2f8970..f56ec32e12a9833a15c69c53120d0f3708fc6011 100755 (executable)
@@ -310,6 +310,22 @@ sub any_snags () {
     return $snags_forced || $snags_tripped;
 }
 
+sub gbp_pq_export ($$$) {
+    my ($bname, $base, $tip) = @_;
+    # must be run in a workarea.  $bname and patch-queue/$bname
+    # ought not to exist.  Leaves you on patch-queue/$bname with
+    # the patches staged but not committed.
+    runcmd @git, qw(checkout -q -b), $bname, $base;
+    runcmd @git, qw(checkout -q -b), "patch-queue/$bname", $tip;
+    my @gbp_cmd = (qw(gbp pq export));
+    my $r = system shell_cmd 'exec >../gbp-pq-err 2>&1', @gbp_cmd;
+    if ($r) {
+       { local ($!,$?); copy('../gbp-pq-err', \*STDERR); }
+       failedcmd @gbp_cmd;
+    }
+    runcmd @git, qw(add -f debian/patches);
+}
+
 # classify returns an info hash like this
 #   CommitId => $objid
 #   Hdr => # commit headers, including 1 final newline
@@ -1618,15 +1634,7 @@ sub make_patches_staged ($) {
     my ($secret_head, $secret_bw, $last_anchor) = walk $head;
     fresh_workarea();
     in_workarea sub {
-       runcmd @git, qw(checkout -q -b bw), $secret_bw;
-       runcmd @git, qw(checkout -q -b patch-queue/bw), $secret_head;
-       my @gbp_cmd = (qw(gbp pq export));
-       my $r = system shell_cmd 'exec >../gbp-pq-err 2>&1', @gbp_cmd;
-       if ($r) {
-           { local ($!,$?); copy('../gbp-pq-err', \*STDERR); }
-           failedcmd @gbp_cmd;
-       }
-       runcmd @git, qw(add -f debian/patches);
+       gbp_pq_export 'bw', $secret_bw, $secret_head;
     };
 }