chiark / gitweb /
Pseudomerge: pseudomerge_make_commit: Lift up some message generation
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 0e99eb5dbb197ce146cffa5b02853a89b0e3964c..0dea96c8f1a678ad9c6d223197caa66e57cb2c0c 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -543,7 +543,7 @@ our %defcfg = ('dgit.default.distro' => 'debian',
               'dgit-distro.debian.git-check' => 'url',
               'dgit-distro.debian.git-check-suffix' => '/info/refs',
               'dgit-distro.debian.new-private-pushers' => 't',
-              'dgit-distro.debian.dgit-tag-format' => 'old',
+              'dgit-distro.debian.dgit-tag-format' => 'new',
               'dgit-distro.debian/push.git-url' => '',
               'dgit-distro.debian/push.git-host' => 'push.dgit.debian.org',
               'dgit-distro.debian/push.git-user-force' => 'dgit',
@@ -2412,23 +2412,32 @@ sub pseudomerge_version_check ($$) {
     return $i_arch_v;
 }
 
-sub pseudomerge_make_commit ($$$$$) {
-    my ($clogp, $dgitview, $archive_hash, $i_arch_v, $msg) = @_;
+sub pseudomerge_make_commit ($$$$ $$) {
+    my ($clogp, $dgitview, $archive_hash, $i_arch_v,
+       $msg_cmd, $msg_msg) = @_;
     progress "Declaring that HEAD inciudes all changes in $i_arch_v->[0]...";
 
     my $tree = cmdoutput qw(git rev-parse), "${dgitview}:";
     my $authline = clogp_authline $clogp;
 
+    chomp $msg_msg;
+    $msg_cmd .=
+       !defined $overwrite_version ? ""
+       : " --overwrite=".$overwrite_version;
+
     mkpath '.git/dgit';
     my $pmf = ".git/dgit/pseudomerge";
     open MC, ">", $pmf or die "$pmf $!";
-    print MC <<END, $msg or die $!;
+    print MC <<END or die $!;
 tree $tree
 parent $dgitview
 parent $archive_hash
 author $authline
 commiter $authline
 
+$msg_msg
+
+[$msg_cmd]
 END
     close MC or die $!;
 
@@ -2477,14 +2486,11 @@ sub splitbrain_pseudomerge ($$$$) {
 
     my $r = pseudomerge_make_commit
        $clogp, $dgitview, $archive_hash, $i_arch_v,
+       "dgit --quilt=$quilt_mode",
        (defined $overwrite_version ? <<END_OVERWR : <<END_MAKEFF);
 Declare fast forward from $overwrite_version
-
-[dgit --quilt=$quilt_mode --overwrite-version=$overwrite_version]
 END_OVERWR
 Make fast forward from $i_arch_v->[0]
-
-[dgit --quilt=$quilt_mode]
 END_MAKEFF
 
     progress "Made pseudo-merge of $i_arch_v->[0] into dgit view.";
@@ -2513,11 +2519,8 @@ sub plain_overwrite_pseudomerge ($$$) {
     my $m = "Declare fast forward from $overwrite_version";
 
     my $r = pseudomerge_make_commit
-       $clogp, $head, $archive_hash, $i_arch_v, <<END;
-$m
-
-[dgit --overwrite-version=$overwrite_version]
-END
+       $clogp, $head, $archive_hash, $i_arch_v,
+       "dgit", $m;
 
     runcmd @git, qw(update-ref -m), $m, 'HEAD', $r, $head;
 
@@ -2769,10 +2772,10 @@ END
        } else {
            fail "dgit push: HEAD is not a descendant".
                " of the archive's version.\n".
-               "dgit: To overwrite its contents,".
-               " use git merge -s ours ".lrref().".\n".
-               "dgit: To rewind history, if permitted by the archive,".
-               " use --deliberately-not-fast-forward";
+               "To overwrite the archive's contents,".
+               " pass --overwrite[=VERSION].\n".
+               "To rewind history, if permitted by the archive,".
+               " use --deliberately-not-fast-forward.";
        }
     }
 
@@ -4561,6 +4564,9 @@ sub parseopts () {
            } elsif (m/^--no-rm-on-error$/s) {
                push @ropts, $_;
                $rmonerror = 0;
+           } elsif (m/^--overwrite=(.*)$/s) {
+               push @ropts, $_;
+               $overwrite_version = $1;
            } elsif (m/^--(no-)?rm-old-changes$/s) {
                push @ropts, $_;
                $rmchanges = !$1;