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

Re: [PATCH] rebase: save autostash entry into stash reflog on --quit

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Apr 30, 2020, 09:41 UTC
Message-ID
<c2babcad-d14d-0e06-3897-a3653e72edf6@gmail.com>
In-Reply-To
<353a67567a90aea8a90bce1de05d005c61b3b670.1588066252.git.liu.denton@gmail.com>
Hi Denton
Thanks for working on this, the implementation and test look fine
Best Wishes
Phillip
On 28/04/2020 10:31, Denton Liu wrote:
Show 78 quoted lines
> In a03b55530a (merge: teach --autostash option, 2020-04-07), the
> --autostash option was introduced for `git merge`. Notably, when
> `git merge --quit` is run with an autostash entry present, it is saved
> into the stash reflog. This is contrasted with the current behaviour of
> `git rebase --quit` where the autostash entry is simply just dropped out
> of existence.
> 
> Adopt the behaviour of `git merge --quit` in `git rebase --quit` and
> save the autostash entry into the stash reflog instead of just deleting
> it.
> 
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
> 
> Notes:
>     This patch is based on 'dl/merge-autostash'.
> 
>  Documentation/git-rebase.txt |  3 ++-
>  builtin/rebase.c             |  1 +
>  t/t3420-rebase-autostash.sh  | 20 ++++++++++++++++++++
>  3 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
> index f7a6033607..7d0c89a184 100644
> --- a/Documentation/git-rebase.txt
> +++ b/Documentation/git-rebase.txt
> @@ -256,7 +256,8 @@ See also INCOMPATIBLE OPTIONS below.
>  --quit::
>  	Abort the rebase operation but HEAD is not reset back to the
>  	original branch. The index and working tree are also left
> -	unchanged as a result.
> +	unchanged as a result. If a temporary stash entry was created
> +	using --autostash, it will be saved to the stash reflog.>  --apply:
>  	Use applying strategies to rebase (calling `git-am`
> diff --git a/builtin/rebase.c b/builtin/rebase.c
> index bc4fc69906..71aec532b1 100644
> --- a/builtin/rebase.c
> +++ b/builtin/rebase.c
> @@ -1556,6 +1556,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
>  		goto cleanup;
>  	}
>  	case ACTION_QUIT: {
> +		save_autostash(state_dir_path("autostash", &options));
>  		if (options.type == REBASE_MERGE) {
>  			struct replay_opts replay = REPLAY_OPTS_INIT;
>  
> diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
> index b97ea62363..ca331733fb 100755
> --- a/t/t3420-rebase-autostash.sh
> +++ b/t/t3420-rebase-autostash.sh
> @@ -184,6 +184,26 @@ testrebase () {
>  		git checkout feature-branch
>  	'
>  
> +	test_expect_success "rebase$type: --quit" '
> +		test_config rebase.autostash true &&
> +		git reset --hard &&
> +		git checkout -b rebased-feature-branch feature-branch &&
> +		test_when_finished git branch -D rebased-feature-branch &&
> +		echo dirty >>file3 &&
> +		git diff >expect &&
> +		test_must_fail git rebase$type related-onto-branch &&
> +		test_path_is_file $dotest/autostash &&
> +		test_path_is_missing file3 &&
> +		git rebase --quit &&
> +		test_when_finished git stash drop &&
> +		test_path_is_missing $dotest/autostash &&
> +		! grep dirty file3 &&
> +		git stash show -p >actual &&
> +		test_cmp expect actual &&
> +		git reset --hard &&
> +		git checkout feature-branch
> +	'
> +
>  	test_expect_success "rebase$type: non-conflicting rebase, conflicting stash" '
>  		test_config rebase.autostash true &&
>  		git reset --hard &&
> 
Previous: Phillip Wood
Message 5 of 5 in “rebase: save autostash entry into stash reflog on --quit”
  1. rebase: save autostash entry into stash reflog on --quitDenton Liu, Apr 28, 2020
  2. Junio C HamanoApr 28, 2020
  3. Denton LiuApr 29, 2020
  4. Phillip WoodApr 30, 2020
  5. Phillip WoodApr 30, 2020

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.