Skip to content

Commit d92ec3b

Browse files
committed
Merge branch 'rebase-r-and-merge-head-v1'
2 parents b517370 + 07a0e6f commit d92ec3b

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

builtin/rebase.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "wt-status.h"
2323
#include "revision.h"
2424
#include "rerere.h"
25+
#include "branch.h"
2526

2627
static char const * const builtin_rebase_usage[] = {
2728
N_("git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] "
@@ -1179,6 +1180,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
11791180

11801181
if (reset_head(NULL, "reset", NULL, 0, NULL, NULL) < 0)
11811182
die(_("could not discard worktree changes"));
1183+
remove_branch_state();
11821184
if (read_basic_state(&options))
11831185
exit(1);
11841186
goto run_rebase;
@@ -1196,6 +1198,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
11961198
options.head_name, 0, NULL, NULL) < 0)
11971199
die(_("could not move back to %s"),
11981200
oid_to_hex(&options.orig_head));
1201+
remove_branch_state();
11991202
ret = finish_rebase(&options);
12001203
goto cleanup;
12011204
}

sequencer.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,10 +3184,6 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
31843184
}
31853185

31863186
merge_commit = to_merge->item;
3187-
write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ,
3188-
git_path_merge_head(the_repository), 0);
3189-
write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
3190-
31913187
bases = get_merge_bases(head_commit, merge_commit);
31923188
if (bases && !oidcmp(&merge_commit->object.oid,
31933189
&bases->item->object.oid)) {
@@ -3196,6 +3192,10 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
31963192
goto leave_merge;
31973193
}
31983194

3195+
write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ,
3196+
git_path_merge_head(the_repository), 0);
3197+
write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
3198+
31993199
for (j = bases; j; j = j->next)
32003200
commit_list_insert(j->item, &reversed);
32013201
free_commit_list(bases);
@@ -3434,6 +3434,7 @@ static int pick_commits(struct todo_list *todo_list, struct replay_opts *opts)
34343434
unlink(rebase_path_author_script());
34353435
unlink(rebase_path_stopped_sha());
34363436
unlink(rebase_path_amend());
3437+
unlink(git_path_merge_head(the_repository));
34373438
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
34383439
}
34393440
if (item->command <= TODO_SQUASH) {
@@ -3790,6 +3791,7 @@ static int commit_staged_changes(struct replay_opts *opts,
37903791
opts, flags))
37913792
return error(_("could not commit staged changes."));
37923793
unlink(rebase_path_amend());
3794+
unlink(git_path_merge_head(the_repository));
37933795
if (final_fixup) {
37943796
unlink(rebase_path_fixup_msg());
37953797
unlink(rebase_path_squash_msg());

t/t3430-rebase-merges.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,20 @@ test_expect_success 'with --autosquash and --exec' '
396396
grep "G: +G" actual
397397
'
398398

399+
test_expect_success '--continue after resolving conflicts after a merge' '
400+
git checkout -b already-has-g E &&
401+
git cherry-pick E..G &&
402+
test_commit H2 &&
403+
404+
git checkout -b conflicts-in-merge H &&
405+
test_commit H2 H2.t conflicts H2-conflict &&
406+
test_must_fail git rebase -r already-has-g &&
407+
grep conflicts H2.t &&
408+
echo resolved >H2.t &&
409+
git add -u &&
410+
git rebase --continue &&
411+
test_must_fail git rev-parse --verify HEAD^2 &&
412+
test_path_is_missing .git/MERGE_HEAD
413+
'
414+
399415
test_done

wt-status.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,7 @@ void wt_status_get_state(struct wt_status_state *state,
15531553
struct object_id oid;
15541554

15551555
if (!stat(git_path_merge_head(the_repository), &st)) {
1556+
wt_status_check_rebase(NULL, state);
15561557
state->merge_in_progress = 1;
15571558
} else if (wt_status_check_rebase(NULL, state)) {
15581559
; /* all set */
@@ -1576,9 +1577,13 @@ static void wt_longstatus_print_state(struct wt_status *s,
15761577
struct wt_status_state *state)
15771578
{
15781579
const char *state_color = color(WT_STATUS_HEADER, s);
1579-
if (state->merge_in_progress)
1580+
if (state->merge_in_progress) {
1581+
if (state->rebase_interactive_in_progress) {
1582+
show_rebase_information(s, state, state_color);
1583+
fputs("\n", s->fp);
1584+
}
15801585
show_merge_in_progress(s, state, state_color);
1581-
else if (state->am_in_progress)
1586+
} else if (state->am_in_progress)
15821587
show_am_in_progress(s, state, state_color);
15831588
else if (state->rebase_in_progress || state->rebase_interactive_in_progress)
15841589
show_rebase_in_progress(s, state, state_color);

0 commit comments

Comments
 (0)