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

Re: [PATCH v2 4/4] built-in rebase: call `git am` directly

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 29, 2019, 09:46 UTC
Message-ID
<nycvar.QRO.7.76.6.1901291033180.41@tvgsbejvaqbjf.bet>
In-Reply-To
<dc6830ab-d31c-fb9b-4f8d-24a79a978764@gmail.com>
Hi Alban,
On Sat, 26 Jan 2019, Alban Gruin wrote:
Show 21 quoted lines
> Le 18/01/2019 à 16:09, Johannes Schindelin via GitGitGadget a écrit :
> > -%<-
> > +static int run_am(struct rebase_options *opts)
> > +{
> > -%<-
> > +
> > +	if (!status) {
> > +		return move_to_original_branch(opts);
> > +	}
> > +
> > +	if (is_directory(opts->state_dir))
> > +		write_basic_state(opts);
> > +
> > +	return status;
> > +}
> > +
> 
> This means that the state directory will be created only if there is a
> problem (ie. a conflict), not if the user cancels the rebase by hitting
> ^C.  In this case, the user will be left in a corrupted state where the
> builtin rebase cannot abort the rebase properly.

This is an almost literal translation of https://github.com/git/git/blob/v2.20.1/git-rebase--am.sh#L77-L83:

```sh
if test 0 != $ret
then
        test -d "$state_dir" && write_basic_state
        return $ret
fi

move_to_original_branch ```

All I did was to switch the order to handle the simple (and common) case first.

So I do not think that this changes the behavior of the shell-scripted `am` backend.

Looking at the code, for a moment I thought that I had introduced a bug where the state_dir is not cleaned up after move_to_original_branch() is called, but I call run_am() in run_specific_rebase() and skip directly to the finished_rebase label after that, which does take care of calling finish_rebase() (which removes the state_dir, among other things such as applying the autostash).

Ciao, Dscho

Previous: Alban GruinNext: Junio C Hamano
Message 24 of 27 in “Let the builtin rebase call the git am command directly”
  1. 0/4 Let the builtin rebase call the git am command directlyJohannes Schindelin via GitGitGadget, Dec 21, 2018
  2. 2/4 rebase: avoid double reflog entry when switching branchesJohannes Schindelin via GitGitGadget, Dec 21, 2018
  3. Junio C HamanoJan 4, 2019
  4. Johannes SchindelinJan 18, 2019
  5. 1/4 rebase: move `reset_head()` into a better spotJohannes Schindelin via GitGitGadget, Dec 21, 2018
  6. Junio C HamanoJan 4, 2019
  7. 3/4 rebase: teach `reset_head()` to optionally skip the worktreeJohannes Schindelin via GitGitGadget, Dec 21, 2018
  8. Junio C HamanoJan 4, 2019
  9. Junio C HamanoJan 4, 2019
  10. Johannes SchindelinJan 18, 2019
  11. 4/4 built-in rebase: call `git am` directlyJohannes Schindelin via GitGitGadget, Dec 21, 2018
  12. Junio C HamanoJan 4, 2019
  13. Johannes SchindelinJan 18, 2019
  14. Junio C HamanoJan 18, 2019
  15. Johannes SchindelinJan 18, 2019
  16. Junio C HamanoJan 4, 2019
  17. Junio C HamanoJan 7, 2019
  18. 0/4 Let the builtin rebase call the git am command directlyJohannes Schindelin via GitGitGadget, Jan 18, 2019
  19. 1/4 rebase: move `reset_head()` into a better spotJohannes Schindelin via GitGitGadget, Jan 18, 2019
  20. 2/4 rebase: avoid double reflog entry when switching branchesJohannes Schindelin via GitGitGadget, Jan 18, 2019
  21. 3/4 rebase: teach `reset_head()` to optionally skip the worktreeJohannes Schindelin via GitGitGadget, Jan 18, 2019
  22. 4/4 built-in rebase: call `git am` directlyJohannes Schindelin via GitGitGadget, Jan 18, 2019
  23. Alban GruinJan 26, 2019
  24. Johannes SchindelinJan 29, 2019
  25. Junio C HamanoJan 18, 2019
  26. Junio C HamanoJan 18, 2019
  27. Johannes SchindelinJan 18, 2019

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.