X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=git-debrebase;h=0e2e0b7438c76cad9d9f3020896da15a117c6a7d;hb=4f5ea68c4b64ec065e40240e9f0df6ed4279593d;hp=9a71bd30e4607039aa79b47307be4e797664356e;hpb=3fdad08cc0d365364b9075e02261c5941bfe3cf5;p=dgit.git diff --git a/git-debrebase b/git-debrebase index 9a71bd30..0e2e0b74 100755 --- a/git-debrebase +++ b/git-debrebase @@ -21,6 +21,7 @@ # git-debrebase new-upstreams-v0 \ # NEW-VERSION ORIG-COMMITISH # [EXTRA-ORIG-NAME EXTRA-ORIG-COMMITISH ...] +# [] # usages: # git-debrebase status @@ -787,6 +788,8 @@ sub update_head_checkout ($$$) { sub update_head_postlaunder ($$$) { my ($old, $tip, $reflogmsg) = @_; + return if $tip eq $old; + print "git-debrebase: laundered (head was $old)\n"; update_head $old, $tip, $reflogmsg; # no tree changes except debian/patches runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches); @@ -802,6 +805,14 @@ sub cmd_launder () { printf "# last upstream merge\n%s\n", $last_upstream_merge; } +sub defaultcmd_rebase () { + my $old = get_head(); + my ($tip,$breakwater) = walk $old; + update_head_postlaunder $old, $tip, 'launder for rebase'; + @ARGV = qw(-i) unless @ARGV; # make configurable + runcmd @git, qw(rebase), @ARGV, $breakwater; +} + sub cmd_analyse () { die if ($ARGV[0]//'') =~ m/^-/; badusage "too many arguments to analyse" if @ARGV>1; @@ -816,16 +827,14 @@ sub cmd_analyse () { } sub cmd_new_upstream_v0 () { - # xxx would like to support more git-rebase options - badusage - "need NEW-VERSION UPS-COMMITISH [EXTRA-UPS-NAME EXTRA-UPS-COMMITISH...]" - unless @ARGV % 2 == 0 and @ARGV >= 2; # tree should be clean and this is not checked # automatically and unconditionally launders before rebasing # if rebase --abort is used, laundering has still been done my %pieces; + badusage "need NEW-VERSION UPS-COMMITTISH" unless @ARGV >= 2; + # parse args - low commitment my $new_version = (new Dpkg::Version scalar(shift @ARGV), check => 1); my $new_upstream_version = $new_version->version(); @@ -853,8 +862,12 @@ sub cmd_new_upstream_v0 () { OldIx => 0, New => $new_upstream, ); - while (@ARGV) { + while (@ARGV && $ARGV[0] !~ m{^-}) { my $n = shift @ARGV; + + badusage "for each EXTRA-UPS-NAME need EXTRA-UPS-COMMITISH" + unless @ARGV && $ARGV[0] !~ m{^-}; + my $c = git_rev_parse shift @ARGV; die unless $n =~ m/^$extra_orig_namepart_re$/; $newpiece->($n, New => $c); @@ -997,9 +1010,10 @@ END # the laundering output, because git-rebase can't easily be made # to make a replay list which is based on some other branch - update_head $old_head, $old_laundered_tip, 'launder for new upstream'; + update_head_postlaunder $old_head, $old_laundered_tip, + 'launder for new upstream'; - my @cmd = (@git, qw(rebase --onto), $new_bw, $old_bw); + my @cmd = (@git, qw(rebase --onto), $new_bw, $old_bw, @ARGV); runcmd @cmd; # now it's for the user to sort out } @@ -1063,10 +1077,14 @@ chdir $toplevel or die "chdir $toplevel: $!"; $rd = fresh_playground "$playprefix/misc"; -my $cmd = shift @ARGV; -my $cmdfn = $cmd; -$cmdfn =~ y/-/_/; -$cmdfn = ${*::}{"cmd_$cmdfn"}; +if (!@ARGV || $ARGV[0] =~ m{^-}) { + defaultcmd_rebase(); +} else { + my $cmd = shift @ARGV; + my $cmdfn = $cmd; + $cmdfn =~ y/-/_/; + $cmdfn = ${*::}{"cmd_$cmdfn"}; -$cmdfn or badusage "unknown git-debrebase sub-operation $cmd"; -$cmdfn->(); + $cmdfn or badusage "unknown git-debrebase sub-operation $cmd"; + $cmdfn->(); +}