chiark / gitweb /
git-debrebase: new-upstream-v0 break out make_commit
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 31 Jan 2018 15:09:19 +0000 (15:09 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 11:25:49 +0000 (12:25 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index aaf7f93..df5d27e 100755 (executable)
@@ -273,6 +273,15 @@ sub read_tree_subdir ($$) {
     runcmd @git, qw(read-tree), "--prefix=$subdir/", $new_tree_object;
 }
 
+sub make_commit ($$) {
+    my ($parents, $message_paras) = @_;
+    my $tree = cmdoutput @git, qw(write-tree);
+    my @cmd = (@git, qw(commit-tree), $tree);
+    push @cmd, qw(-p), $_ foreach @$parents;
+    push @cmd, qw(-m), $_ foreach @$message_paras;
+    return cmdoutput @cmd;
+}
+
 # classify returns an info hash like this
 #   CommitId => $objid
 #   Hdr => # commit headers, including 1 final newline
@@ -948,14 +957,10 @@ sub cmd_new_upstream_v0 () {
        read_tree_subdir 'debian', "$old_bw:debian";
 
        # index now contains the breakwater merge contents
-
-       my $bw_tree = cmdoutput @git, qw(write-tree);
-       my @cmd = (@git, qw(commit-tree), $bw_tree);
-       push @cmd, qw(-p), $old_bw, qw(-p), $new_upstream;
-       push @cmd, qw(-m), "Update to upstream $new_upstream_version";
-       push @cmd, qw(-m),
-           "[git-debrebase new-upstream breakwater $new_upstream_version]";
-       $new_bw = cmdoutput @cmd;
+        $new_bw = make_commit [ $old_bw, $new_upstream ],
+            [ "Update to upstream $new_upstream_version",
+              "[git-debrebase new-upstream breakwater $new_upstream_version]",
+            ];
 
        # Now we have to add a changelog stanza so the Debian version
        # is right.
@@ -980,15 +985,10 @@ END
        runcmd @git, qw(update-index --add --replace), 'debian/changelog';
 
        # Now we have the final new breakwater branch in the index
-
-       $bw_tree = cmdoutput @git, qw(write-tree);
-       @cmd = (@git, qw(commit-tree), $bw_tree);
-       push @cmd, qw(-p), $new_bw;
-       push @cmd, qw(-m),
-           "Update changelog for new upstream $new_upstream_version";
-       push @cmd, qw(-m),
-           "[git-debrebase new-upstream changelog $new_upstream_version]";
-       $new_bw = cmdoutput @cmd;
+        $new_bw = make_commit [ $new_bw ],
+            [ "Update changelog for new upstream $new_upstream_version",
+              "[git-debrebase new-upstream changelog $new_upstream_version]",
+            ];
     };
 
     # we have constructed the new breakwater. we now need to commit to