All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org,  Long 76 <long76.git@mail.ru>,
	 Matt Hunter <m@lfurio.us>
Subject: Re: [PATCH 2/3] sequencer: remove REBASE_HEAD at the end of a rebase
Date: Tue, 27 Oct 2026 13:10:13 -0700	[thread overview]
Message-ID: <xmqqh5i6j462.fsf@gitster.g> (raw)
In-Reply-To: <ba13c74698d2af3bd2ababbf2ff1a9738a81d501.1793098652.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Tue, 27 Oct 2026 10:57:56 +0000")

Phillip Wood <phillip.wood123@gmail.com> writes:

> Several existing tests are extended to check that REBASE_HEAD is
> present when we stop for conflicts and is absent when the rebase
> finishes.

Good.

> diff --git a/sequencer.c b/sequencer.c
> index 2ac78e15b89..2d6a5f525c7 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1781,7 +1781,10 @@ static int do_commit(struct repository *r,
>  		if (is_rebase_i(opts) && oid)
>  			if (write_rebase_head(oid))
>  			    return -1;
> -		return run_git_commit(msg_file, reflog_action, opts, flags);
> +		res = run_git_commit(msg_file, reflog_action, opts, flags);
> +		if (!res && is_rebase_i(opts) && oid)
> +			refs_delete_ref(get_main_ref_store(r), "", "REBASE_HEAD",
> +					NULL, REF_NO_DEREF);
>  	}
>  
>  	return res;
> @@ -5178,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), "", "REBASE_HEAD", NULL,
> +			REF_NO_DEREF);
>  
>  	while (todo_list->current < todo_list->nr) {
>  		struct todo_item *item = todo_list->items + todo_list->current;
> @@ -5206,8 +5211,6 @@ static int pick_commits(struct repository *r,
>  			unlink(git_path_merge_head(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);
>  
>  			if (item->command == TODO_BREAK) {
>  				if (!opts->verbose)

The patch is a bit dense (not a fault of the patch, but the blame
largely lies on the overly long functions involved with multi-level
callchain), but the idea is that the existing removal in the loop
inside pick_commits() may not trigger if the user resumes (via
"--continue" or "--skip") with an exhausted todo_list and that would
leave the REBASE_HEAD file behind, so we remove at the beginning of
pick_commits() before entering the loop, and also in do_commit(),
which is called deep inside the callchain from the loop to handle
one step, immediately before it returns on successful commit.

Which makes perfect sense.  The new tests seems to cover these cases
adequately, too.

Thanks.

  reply	other threads:[~2026-10-27 20:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 10:57 [PATCH 0/3] sequencer: fix cleanup of REBASE_HEAD and AUTO_MERGE Phillip Wood
2026-10-27 10:57 ` [PATCH 1/3] test_ref_missing(): improve error message Phillip Wood
2026-10-27 20:00   ` Junio C Hamano
2026-10-27 10:57 ` [PATCH 2/3] sequencer: remove REBASE_HEAD at the end of a rebase Phillip Wood
2026-10-27 20:10   ` Junio C Hamano [this message]
2026-10-27 10:57 ` [PATCH 3/3] sequencer: remove AUTO_MERGE " Phillip Wood
2026-10-27 20:11   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqh5i6j462.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=long76.git@mail.ru \
    --cc=m@lfurio.us \
    --cc=phillip.wood123@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.