From: Junio C Hamano Date: Fri, 28 Jul 2023 22:06:26 GMT Subject: [PATCH 1/2] checkout/restore: refuse unmerging paths unless checking out of the index Message-ID: Recreating unmerged index entries using resolve-undo data, recreating conflicted working tree files using unmerged index entries, and writing data out of unmerged index entries, make sense only when we are checking paths out of the index and not when we are checking paths out of a tree-ish. Add an extra check to make sure "--merge" and "--ours/--theirs" options are rejected when checking out from a tree-ish, update the document (especially the SYNOPSIS section) to highlight that they are incompatible, and add a few tests to make sure the combination fails. Signed-off-by: Junio C Hamano --- * We do have proper description of the --merge option in Documentation/git-checkout.txt to cover the operation in both modes of "checkout" (i.e. checking out a branch vs checking out paths), but the parse_options help text only talks about the one that happens when checking out a branch. We might want to do something about it, but I am not sure what the right phrase should be. The options[] array there is created by concatenating common ones, switch-related ones, and restore-related ones, and ideally how the option works in each mode should be decribed in the latter two, but we cannot have duplicate entries in the resulting options[] array, of course, so such an approach would not work well. Documentation/git-checkout.txt | 9 ++++++--- Documentation/git-restore.txt | 4 ++++ builtin/checkout.c | 9 +++++++++ t/t2070-restore.sh | 7 +++++-- t/t7201-co.sh | 5 +++++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 4af0904f47..a30e3ebc51 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -12,8 +12,10 @@ SYNOPSIS 'git checkout' [-q] [-f] [-m] --detach [] 'git checkout' [-q] [-f] [-m] [--detach] 'git checkout' [-q] [-f] [-m] [[-b|-B|--orphan] ] [] -'git checkout' [-f|--ours|--theirs|-m|--conflict=