From patchwork Fri Jul 28 22:06:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junio C Hamano X-Patchwork-Id: 13332703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0ECB2EB64DD for ; Fri, 28 Jul 2023 22:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234392AbjG1WGe (ORCPT ); Fri, 28 Jul 2023 18:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231533AbjG1WGc (ORCPT ); Fri, 28 Jul 2023 18:06:32 -0400 Received: from pb-smtp20.pobox.com (pb-smtp20.pobox.com [173.228.157.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8284D2D73 for ; Fri, 28 Jul 2023 15:06:31 -0700 (PDT) Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 10D122BBDD; Fri, 28 Jul 2023 18:06:31 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:mime-version:content-type; s=sasl; bh=H 9BzX582P3+8SmHGECQJVmL+eUXwdPuYn2G+kcpNS8k=; b=AZ956dppP5NzffNhS yzxKGg0HsqKXQgtnbO0JSBuGX0xvH3yxVMxlH29cFXtXc0LGE1JWvVUfyioJafMs HpMH4qFDgU5t6g2QhQwicj0HeSxZFQI8WgnIAVotgcZkG24Hmb2O7xoA+JIzyJ4Z vb9DnbssTklCzvhCSjQLc/7LIE= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 097DF2BBDC; Fri, 28 Jul 2023 18:06:31 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.168.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 8FD182BBDB; Fri, 28 Jul 2023 18:06:27 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 1/2] checkout/restore: refuse unmerging paths unless checking out of the index Date: Fri, 28 Jul 2023 15:06:26 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Pobox-Relay-ID: FFDA638A-2D92-11EE-B23D-C2DA088D43B2-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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=