summaryrefslogtreecommitdiff
path: root/git-debrebase
diff options
context:
space:
mode:
Diffstat (limited to 'git-debrebase')
-rwxr-xr-xgit-debrebase69
1 files changed, 56 insertions, 13 deletions
diff --git a/git-debrebase b/git-debrebase
index 01429fb..e06963b 100755
--- a/git-debrebase
+++ b/git-debrebase
@@ -3,7 +3,8 @@
# Script helping make fast-forwarding histories while still rebasing
# upstream deltas when working on Debian packaging
#
-# Copyright (C)2017,2018 Ian Jackson
+# Copyright (C)2017-2019 Ian Jackson
+# Copyright (C)2019 Niko Tyni
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -120,7 +121,6 @@ our $playprefix = 'debrebase';
our $rd;
our $workarea;
-our @git = qw(git);
our @dgit = qw(dgit);
sub in_workarea ($) {
@@ -1154,6 +1154,10 @@ sub keycommits ($;$$$$$) {
return ($anchor, $breakwater);
}
+sub treated_anchor_msg () {
+ __ 'old anchor is recognised due to --anchor, cannot check upstream'
+}
+
sub walk ($;$$$);
sub walk ($;$$$) {
my ($input,
@@ -1747,6 +1751,16 @@ sub do_launder_head ($) {
}
sub cmd_launder_v0 () {
+ # =item git-debrebase launder-v0
+ #
+ # Launders the branch without recording anything in ffq-prev.
+ # Then prints some information about the current branch.
+ # Do not use this operation;
+ # it will be withdrawn soon.
+ #
+ # (docs removed from manual and placed here in dgit 10.6;
+ # the code is retained for information)
+
badusage "no arguments to launder-v0 allowed" if @ARGV;
my $old = get_head();
my ($tip,$breakwater,$last_anchor) = walk $old;
@@ -1973,7 +1987,7 @@ sub cmd_new_upstream () {
$new_version = (new Dpkg::Version "$spec_version-1", check => 1);
}
- my $new_upstream = shift @ARGV;
+ my $new_upstream = (@ARGV && $ARGV[0] !~ m{^-}) ? shift @ARGV : undef;
my $new_upstream_version = upstreamversion $new_version;
my $new_upstream_used;
($new_upstream, $new_upstream_used) =
@@ -2023,8 +2037,7 @@ sub cmd_new_upstream () {
my $old_anchor_cl = classify $old_anchor;
my $old_upstream;
if (!$old_anchor_cl->{OrigParents}) {
- snag 'anchor-treated',
- __ 'old anchor is recognised due to --anchor, cannot check upstream';
+ snag 'anchor-treated', treated_anchor_msg();
} else {
$old_upstream = parsecommit
$old_anchor_cl->{OrigParents}[0]{CommitId};
@@ -2273,6 +2286,16 @@ sub cmd_status () {
print __ "key git-debrebase commits:\n";
$prab->($anchor, __ 'anchor');
$prab->($bw, __ 'breakwater');
+ if (defined $anchor) {
+ print " upstream\n";
+ my $cl = classify $anchor;
+ my $ops = $cl->{OrigParents};
+ if ($ops) {
+ $prcommitinfo->($ops->[0]{CommitId});
+ } else {
+ printf " %s\n", treated_anchor_msg();
+ }
+ }
my ($ffqstatus, $ffq_msg, $current, $ffq_prev, $gdrlast) =
ffq_prev_branchinfo();
@@ -2463,6 +2486,7 @@ sub begin_convert_from () {
sub complete_convert_from ($$$$) {
my ($old_head, $new_head, $gi, $mrest) = @_;
+ snags_maybe_bail();
ffq_check $new_head;
record_gdrlast $gi->{LastRef}, $new_head, $gi->{LastObj}
if $gi->{LastRef};
@@ -2560,7 +2584,7 @@ END
print STDERR f_ <<END, "$@";
Cannot confirm dgit view: %s
Failed to stitch in dgit view (see messages above).
-dgit --overwrite will be needed on the first dgit push after conversion.
+dgit --trust-changelog will be needed on the first dgit push after conversion.
END
}
@@ -2697,10 +2721,11 @@ END
if (!@upstreams) {
if ($do_tags) {
my @tried;
- my $ups_tag = upstream_commitish_search $version, \@tried;
- if ($ups_tag) {
- my $this = f_ "git tag %s", $tried[-1];
- push @upstreams, { Commit => $ups_tag,
+ my ($ups_tag, $ups_rev) =
+ upstream_commitish_search $version, \@tried;
+ if ($ups_rev) {
+ my $this = f_ "git tag %s", $ups_tag;
+ push @upstreams, { Commit => "$ups_rev~0",
Source => $this,
};
} else {
@@ -2752,7 +2777,7 @@ END
} else {
print STDERR f_
" orig: no suitable origs found (looked for %s in %s)\n",
- "${p}_".(stripeoch $version)."...", $bpd;
+ "${p}_".(stripepoch $version)."...", $bpd;
}
}
}
@@ -2789,12 +2814,16 @@ END
if ($some_patches) {
runcmd @git, qw(checkout), $head, qw(-- debian/patches);
runcmd @git, qw(reset --quiet);
+ # We deliberately run with dirty patches, so want --ignore-new
+ # but it isn't available everywhere
+ playtree_write_gbp_conf('true');
my @gbp_cmd = (qw(gbp pq import));
if (!$diagnose) {
my $gbp_err = "../gbp-pq-err";
@gbp_cmd = shell_cmd "exec >$gbp_err 2>&1", @gbp_cmd;
}
my $r = system @gbp_cmd;
+ playtree_write_gbp_conf();
if ($r) {
print STDERR f_
" %s: couldn't apply patches: gbp pq %s",
@@ -2828,6 +2857,20 @@ END
print STDERR f_ "Yes, will base new branch on %s\n", $result->{Source};
+ my $out_diff = get_differs $result->{Result}, $head;
+ if ($out_diff & (D_UPS | DS_DEB)) {
+ print STDERR "\n", f_ <<END, $result->{Result};
+Result of applying debian/patches/ onto the upstream is not the same as HEAD.
+(Applying patches gave the commit %s)
+Perhaps the upstream is not right, or not all of the delta is in d/patches.
+END
+ runcmd @git, qw(--no-pager diff --stat),
+ $result->{Result}, $head,
+ qw( -- :!/debian/patches :/);
+ snag 'conversion-mismatch',
+ __ "Output of conversion does not match input!";
+ }
+
complete_convert_from $head, $result->{Result}, $gdrlastinfo,
'convert-from-dgit-view';
}
@@ -2941,7 +2984,7 @@ textdomain("git-debrebase");
getoptions_main
(__ "bad options\n",
"D+" => \$debuglevel,
- 'noop-ok', => \$opt_noop_ok,
+ 'noop-ok!',
'f=s' => \@snag_force_opts,
'anchor=s' => \@opt_anchors,
'--dgit=s' => \($dgit[0]),
@@ -2949,7 +2992,7 @@ getoptions_main
'experimental-merge-resolution!', \$opt_merges,
'-i:s' => sub {
my ($opt,$val) = @_;
- badusage f_ "%s: no cuddling to -i for git-rebase", $us
+ badusage f_ "%s: with git-debrebase, get-rebase -i option may only be followed by more options (as separate arguments)", $us
if length $val;
confess if $opt_defaultcmd_interactive; # should not happen
$opt_defaultcmd_interactive = [ qw(-i) ];