From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-a1-smtp.messagingengine.com (fout-a1-smtp.messagingengine.com [103.168.172.144]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24872324B0A for ; Sun, 30 Aug 2026 20:48:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.144 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788122923; cv=none; b=U1MtvMXfIJz8nZtZNjZMw3/zr7m/mo7MmGlB7LFUNEvBA9zySxkGUpxwRRqGX3R3rZ1YKYMMoMYRAq9cESGijK6hEf4Gt3jbkh6rhCcPfv3WoCesAjfvs6IJMThVxZzc7kzCjOjBANcNoracW/xfqbvvP3XH+o8BEWOgKNXWwyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788122923; c=relaxed/simple; bh=OpvCDpbJrnfed/kLNghBHhkq5nGstmDnc9ASWaF3x/4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c8OLDp3o3WEiDt0bS4J8kQSAYJu0D/g+X6W0J651vIa5tGvE3RXN1Iyn6eHaLbzL2skgMCdp2c7C7esTkyxGE/M2DTRy2Tbpcrk3WnklWTJMFrxeTRfh/aFUOZLyPEuNaAwukGddtY33NMa4ATtTRXwB22SMv5oimcR3Xj7rOkk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=FsXrCJRO; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=WFYSdpRf; arc=none smtp.client-ip=103.168.172.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="FsXrCJRO"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="WFYSdpRf" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 49FFFEC0086; Sun, 30 Aug 2026 16:48:41 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-04.internal (MEProxy); Sun, 30 Aug 2026 16:48:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1788122921; x= 1788209321; bh=d1mg2z1xxkFF2Wy4QgDQXdsB0JQM14Qgskg1Gb389J4=; b=F sXrCJROLaebZvPClQlxqBk1wRNBIlZ+Lu7hu3HUqFPlKYOtGcntXmBLhpXFlk3DM WAal0hYf+XRaM+m+H8HYIanyATJEDPgvnxXQJsRHPP5xa06eegyplPqMP34mc2Hw g/9KK9ApVAggSab1qBCfpFUXWPDoWsuYmLf1DiTHxIfCgg+HyK/4nuoxWzb51h9b HZ1ljYtRpf5qyB0xjNtsFX0segu9F/hBtZrRjT8pR3pumwMWrYTj2ZvdgpuBtajZ nvsLsuX4PPEqMzi9gWP2JAHS/aifWHivVoPctU9lK7+tSVseP0HTFzaldyt4hnIa i5iho6SbTxWUjaeErZeZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1788122921; x=1788209321; bh=d1mg2z1xxkFF2Wy4QgDQXdsB0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ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 30 Aug 2026 16:48:40 -0400 (EDT) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH v2 3/8] checkout: validate stage and merge option compatibility in checkout_paths() Date: Sun, 30 Aug 2026 13:48:30 -0700 Message-ID: <20260830204835.1040408-4-gitster@pobox.com> X-Mailer: git-send-email 2.55.0-884-g76cf8659c2 In-Reply-To: <20260830204835.1040408-1-gitster@pobox.com> References: <20260828225206.310500-1-gitster@pobox.com> <20260830204835.1040408-1-gitster@pobox.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In checkout_main(), checking that no more than one of --ours/--theirs, --force, and --merge is specified is performed when pathspecs are present, before dispatching to checkout_paths(). Checking out a branch does not use index stages, so this validation belongs in checkout_paths(). Move the incompatibility check from checkout_main() into checkout_paths(). Signed-off-by: Junio C Hamano --- builtin/checkout.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 14542626e9..e3d23256e2 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -591,6 +591,10 @@ static int checkout_paths(const struct checkout_opts *opts, die(_("'%s', '%s', or '%s' cannot be used when checking out of a tree"), "--merge", "--ours", "--theirs"); + if (1 < !!opts->writeout_stage + !!opts->force + !!opts->merge) + die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\n" + "checking out of the index.")); + if (opts->patch_mode) { enum add_p_mode patch_mode; struct interactive_options interactive_opts = { @@ -2063,11 +2067,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix, opts->pathspec.recursive = 1; - if (opts->pathspec.nr) { - if (1 < !!opts->writeout_stage + !!opts->force + !!opts->merge) - die(_("git checkout: --ours/--theirs, --force and --merge are incompatible when\n" - "checking out of the index.")); - } else { + if (!opts->pathspec.nr) { if (opts->accept_pathspec && !opts->empty_pathspec_ok && !opts->patch_mode) /* patch mode is special */ die(_("you must specify path(s) to restore")); -- 2.55.0-884-g76cf8659c2