From 632477167abfdf1d0e9f5bb28ffe6cdb74e2a4fa Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 24 Jan 2018 17:09:07 +0000 Subject: [PATCH 1/1] git-debrebase: new-upstream wip Signed-off-by: Ian Jackson --- git-debrebase | 69 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/git-debrebase b/git-debrebase index 51b2429d..60a27ad1 100755 --- a/git-debrebase +++ b/git-debrebase @@ -837,7 +837,7 @@ sub cmd_new_upstream_v0 () { if ($old_orig_ci =~ m{^\[git-debrebase }m) { if ($old_orig_ci =~ - m{^\[git-debrebase combine-upstreams \.((?: $extra_orig_namepart_re)+)\]} + m{^\[git-debrebase new-upstream combine \.((?: $extra_orig_namepart_re)+)\]} ) { my @oldpieces = ('', split / /, $1); my $parentix = -1 + scalar @{ $old_orig->{Parents} }; @@ -847,7 +847,7 @@ sub cmd_new_upstream_v0 () { } } else { $problem->("previous upstream $old_orig->{CommitId} is from". - " git-debrebase but not a \`combine-upstream' commit"); + " git-debrebase but not a \`new-upstream combine' commit"); } } @@ -882,14 +882,11 @@ sub cmd_new_upstream_v0 () { } foreach my $pc (@newpieces) { # always has '' first - my @cmd = @git, qw(read-tree); if ($pc->{Name}) { - push @cmd, "-prefix=$pcname/"; - runcmd @git, qw(rm --cached -rf --ignore-unmatch), $pcname; + read_tree_subdir $pcname, $pc->{New]; + } else { + runcmd @git, qw(read-tree), $pc->{New}; } - push @cmd, $pc->{New}; - runcmd @cmd; - push @upstream_merge_parents, $pc->{New}; } @@ -898,11 +895,11 @@ sub cmd_new_upstream_v0 () { if (@newpieces > 1) { # need to make the upstream subtree merge commit my $us_tree = cmdoutput @git, qw(write-tree); - my @cmd = @git, qw(commit-tree), $us_tree; + my @cmd = (@git, qw(commit-tree), $us_tree); push @cmd, qw(-p), $_ foreach @upstream_merge_parents; push @cmd, qw(-m), "Combine upstreams for $new_upstream_version"; push @cmd, qw(-m), - "[git-debrebase combine-upstreams . ". + "[git-debrebase new-upstream combine . ". (join " ", map { $_->{Name} } @newpieces[1..$#newpieces]). "]"; $new_upstream = cmdoutput @cmd; @@ -912,13 +909,51 @@ sub cmd_new_upstream_v0 () { # combined commit we just made. Either way it will be the # "upstream" parent of the breakwater special merge. - runcmd @git, qw(rm --cached -rf --ignore-unmatch), 'debian'; - runcmd @git, qw(read-tree --prefix=debian/), - - my @bcmd = @git, qw - - my $us_txt = "" - make_commit_te + read_tree_subdir 'debian', "$breakwater:debian"; + + # index now contains the breakwater merge contents + + my $bw_tree = cmdoutput @git, qw(write_tree); + my @cmd = (@git, qw(commit-tree), $bw_tree); + push @cmd, qw(-p), $breakwater, qw(-p), $new_upstream; + push @cmd, qw(-m), "Update to upstream $new_upstream_version"; + push @cmd, qw(-m), + "[git-debrebase new-upstream breakwater $new_upstream_version]"; + my $new_bw = cmdoutput @git; + + # Now we have to add a changelog stanza so the Debian version + # is right. + + die if unlink "debian"; + die unless $!==ENOTEMPTY; + unlink "debian/changelog" or die $!; + open CN, ">", "debian/changelog" or die $!; + my $oldclog = git_cat_file ":debian/changelog"; + $oldclog =~ m/^($package_re) \(\S+\) / or + fail "cannot parse old changelog to get package name"; + my $p = $1; + print CN, <