From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 9543D3AFAE1 for ; Fri, 28 Aug 2026 22:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787957535; cv=none; b=pqLNc7eD3U99p0FVq5YMV2e85bLYyBwUpMv9JubJKA11FedcNbCGxEhsZJYes8JA9J0Q2pDEDWUnO4LPzEE+lr7d/Xo1ruBULGmdVUdbEprgWbe4YRsSztl73oNZnUt/3tYDu/tPQxQNZMQFHbD7q8ugHPnSeaa/tCRfr8SoKB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787957535; c=relaxed/simple; bh=OpvCDpbJrnfed/kLNghBHhkq5nGstmDnc9ASWaF3x/4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bQ57GRBssnHYUzsPVPU+DTegpjmRBr8v5XlIZQ+UUr+OCHyXOdjnISxgxn6hOMfaeNuhvoW7yt/AZlWGxdxhuAbTDpVytT/sC7x0rDXh835OQp8wnJYzd5Fw1VK5KE4Sc+2bPurRqWZAJsoKqvs63hUzM9GA8hsVu96GJ/15TwE= 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=ssQyp/re; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=T9dg943E; arc=none smtp.client-ip=202.12.124.159 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="ssQyp/re"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="T9dg943E" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id E689D7A0096; Fri, 28 Aug 2026 18:52:12 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-05.internal (MEProxy); Fri, 28 Aug 2026 18:52:13 -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=1787957532; x= 1788043932; bh=d1mg2z1xxkFF2Wy4QgDQXdsB0JQM14Qgskg1Gb389J4=; b=s sQyp/re3P2Fboo8n6mpw8UJ97KVHj2OY/sYFwrGV9Lk1Fb02OKdoZ0u67fP0ehL3 Ig50qRi4Ut2Wd+OxW/4DHdt5kewHfStC97B6FzOjsdFvFR26KiQrSNLh+UfREu3L bFxw9GwyF5EBlYn7TL2DG8i1xuc/iBnRdFEShFfA/f7eb6CkCUBc12W7fRzfd5BU N/MKTsjm+Sk8RTjo7gZ18E4/77v1HXRHy2BjzSVV+NrmdqCqXmOhenzlklyhEGFW lzTM/gd12CZ505vRV2kT3ZpIECIQTUyVkRjSHx0v+kNfCULa7vq05pKch96Wg45O Aid88yu1nMxxq9j1obx7Q== 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=1787957532; x=1788043932; bh=d1mg2z1xxkFF2Wy4Qg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I3zO7NE9kus9e52AxzBnWJIMrvJ0Q X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 Aug 2026 18:52:12 -0400 (EDT) From: Junio C Hamano To: git@vger.kernel.org Subject: [PATCH 3/8] checkout: validate stage and merge option compatibility in checkout_paths() Date: Fri, 28 Aug 2026 15:52:01 -0700 Message-ID: <20260828225206.310500-4-gitster@pobox.com> X-Mailer: git-send-email 2.55.0-884-g76cf8659c2 In-Reply-To: <20260828225206.310500-1-gitster@pobox.com> References: <20260828225206.310500-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