Subject: Re: [PATCH v6 07/27] checkout: inform the user when removing branch state

From: Duy Nguyen <[email-masked]>
Date: Tue, 2 Jul 2019 16:03:09 +0700

On Tue, Jul 02, 2019 at 10:06:11AM +0200, SZEDER Gábor wrote:
> On Fri, Mar 29, 2019 at 05:38:59PM +0700, Nguyễn Thái Ngọc Duy wrote:
> > After a successful switch, if a merge, cherry-pick or revert is ongoing,
> > it is canceled. This behavior has been with us from the very early
> > beginning, soon after git-merge was created but never actually
> > documented [1]. It may be a good idea to be transparent and tell the
> > user if some operation is canceled.
> 
> After this entered 'next' last week, today it greeted me with 167(!)
> of these warnings...  before I even had my breakfast.
> 
> Now, my script does a lot of repeated cherry-picks and expects that
> rerere is able to deal with most of the conflicts, i.e. it does
> approximately this:
> 
>   if ! git cherry-pick $oid >/dev/null 2>&1
>   then
>       if was_the_conflict_resolved
>       then
>           echo "using previous conflict resolution"
>           git commit --no-edit --cleanup=strip --quiet
>       else
>           die "uh-oh"
>       fi
>   fi
> 
> That 'git commit' in there always prints:
> 
>   warning: cancelling a cherry picking in progress
> 
> I don't understand why committing after a cherry-pick is considered
> "cancelling"...  in my view it's finishing it and there should be no
> warning whatsoever.
> 

I agree, this is not "canceling". I think this series causes conflicts
with pw/clean-sequencer-state-upon-final-commit and the warning is
accidentally enabled (partly my fault since I named the argument
"verbose").

Junio, in this conflict resolution (merging nd/switch-and-restore to
next), we should pass '0' instead of 'verbose' to
sequencer_post_commit_cleanup().

diff --cc builtin/commit.c
index 1921401117,fa5982cc86..145d50caf0
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@@ -1658,7 -1666,8 +1658,7 @@@ int cmd_commit(int argc, const char **a
  		die("%s", err.buf);
  	}
  
- 	sequencer_post_commit_cleanup(the_repository);
 -	unlink(git_path_cherry_pick_head(the_repository));
 -	unlink(git_path_revert_head(the_repository));
++	sequencer_post_commit_cleanup(the_repository, verbose);
  	unlink(git_path_merge_head(the_repository));
  	unlink(git_path_merge_msg(the_repository));
  	unlink(git_path_merge_mode(the_repository));
--
Duy