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

Re: [PATCH 4/5] built-in rebase --skip/--abort: clean up stale .git/<name> files

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2018, 02:11 UTC
Message-ID
<xmqqlg5xybdg.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<8d1dec51b704c45bf36af24f657cc40f006989e2.1542065154.git.gitgitgadget@gmail.com>

"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com> writes:

Show 39 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>
> The scripted version of the rebase used to execute `git reset --hard`
> when skipping or aborting. When we ported this to C, we did update the
> worktree and some reflogs, but we failed to imitate `git reset --hard`'s
> behavior regarding files in .git/ such as MERGE_HEAD.
>
> Let's address this oversight.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
>  builtin/rebase.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index 0ee06aa363..017dce1b50 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -23,6 +23,7 @@
>  #include "revision.h"
>  #include "commit-reach.h"
>  #include "rerere.h"
> +#include "branch.h"
>  
>  static char const * const builtin_rebase_usage[] = {
>  	N_("git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] "
> @@ -1002,6 +1003,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  
>  		if (reset_head(NULL, "reset", NULL, 0, NULL, NULL) < 0)
>  			die(_("could not discard worktree changes"));
> +		remove_branch_state();
>  		if (read_basic_state(&options))
>  			exit(1);
>  		goto run_rebase;
> @@ -1019,6 +1021,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  			       options.head_name, 0, NULL, NULL) < 0)
>  			die(_("could not move back to %s"),
>  			    oid_to_hex(&options.orig_head));
> +		remove_branch_state();

Hmph. Among 5 or so callsites of reset_head(), only these two places need it, so reset_head() is clearly not a substitute for "reset --hard HEAD", and it sometimes used to switch branches or something? Perhaps we may need to rename it to avoid confusion but it can wait until we actually decide to make it externally available. Until then, it's OK as-is, I would think.

>  		ret = finish_rebase(&options);
>  		goto cleanup;
>  	}
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin
Message 12 of 14 in “Assorted fixes revolving around rebase and merges”
  1. 0/5 Assorted fixes revolving around rebase and mergesJohannes Schindelin via GitGitGadget, Nov 12, 2018
  2. 1/5 rebase -r: demonstrate bug with conflicting mergesJohannes Schindelin via GitGitGadget, Nov 12, 2018
  3. Junio C HamanoNov 13, 2018
  4. Johannes SchindelinNov 13, 2018
  5. Junio C HamanoNov 13, 2018
  6. Johannes SchindelinNov 13, 2018
  7. Junio C HamanoNov 13, 2018
  8. 2/5 rebase -r: do not write MERGE_HEAD unless neededJohannes Schindelin via GitGitGadget, Nov 12, 2018
  9. 3/5 rebase -i: include MERGE_HEAD into files to clean upJohannes Schindelin via GitGitGadget, Nov 12, 2018
  10. Junio C HamanoNov 13, 2018
  11. 4/5 built-in rebase --skip/--abort: clean up stale .git/<name> filesJohannes Schindelin via GitGitGadget, Nov 12, 2018
  12. Junio C HamanoNov 13, 2018
  13. Johannes SchindelinNov 13, 2018
  14. 5/5 status: rebase and merge can be in progress at the same timeJohannes Schindelin via GitGitGadget, Nov 12, 2018

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.