From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b2-smtp.messagingengine.com (fhigh-b2-smtp.messagingengine.com [202.12.124.153]) (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 DAE2D3DD84C for ; Wed, 23 Sep 2026 17:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.153 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790184331; cv=none; b=lvQXhUk7QAZ2wseT8+trnChxY3NQEI8iN/zDDS+mJ2D9U3pgD+E2UMUYNcVmVoTpGNwRlIGeKfrMP/o3f9YSNC4V6d1LskYBqXky3o8V2tJqAatoQsaY5g+DXfp3wdEYGm7vYzu619DeudD6YbqRHSZSz6V2hP/QBi+gt17XXPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790184331; c=relaxed/simple; bh=sSRdcjXRSQvICkmohY7As2xnrtjJzH+FWezI3MCZD6U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=W/7Xyh27psfc1s/tpFEXP+ShqpecM7jDk1/MNDb0jl/otWHF3QNOJCgNjXqeS4Hr/j9ujOBHRqARhqo9TnOj5fg4ueBTZ+5c+7PyMOr7RKfruBJD5l7zvpIcQQvQYQFnC8kxw9f7sALtWYOGaKd64CsmwfX9kUYZwRBQBVd32RM= 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=LzR0dHUx; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=xSBpM+cY; arc=none smtp.client-ip=202.12.124.153 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="LzR0dHUx"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="xSBpM+cY" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id EC2D37A0108; Wed, 23 Sep 2026 13:25:28 -0400 (EDT) Received: from phl-frontend-01 ([10.202.2.160]) by phl-compute-06.internal (MEProxy); Wed, 23 Sep 2026 13:25:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1790184328; x=1790270728; bh=NVPv96PZks 9Y6dOgqnb2TN4PMHQicHk00zw3ubsp6Xs=; b=LzR0dHUxNZ1sqHbR5Y72DiNYFD g3QgmpkfbHT9NboHV3YYaUYZjvNEMQpDu6ngwEZGdE8/sbw3VWMSWE5RxZn+KEQC eRhcIuMbCqpdhZBapqUzBt9TKEb+8o1xz4W1wz3wQw9QFItiTYsZ9rJmrBeEhPtD rIGacyX1Dwn7iRQQLwibWiA//GJyO0Eh9tSyibxEQvNG2V2xNx9N+rPsiAx9B0IA u+uF1r+fmMAHj9ESMSv4i0Szh6gmgHLefHIoVbl+H4oRjtVQcFYdEE1wQBUmK+0x VAts39h63DXIp6lTgvWT8MwTgndKyRjdTxnd45UqWWHLYtXE8iqFGrNzv/9Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type: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=fm1; t= 1790184328; x=1790270728; bh=NVPv96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hPvx1meR2hLQ8Un7IUSXZpIIrWR9o0ReBb7lnBAAnuQPNq1Y3BIw X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 23 Sep 2026 13:25:27 -0400 (EDT) From: Junio C Hamano To: Christian Couder Cc: git@vger.kernel.org, Patrick Steinhardt , Elijah Newren , Jeff King , "brian m . carlson" , Johannes Schindelin , Justin Tobler Subject: Re: [PATCH 1/6] parse-options: add early_scan_options() In-Reply-To: (Christian Couder's message of "Wed, 23 Sep 2026 10:10:37 +0200") References: <20260902161047.476753-1-christian.couder@gmail.com> <20260902161047.476753-2-christian.couder@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Wed, 23 Sep 2026 10:25:26 -0700 Message-ID: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Christian Couder writes: > Whether the next argument has to be skipped is decided by the caller: > > if (parse_options_takes_argument(opt) && !value && i + 1 < argc) > value = argv[++i]; > > find_early_scan_option() cannot do that itself, as it has neither > argv, argc nor the current index. > > So signalling to the caller would be redundant, because the caller > already holds the matched option and can ask directly. > > But maybe I should add a comment on the line before `if (!*rest) {` > saying that skipping a separate value is the caller's job? Not really. I was hinting if it is cleaner to have the callee do the skipping so that caller does not have to worry about it. After all, the job of the early-scan machinery is to scan the options reliably to find something later in the command line argument array. The less the caller needs to do, the easier the machinery is to use. >> > + /* Only an option taking a value can be stuck to one. */ >> > + if (*rest == '=' && options->takes_value) { >> > + *value = rest + 1; >> > + return options; >> > + } >> >> And if the option[] table had "opt", then "--option" on the command >> line may begin with "--opt" but "ion" is an excess that is not a >> stuck value, so we do not consider it as a match. OK. > > Now using `takes_value` in the `*rest == '='` case wasn't quite right, > as parse_options_takes_argument() returns 0 for PARSE_OPT_OPTARG and > PARSE_OPT_LASTARG_DEFAULT, but parse_options() does accept a stuck > value for both. > > So in v2 we use the same condition parse_options() uses: My giving an opaque hint pays off sometimes ;-) Thanks.