Re: [PATCH v2 5/5] checkout: fix interaction between --conflict and --merge
From: Junio C Hamano <hidden>
Date: 2024-03-14 17:32:46
"Phillip Wood via GitGitGadget" [off-list ref] writes:
From: Phillip Wood <redacted> When using "git checkout" to recreate merge conflicts or merge uncommitted changes when switching branch "--conflict" sensibly implies "--merge". Unfortunately the way this is implemented means that "git checkout --conflict=diff3 --no-merge" implies "--merge" violating the usual last-one-wins rule. Fix this by only overriding the value of opts->merge if "--conflicts" comes after "--no-merge" or "-[-no]-merge" is not given on the command line.
That smells like a convoluted logic but I think I can buy the argument. If "--conflict=diff3" implies "--conflict=diff3 --merge", then "--conflict=diff3 --no-merge" should imply "--conflict=diff3 --merge --no-merge" and the latter two cancels out with the last-one-wins rule, leaving only "--conflict=diff3" that does not imply anything about "--merge". The conflict style specification does not have any effect when we are not recreating any merge, so all of them are ignored in the end. So, it probably makes sense, even though I find it highly confusing. Is it likely that "--conflict=diff3 --no-merge" signals that the user is confused and it is safer to abort the operation before doing further harm, though, I wonder? Thanks.