summaryrefslogtreecommitdiff
path: root/git-debrebase
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-03-25 17:11:41 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-06-16 16:07:01 +0100
commit5ccc45c714e700c97d52fa291daef03cd2492780 (patch)
treed481d62df0cbff4af85117274bf2d89bc7439752 /git-debrebase
parentb95109f18261edb47dda96bfd160fb2b79e39a41 (diff)
git-debrebase: break out stitch() (nfc)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'git-debrebase')
-rwxr-xr-xgit-debrebase52
1 files changed, 30 insertions, 22 deletions
diff --git a/git-debrebase b/git-debrebase
index 29f06a3..1713246 100755
--- a/git-debrebase
+++ b/git-debrebase
@@ -1026,6 +1026,33 @@ sub record_ffq_auto () {
}
}
+sub stitch ($$$$$) {
+ my ($old_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose) = @_;
+
+ push @deferred_updates, "delete $ffq_prev $ffq_prev_commitish";
+
+ if (is_fast_fwd $old_head, $ffq_prev_commitish) {
+ my $differs = get_differs $old_head, $ffq_prev_commitish;
+ unless ($differs & ~D_PAT_ADD) {
+ # ffq-prev is ahead of us, and the only tree changes it has
+ # are possibly addition of things in debian/patches/.
+ # Just wind forwards rather than making a pointless pseudomerge.
+ push @deferred_updates,
+ "update $gdrlast $ffq_prev_commitish $git_null_obj";
+ update_head_checkout $old_head, $ffq_prev_commitish,
+ "stitch (fast forward)";
+ return;
+ }
+ }
+ fresh_workarea();
+ my $new_head = make_commit [ $old_head, $ffq_prev ], [
+ 'Declare fast forward / record previous work',
+ "[git-debrebase pseudomerge: stitch$prose]",
+ ];
+ push @deferred_updates, "update $gdrlast $new_head $git_null_obj";
+ update_head $old_head, $new_head, "stitch";
+}
+
sub cmd_new_upstream_v0 () {
# automatically and unconditionally launders before rebasing
# if rebase --abort is used, laundering has still been done
@@ -1246,8 +1273,8 @@ sub cmd_stitch () {
fproblem $status, "could not check ffq-prev: $message";
fproblems_maybe_bail();
}
- my $prev = $ffq_prev && git_get_ref $ffq_prev;
- if (!$prev) {
+ my $ffq_prev_commitish = $ffq_prev && git_get_ref $ffq_prev;
+ if (!$ffq_prev_commitish) {
fail "No ffq-prev to stitch." unless $opt_noop_ok;
return;
}
@@ -1255,26 +1282,7 @@ sub cmd_stitch () {
keycommits $old_head, \&fproblem, \&fproblem, \&fproblem;
- push @deferred_updates, "delete $ffq_prev $prev";
-
- if (is_fast_fwd $old_head, $prev) {
- my $differs = get_differs $old_head, $prev;
- unless ($differs & ~D_PAT_ADD) {
- # ffq-prev is ahead of us, and the only tree changes it has
- # are possibly addition of things in debian/patches/.
- # Just wind forwards rather than making a pointless pseudomerge.
- push @deferred_updates, "update $gdrlast $prev $git_null_obj";
- update_head_checkout $old_head, $prev, "stitch (fast forward)";
- return;
- }
- }
- fresh_workarea();
- my $new_head = make_commit [ $old_head, $ffq_prev ], [
- 'Declare fast forward / record previous work',
- "[git-debrebase pseudomerge: stitch$prose]",
- ];
- push @deferred_updates, "update $gdrlast $new_head $git_null_obj";
- update_head $old_head, $new_head, "stitch";
+ stitch($old_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose);
}
sub cmd_convert_from_gbp () {