git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] sequencer: remove AUTO_MERGE at the end of a rebase

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Oct 27, 2026, 10:57 UTC
Message-ID
<2fcb42a0858dffe45241cbced066dd0c0f5da76f.1793098652.git.phillip.wood@dunelm.org.uk>
In-Reply-To
<cover.1793098652.git.phillip.wood@dunelm.org.uk>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

If there are conflicts when picking a commit, the merge machinery creates a ref called AUTO_MERGE that the user can use to compare their conflict resolution to the conflicted result. The sequencer tries to remove that ref on every iteration of the loop that picks commits, but it is only written if we stop for conflicts, so it only needs to be removed when we enter the loop, not on every iteration. The ref is not removed after the loop has finished, which means that if the last pick has conflicts it is left behind after the rebase has finished. Fix this by removing the ref before the start of the loop in pick_commits() as the last commit did for REBASE_HEAD. The tests modified by the last commit are extended to check AUTO_MERGE as well.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 sequencer.c                | 4 ++--
 t/t3403-rebase-skip.sh     | 2 ++
 t/t3407-rebase-abort.sh    | 2 ++
 t/t3418-rebase-continue.sh | 2 ++
 4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 2d6a5f525c7..7a88b6530bf 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -5181,6 +5181,8 @@ static int pick_commits(struct repository *r,
 	unlink(rebase_path_amend());
 	unlink(rebase_path_patch());
 	unlink(git_path_merge_labels(r));
+	refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE", NULL,
+			REF_NO_DEREF);
 	refs_delete_ref(get_main_ref_store(r), "", "REBASE_HEAD", NULL,
 			REF_NO_DEREF);
 
@@ -5209,8 +5211,6 @@ static int pick_commits(struct repository *r,
 			}
 			unlink(rebase_path_author_script());
 			unlink(git_path_merge_head(r));
-			refs_delete_ref(get_main_ref_store(r), "", "AUTO_MERGE",
-					NULL, REF_NO_DEREF);
 
 			if (item->command == TODO_BREAK) {
 				if (!opts->verbose)
diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh
index a2a5ac8ae01..d4fcfe567c4 100755
--- a/t/t3403-rebase-skip.sh
+++ b/t/t3403-rebase-skip.sh
@@ -100,8 +100,10 @@ test_debug 'gitk --all & sleep 1'
 test_expect_success 'skipping final pick removes REBASE_HEAD & .git/MERGE_MSG' '
 	test_must_fail git rebase --onto hello reverted-goodbye^ \
 		reverted-goodbye &&
+	git show-ref --verify AUTO_MERGE &&
 	test_cmp_rev reverted-goodbye REBASE_HEAD &&
 	git rebase --skip &&
+	test_ref_missing AUTO_MERGE &&
 	test_ref_missing REBASE_HEAD &&
 	test_path_is_missing .git/MERGE_MSG
 '
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index 1703b5ae9b5..fdd9a2b9f61 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -35,8 +35,10 @@ testrebase() {
 		git reset --hard pre-rebase &&
 		test_must_fail git rebase$type main &&
 		test_path_is_dir "$state_dir" &&
+		git show-ref --verify AUTO_MERGE &&
 		test_cmp_rev d REBASE_HEAD &&
 		git rebase --abort &&
+		test_ref_missing AUTO_MERGE &&
 		test_ref_missing REBASE_HEAD &&
 		check_head &&
 		test_path_is_missing "$state_dir"
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
index f35cd130921..1c26bf5de54 100755
--- a/t/t3418-rebase-continue.sh
+++ b/t/t3418-rebase-continue.sh
@@ -39,9 +39,11 @@ test_expect_success 'merge based rebase --continue removes .git/MERGE_MSG' '
 	test_must_fail git rebase --onto main HEAD^ &&
 	git read-tree --reset -u HEAD &&
 	test_path_is_file .git/MERGE_MSG &&
+	git show-ref --verify AUTO_MERGE &&
 	test_cmp_rev commit-new-file-F2-on-topic-branch REBASE_HEAD &&
 	git rebase --continue &&
 	test_path_is_missing .git/MERGE_MSG &&
+	test_ref_missing AUTO_MERGE &&
 	test_ref_missing REBASE_HEAD
 '
 
-- 
2.56.0.336.g97505d19352
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “sequencer: fix cleanup of REBASE_HEAD and AUTO_MERGE”
  1. 0/3 sequencer: fix cleanup of REBASE_HEAD and AUTO_MERGEPhillip Wood, Oct 27, 2026
  2. 1/3 test_ref_missing(): improve error messagePhillip Wood, Oct 27, 2026
  3. Junio C HamanoOct 27, 2026
  4. 2/3 sequencer: remove REBASE_HEAD at the end of a rebasePhillip Wood, Oct 27, 2026
  5. Junio C HamanoOct 27, 2026
  6. 3/3 sequencer: remove AUTO_MERGE at the end of a rebasePhillip Wood, Oct 27, 2026
  7. Junio C HamanoOct 27, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.