chiark / gitweb /
git-debrebase: Do not run a no-op rebase in default mode
[dgit.git] / git-debrebase
index 72b48288e7879ef4a799e8065de49a5e08f15bce..59b15aa38045ef8a79e7bc2b9cfd5ef0093b64b7 100755 (executable)
@@ -32,6 +32,7 @@ use Dpkg::Version;
 use File::FnMatch qw(:fnmatch);
 
 our ($opt_force, $opt_noop_ok, @opt_anchors);
+our ($opt_defaultcmd_interactive);
 
 our $us = qw(git-debrebase);
 
@@ -906,8 +907,9 @@ sub cmd_launder_v0 () {
 }
 
 sub defaultcmd_rebase () {
+    push @ARGV, @{ $opt_defaultcmd_interactive // [] };
     my ($tip,$breakwater) = do_launder_head 'launder for rebase';
-    runcmd @git, qw(rebase), @ARGV, $breakwater;
+    runcmd @git, qw(rebase), @ARGV, $breakwater if @ARGV;
 }
 
 sub cmd_analyse () {
@@ -1461,7 +1463,19 @@ GetOptions("D+" => \$debuglevel,
           'noop-ok', => \$opt_noop_ok,
           'f=s' => \@snag_force_opts,
           'anchor=s' => \@opt_anchors,
-          'force!') or die badusage "bad options\n";
+          'force!',
+          '-i:s' => sub {
+              my ($opt,$val) = @_;
+              badusage "git-debrebase: no cuddling to -i for git-rebase"
+                  if length $val;
+              die if $opt_defaultcmd_interactive; # should not happen
+              $opt_defaultcmd_interactive = [ qw(-i) ];
+              # This access to @ARGV is excessive familiarity with
+              # Getopt::Long, but there isn't another sensible
+              # approach.  '-i=s{0,}' does not work with bundling.
+              push @$opt_defaultcmd_interactive, @ARGV;
+              @ARGV=();
+          }) or die badusage "bad options\n";
 initdebug('git-debrebase ');
 enabledebug if $debuglevel;
 
@@ -1472,7 +1486,7 @@ $rd = fresh_playground "$playprefix/misc";
 
 @opt_anchors = map { git_rev_parse $_ } @opt_anchors;
 
-if (!@ARGV || $ARGV[0] =~ m{^-}) {
+if (!@ARGV || $opt_defaultcmd_interactive || $ARGV[0] =~ m{^-}) {
     defaultcmd_rebase();
 } else {
     my $cmd = shift @ARGV;