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

Re: [PATCH 2/2] cherry-pick: fix --quit not deleting CHERRY_PICK_HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 15, 2018, 17:26 UTC
Message-ID
<xmqqpnyjilrd.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180815162308.17747-2-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 10 quoted lines
> --quit is supposed to be --abort but without restoring HEAD. Leaving
> CHERRY_PICK_HEAD behind could make other commands mistake that
> cherry-pick is still ongoing (e.g. "git commit --amend" will refuse to
> work). Clean it too.
>
> For abort, this job of deleting CHERRY_PICK_HEAD is on "git reset" so
> we don't need to do anything else.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---

Please do not hide this bugfix behind 1/2 that is likely to require longer to cook than the fix itself. And more importantly, it makes it impossible to merge down the fix to the maintenance track, as I do not think we'd want to merge 1/2 there.

Thanks.
Show 45 quoted lines
>  builtin/revert.c                | 9 +++++++--
>  t/t3510-cherry-pick-sequence.sh | 3 ++-
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/revert.c b/builtin/revert.c
> index 76f0a35b07..e94a4ead2b 100644
> --- a/builtin/revert.c
> +++ b/builtin/revert.c
> @@ -7,6 +7,7 @@
>  #include "rerere.h"
>  #include "dir.h"
>  #include "sequencer.h"
> +#include "branch.h"
>  
>  /*
>   * This implements the builtins revert and cherry-pick.
> @@ -191,8 +192,12 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
>  	opts->gpg_sign = xstrdup_or_null(opts->gpg_sign);
>  	opts->strategy = xstrdup_or_null(opts->strategy);
>  
> -	if (cmd == 'q')
> -		return sequencer_remove_state(opts);
> +	if (cmd == 'q') {
> +		int ret = sequencer_remove_state(opts);
> +		if (!ret)
> +			remove_branch_state(the_repository);
> +		return ret;
> +	}
>  	if (cmd == 'c')
>  		return sequencer_continue(opts);
>  	if (cmd == 'a')
> diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh
> index 3505b6aa14..9d121f8ce6 100755
> --- a/t/t3510-cherry-pick-sequence.sh
> +++ b/t/t3510-cherry-pick-sequence.sh
> @@ -103,7 +103,8 @@ test_expect_success '--quit cleans up sequencer state' '
>  	pristine_detach initial &&
>  	test_expect_code 1 git cherry-pick base..picked &&
>  	git cherry-pick --quit &&
> -	test_path_is_missing .git/sequencer
> +	test_path_is_missing .git/sequencer &&
> +	test_path_is_missing .git/CHERRY_PICK_HEAD
>  '
>  
>  test_expect_success '--quit keeps HEAD and conflicted index intact' '
Previous: Stefan BellerNext: Duy Nguyen
Message 6 of 18 in “branch.c: remove explicit reference to the_repository”
  1. 1/2 branch.c: remove explicit reference to the_repositoryNguyễn Thái Ngọc Duy, Aug 15, 2018
  2. 2/2 cherry-pick: fix --quit not deleting CHERRY_PICK_HEADNguyễn Thái Ngọc Duy, Aug 15, 2018
  3. Stefan BellerAug 15, 2018
  4. Duy NguyenAug 15, 2018
  5. Stefan BellerAug 15, 2018
  6. Junio C HamanoAug 15, 2018
  7. Duy NguyenAug 15, 2018
  8. Junio C HamanoAug 15, 2018
  9. cherry-pick: fix --quit not deleting CHERRY_PICK_HEADNguyễn Thái Ngọc Duy, Aug 16, 2018
  10. Junio C HamanoAug 16, 2018
  11. Elijah NewrenAug 15, 2018
  12. Duy NguyenAug 15, 2018
  13. Stefan BellerAug 15, 2018
  14. Duy NguyenAug 15, 2018
  15. Junio C HamanoAug 15, 2018
  16. Duy NguyenAug 15, 2018
  17. Junio C HamanoAug 15, 2018
  18. Duy NguyenAug 15, 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.