chiark / gitweb /
git-debrebase: Provide convert-from-unapplied aa alias for -gbp
[dgit.git] / git-debrebase
index 3101ae7d9dcddb39902d3aa6b71d976d694c5c3c..829ab82ce6e44941e0be6ddb83ff7922bf3b573e 100755 (executable)
@@ -47,7 +47,7 @@ usages:
   git-debrebase [<options>] prepush [--prose=...]
   git-debrebase [<options>] quick|conclude
   git-debrebase [<options>] new-upstream <new-version> [<details ...>]
-  git-debrebase [<options>] convert-from-gbp [<upstream-commitish>]
+  git-debrebase [<options>] convert-from-* ...
   ...
 See git-debrebase(1), git-debrebase(5), dgit-maint-debrebase(7) (in dgit).
 END
@@ -2537,6 +2537,7 @@ sub complete_convert_from ($$$$) {
     update_head_checkout $old_head, $new_head, $mrest;
 }
 
+sub cmd_convert_from_unapplied () { cmd_convert_from_gbp(); }
 sub cmd_convert_from_gbp () {
     badusage __ "want only 1 optional argument, the upstream git commitish"
        unless @ARGV<=1;
@@ -2698,10 +2699,10 @@ sub cmd_convert_to_gbp () {
     }
     snags_maybe_bail();
     update_head_checkout $head, $out, "convert to gbp (v0)";
-    print <<END or confess $!;
-$us: converted to git-buildpackage branch format
-$us: WARNING: do not now run "git-debrebase" any more
-$us: WARNING: doing so would drop all upstream patches!
+    print f_ <<END, $us,$us,$us or confess $!;
+%s: converted to git-buildpackage branch format
+%s: WARNING: do not now run "git-debrebase" any more
+%s: WARNING: doing so would drop all upstream patches!
 END
 }
 
@@ -2720,7 +2721,7 @@ sub cmd_convert_from_dgit_view () {
               'origs!', \$do_origs,
               'tags!', \$do_tags,
               'always-convert-anyway!', \$always);
-    fail "takes 1 optional argument, the upstream commitish" if @ARGV>1;
+    fail __ "takes 1 optional argument, the upstream commitish" if @ARGV>1;
 
     my @upstreams;
 
@@ -2728,7 +2729,7 @@ sub cmd_convert_from_dgit_view () {
        my $spec = shift @ARGV;
        my $commit = git_rev_parse "$spec^{commit}";
        push @upstreams, { Commit => $commit,
-                          Source => "$ARGV[0], from command line",
+                          Source => (f_ "%s, from command line", $ARGV[0]),
                           Only => 1,
                         };
     }
@@ -2741,12 +2742,13 @@ sub cmd_convert_from_dgit_view () {
        keycommits $head, sub{}, sub{}, $trouble, $trouble;
        printdebug "troubles=$troubles\n";
        if (!$troubles) {
-           print STDERR <<END;
-$us: Branch already seems to be in git-debrebase format!
-$us: --always-convert-anyway would do the conversion operation anyway
-$us: but is probably a bad idea.  Probably, you wanted to do nothing.
+           print STDERR f_ <<END, $us,$us,$us;
+%s: Branch already seems to be in git-debrebase format!
+%s: --always-convert-anyway would do the conversion operation anyway
+%s: but is probably a bad idea.  Probably, you wanted to do nothing.
 END
-           fail "Branch already in git-debrebase format." unless $opt_noop_ok;
+           fail __ "Branch already in git-debrebase format."
+               unless $opt_noop_ok;
            finish 0;
        }
     }
@@ -2756,19 +2758,20 @@ END
     snags_maybe_bail_early();
 
     my $version = upstreamversion $clogp->{Version};
-    print STDERR "Considering possible commits corresponding to upstream:\n";
+    print STDERR __
+       "Considering possible commits corresponding to upstream:\n";
 
     if (!@upstreams) {
        if ($do_tags) {
            my @tried;
            my $ups_tag = upstream_commitish_search $version, \@tried;
            if ($ups_tag) {
-               my $this = "git tag $tried[-1]";
+               my $this = f_ "git tag %s", $tried[-1];
                push @upstreams, { Commit => $ups_tag,
                                   Source => $this,
                                 };
            } else {
-               printf STDERR
+               print STDERR f_
                    " git tag: no suitable tag found (tried %s)\n",
                    "@tried";
            }
@@ -2778,11 +2781,12 @@ END
            # we do a quick check to see if there are plausible origs
            my $something=0;
            if (!opendir BPD, $bpd) {
-               die "opendir build-products-dir $bpd: $!" unless $!==ENOENT;
+               die f_ "opendir build-products-dir %s: %s", $bpd, $!
+                   unless $!==ENOENT;
            } else {
                while ($!=0, my $f = readdir BPD) {
                    next unless is_orig_file_of_p_v $f, $p, $version;
-                   printf STDERR
+                   print STDERR f_
                        " orig: found what looks like a .orig, %s\n",
                        "$bpd/$f";
                    $something=1;
@@ -2813,7 +2817,7 @@ END
                                     };
                }
            } else {
-               printf STDERR
+               print STDERR f_
                    " orig: no suitable origs found (looked for %s in %s)\n",
                    "${p}_".(stripeoch $version)."...", $bpd;
            }
@@ -2822,7 +2826,8 @@ END
 
     my $some_patches = stat_exists 'debian/patches/series';
 
-    print STDERR "Evaluating possible commits corresponding to upstream:\n";
+    print STDERR __
+       "Evaluating possible commits corresponding to upstream:\n";
 
     my $result;
     foreach my $u (@upstreams) {
@@ -2858,7 +2863,7 @@ END
                }
                my $r = system @gbp_cmd;
                if ($r) {
-                   printf STDERR
+                   print STDERR f_
                        " %s: couldn't apply patches: gbp pq %s",
                        $u->{Source}, waitstatusmsg();
                    return;
@@ -2867,8 +2872,9 @@ END
            my $work = git_rev_parse qw(HEAD);
            my $diffout = cmdoutput @git, qw(diff-tree --stat HEAD), $work;
            if (length $diffout) {
-               print STDERR
-                   " $u->{Source}: applying patches gives different tree\n";
+               print STDERR f_
+                   " %s: applying patches gives different tree\n",
+                   $u->{Source};
                print STDERR $diffout if $diagnose;
                return;
            }
@@ -2880,24 +2886,26 @@ END
     }
 
     if (!$result) {
-       fail <<END;
+       fail __ <<END;
 Could not find or construct a suitable upstream commit.
 Rerun adding --diagnose after convert-from-dgit-view, or pass a
 upstream commmit explicitly or provide suitable origs.
 END
     }
 
-    printf STDERR "Yes, will base new branch on %s\n", $result->{Source};
+    print STDERR f_ "Yes, will base new branch on %s\n", $result->{Source};
 
     complete_convert_from $head, $result->{Result}, $gdrlastinfo,
        'convert-from-dgit-view';
 }
 
 sub cmd_forget_was_ever_debrebase () {
-    badusage "forget-was-ever-debrebase takes no further arguments" if @ARGV;
+    badusage __ "forget-was-ever-debrebase takes no further arguments"
+       if @ARGV;
     my ($ffqstatus, $ffq_msg, $current, $ffq_prev, $gdrlast) =
        ffq_prev_branchinfo();
-    fail "Not suitable for recording git-debrebaseness anyway: $ffq_msg"
+    fail f_ "Not suitable for recording git-debrebaseness anyway: %s",
+           $ffq_msg
        if defined $ffq_msg;
     push @deferred_updates, "delete $ffq_prev";
     push @deferred_updates, "delete $gdrlast";
@@ -2998,7 +3006,7 @@ setlocale(LC_MESSAGES, "");
 textdomain("git-debrebase");
 
 getoptions_main
-          ("bad options\n",
+          (__ "bad options\n",
           "D+" => \$debuglevel,
           'noop-ok', => \$opt_noop_ok,
           'f=s' => \@snag_force_opts,
@@ -3024,8 +3032,7 @@ getoptions_main
 initdebug('git-debrebase ');
 enabledebug if $debuglevel;
 
-my $toplevel = cmdoutput @git, qw(rev-parse --show-toplevel);
-chdir $toplevel or fail "chdir toplevel $toplevel: $!\n";
+changedir_git_toplevel();
 
 $rd = fresh_playground "$playprefix/misc";