Article View: linux.kernel.git
Article #2124Re: [PATCH v6] builtin/diff-files: convert ad hoc option parsing to parse-options API
From: Junio C Hamano
Date: Mon, 02 Nov 2026 10:01
Date: Mon, 02 Nov 2026 10:01
69 lines
15139 bytes
15139 bytes
Edson <edsonwasswa54@gmail.com> writes:
> -static const char diff_files_usage[] =
> -"git diff-files [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>...]"
> -"\n"
> -COMMON_DIFF_OPTIONS_HELP;
> +static const char * const diff_files_usage[] = {
> + "git diff-files [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>...]",
> + NULL
> +};
The loss of COMMON_DIFF_OPTIONS_HELP here gives us a regression in
the help output ("git diff-files -h"). By replacing the single string
with a string array and passing it to parse_options() or
show_usage_with_options_if_asked(), the COMMON_DIFF_OPTIONS_HELP
macro is omitted.
Since parse_options() or show_usage_with_options_if_asked() only
knows about the options explicitly defined in the diff_files_options[]
array (leaving standard diff options to be parsed by
setup_revisions()), the common diff options (like -p, --stat, and -z)
will no longer be documented when the user runs "git diff-files -h".
You probably could shove COMMON_DIFF_OPTIONS_HELP into OPT_GROUP()
or something that produces static text in the help output to avoid
the regression if you really wanted to, but given that "diff-files"
is plumbing meant for use by scripts, I am not sure how much value
we get by rewriting its command-line parsing. Being able to say
"git diff-files --bas" and get it understood as "--base" is
something we may appreciate if it were a Porcelain command, but is
it worth the hassle for a plumbing? I have to wonder.
Especially when the parsing loop the patch wants to replace ...
> argc = setup_revisions(argc, argv, &rev, NULL);
> - while (1 < argc && argv[1][0] == '-') {
> - if (!strcmp(argv[1], "--base"))
> - rev.max_count = 1;
> - else if (!strcmp(argv[1], "--ours"))
> - rev.max_count = 2;
> - else if (!strcmp(argv[1], "--theirs"))
> - rev.max_count = 3;
> - else if (!strcmp(argv[1], "-q"))
> - options |= DIFF_SILENT_ON_REMOVED;
> - else
> - usage(diff_files_usage);
> - argv++; argc--;
> - }
... is not anything that is ugly or overly hard to understand.
I dunno.
> + argc = parse_options(argc, argv, prefix, diff_files_options,
> + diff_files_usage, 0);
> if (!rev.diffopt.output_format)
> rev.diffopt.output_format = DIFF_FORMAT_RAW;
> rev.diffopt.rotate_to_strict = 1;
> @@ -73,7 +74,7 @@ int cmd_diff_files(int argc,
> if (rev.pending.nr ||
> rev.min_age != -1 || rev.max_age != -1 ||
> 3 < rev.max_count)
> - usage(diff_files_usage);
> + usage_with_options(diff_files_usage, diff_files_options);
>
> /*
> * "diff-files --base -p" should not combine merges because it
Technical Details
Message-ID:
<xmqq8q3blfh1.fsf@gitster.g>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74128-linux-kernel-git=dewy.ruReferences:
<20261029203904.432-1-edsonwasswa54@gmail.com> <20261101192502.1920-1-edsonwasswa54@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74128-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v6] builtin/diff-files: convert ad hoc option parsing to
parse-options API
Date: Mon, 02 Nov 2026 02:01:14 -0800
Organization: Usenet Network
Message-ID: <xmqq8q3blfh1.fsf@gitster.g>
References: <20261029203904.432-1-edsonwasswa54@gmail.com>
<20261101192502.1920-1-edsonwasswa54@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
logging-data="2896916"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jGIaNuVhOspbtU6hcVx5PPm9AN8= sha256:hEQxeSDAmmdGlggrhpEN7+qKLu8v/4QmuBLDpiZbmhw=
sha1:GRfA2QbrdENH99rDrjeFaGvMZgw= sha256:E+zF/xNxC/oG9t6CFMLawzDzAZ+s371ofW9BCKSne8s=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 40396112491; Mon, 2 Nov 2026 13:02:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=pobox.com header.b=HKJUfLEC; dkim=pass (2048-bit key)
header.d=messagingengine.com header.b=UF9Zvmua
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id OVzQYCdrCABA;
Mon, 2 Nov 2026 13:01:59 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74128-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 49C63112496; Mon, 2 Nov 2026 13:01:46 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 2B6D62DC1F; Mon, 2 Nov 2026 10:01:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793613679;
b=Hzog7N7rih5EusFhXTVS8nm7b1xjhLNo4WLFwSmy0BjuT/XGkXI8GsBYFX8Qfv5kfam4
LS8POOzJ7Tr4iHwulMcKlyXlJTplbYdFZivAz0qWB78OSz2DR1SZHnFccuqu+UpxbYV9e
lHnnFPNPwb7bq6S1+kSl1/zeMsonNJWeR3Aklv35IwZKPb+DKfTUQeOUyAjz44URqbWxJ
HKNmBaDia2RtI1Ykdpp0WfWabgnInFdTh3rf/AVYj7lceltC7BklknDrQCCZ0dq7uoTuK
eClgrtv8b7roP/1ThIi/JlIZsZQ8CQsd5vj2c+dtn7MUBkt4Xnr5awQGtQeq4exImtA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793613679;
h=X-Original-To:Received:DMARC-Filter:Received:Received:DKIM-Signature:
DKIM-Signature:X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:
Message-Instance:X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:
X-ME-Proxy:Feedback-ID:Received:From:To:Cc:Subject:In-Reply-To:
References:Date:Message-ID:User-Agent:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type;
bh=uJ1H0wJ/netMRb3XaFQ58EykPiFcsD+EdnN8847+Nyk=;
b=A0NJ1GKG1Nw6FVua8JXmI3PGjg07GttU/cyal98cGAEXZiNnp7AwQPNwndCAMjzheWKZ
42im/v2/YFtl0jh2ZhWl19SauHpPtNfdD0CaS55j5vA0h5TpM6oTLC9Yohg7AJ4+d6v3R
TeotSrJq41/Pe+1Q3qMM5A5yItZJL0eoYIYuesu5b65Qo/3eGbJLIQmIuvOkzo9EtVZ89
gZNpLqYWeYINff5bY0uyfGb79mllirNgekYq6COefnimj2l1X7lR7xTl0/NHcW7gauqDZ
tvuyBqCkscEOwv20lb2Do46fWcz/ndJXcA1rraLZvYTpWgd/BYq5tQDBhKGSmyCsOpg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=HKJUfLEC;
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=UF9Zvmua;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 01A87606A332;
Mon, 2 Nov 2026 10:01:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=HKJUfLEC;
dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=UF9Zvmua
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.144
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793613677;
b=hhOayd9AtY7y0mw52GqDJ+wYRh0NglAd/HNLf1HD5wezBpDW89+zO3Ilu3w5p68I/xVU
ZKhRnWrxF6rq2YCnoDIYqOULgH4U8y9MPcRRfak1Zdf69N9Jf3N37SssN9/NuuBj1cmCE
D8jUIR/mn6NwxepjJ5oyQlDzYMUCXG2sX3tIJyuKnrZp8DvXRic8EYkuu3m9fa9SuNqwF
m/ixUbiN5wj92OqrMC3loREn3lkyD6OLtKd1+9zURKEIcx/cAtP7jH3dw6jeryJnjLbeE
IiHA6W1h7+yUZ2eLY4RNFlKtC9c74AEsVMmRjsfoqGow0SaHL2kFJl/UEvTAklM2CKQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793613677;
h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature:
X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance:
X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:
Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
User-Agent:MIME-Version:Content-Type;
bh=uJ1H0wJ/netMRb3XaFQ58EykPiFcsD+EdnN8847+Nyk=;
b=TSjI/LpahoftxFpTqa+iPClpeAAXGOVBAEemOr30jXlti8uaxU2knU1kHxo0pw2N6BT1
t1pN/LcnrO9EZhYl1IOlKm1aRaC0Zbb40oWL6Q8sgnTNm6s9OhuWluWBO87gz9GqyS6aN
qVUfY1a+p7+zhshmnYYgbn3LOTzTUDClKJfZ/ZUotUK057Kck0vrXnvjc0vE5IUsUbXSG
wQyZm4oX2S5O0WUuW4vqZp/HfAbL59gGh9IMTBFNvAfyJM9dL67W3XYEyZ9EufKmkmMBW
isnMWPGdjYWiKYhqqMmbGXJFZx87A7qvM1IsoCUjC6i5pZX20aghtJSi16jMn/YRk6g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=pobox.com;
spf=pass smtp.mailfrom=pobox.com;
dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm1 header.b=HKJUfLEC;
dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=UF9Zvmua;
arc=none smtp.remote-ip=202.12.124.144
X-Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3DD16606A327
for <git@vger.kernel.org>; Mon, 2 Nov 2026 10:01:17 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3DD16606A327
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46])
by mailfout.stl.internal (Postfix) with ESMTP id 807921D0022D
for <git@vger.kernel.org>; Mon, 2 Nov 2026 05:01:16 -0500 (EST)
X-Received: from phl-frontend-01 ([10.202.2.160])
by phl-compute-06.internal (MEProxy); Mon, 02 Nov 2026 05:01:16 -0500
X-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=fm1; t=1793613676; x=1793700076; bh=uJ1H0wJ/ne
tMRb3XaFQ58EykPiFcsD+EdnN8847+Nyk=; b=HKJUfLECHrWtSOhmZg9kvCugqk
rJY0rxWnoXNGZYMO/wJIuHZ7WKVIhvWj1h8FN4PMXag/5GE+XpWV+CU4/JofJGMN
B5540U5wQ6ljkLo12BA/PNyvxzIYr/0c8HQ3CK+b/tQ52atksTEhYtChOFRnYoVT
PwkIO4ajvhLSPyTH6OkHOtyQXhVG5YkqPyiVhusrW44X/NxBgHWKZsv+g85kWSUZ
/EcHuZwRi0IGXdtrHWWyxXCocaI1fjJatBAysGNtmn3mBTHJ6pjSOJyk6G2slQ/z
MUHtPsEhGdY69bYE9Mfhb8UAPeVq7FlG8ky+x9rPMbsVxmByqfyCBGQ8mpIA==
X-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=fm2; t=
1793613676; x=1793700076; bh=uJ1H0wJ/netMRb3XaFQ58EykPiFcsD+EdnN
8847+Nyk=; b=UF9ZvmuaoSayEcL2tMEt/Z/6k8Pw3EEkgCWFZkb5m/0XJRt+ZvO
Hv09tPCI6KXDuTDIMtT2Zv2GBrDrx603YpCvw841yuaRK/aYl7p8Rc+cD5XyyEkX
bhTnr2fbUfVeiQ5krE8DAdWAvytg6FidsnEG/KKq3TPrcFUmuDXEmOpONnzhYx1m
IRrDf0mHwh7SpSCzT50tdyo/VJlSpECCdd+77UCuuYcdF8DLhqPf3KiapDSVhv3x
4BVCwR9zKebpvBHYKjqT/0HSaUveB7r6MgBYcYeJezzpg04mfSKGHw2s+nLKTfpQ
06AQIMS4AtT4R8d2xo9UbnBcHI0BcoJINFg==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-08;
repo=github.com/dkim2wg/interop; date=2026-10-28; sw=lmtpprox;
action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1793613676; d=pobox.com;
mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
s=fm1:rsa-sha256:ISu4lQC58AzSUGjuebaloK9fa5Si/SJBlzNWvcBljoJC/dl
SM8/OtNN2a2CHlV4ugk/+JN1CtTa0jbY/gZLgonUXRUvJOUwUGS+ELxS6a3tcNCp
RfDFAXvPi9IozDo4lVIoDAoRKwZkD1sq+W3gDfx5JWdIu/XfAf0M/v+eLrIGx/98
UOjVIMoqfo3rw2Ecx6KoHoC+0HwRKzR9nfED5PVW3F7GPts0wt+Pp9bZbeWsul42
VjzRNxsUNvFZWvFELF/rr7MtVSCHJjbJdb5j9xI5gvEnX2SR+p4OrpDa3CRVoSPY
CvXDs3UJP+Apx5yhuzY32SfFaQdTHDbxxH33qJQ==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-08;
repo=github.com/dkim2wg/interop; date=2026-10-28; sw=lmtpprox;
action=mi-m=1; hc=12;
hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id,
mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:YYcHjXto1bZU5eGgdg//0MD2D4uGtWnZpudNaqSQnxw=:TIDLvChv/QOd5PI/oEseIUk4WpR6lwUNLV231f8M5/w=;
X-ME-Sender: <xms:bF_oasnG679NVneI-kCm3xWk1eNaCMNSj8YkHkq83g-ruKDdZuUAzw>
<xme:bF_oajQxGs3HqLvoHirc2M_mP_q_SU4PsXr5VjRiLaf6cJPr19UnU-cA6jPoute73
Wx3WvZXEtwbEKOcdfjZYwZG7omj-ZOfWku0LWNr2vj6p0dCcxNTAg>
X-ME-Received: <xmr:bF_oaoCzyYQVfftWIvYu7iGjVo-53hQKQugblfIxW7D_8KLPfA9I3r9mbmRYmivH4Ekq1QEWfqu9L83psJlE4R3sJB4Nrkf8q3Jc>
X-ME-Proxy-Cause: dmFkZTEpvYP8W1IjmMhdykHQK1UPIYwGyHw1id88TJ7+2U4WQnFZ8hKDaw5k1Kr7mrR3gp
P64FIn5nSX09OMyqpDZYlS2OS04mjlI9VGdtCh+CxUVqALXlmbc4dKtvRJ/EUnL3Ccr9qD
+9AVNAclOLvoxPay1QDrsd8Wb71EsFqmDab/E1bJJ5wmKqlzD8eXBZHsviLe/c4sjMxYrb
tntGydE6wibQ8KqDhGWDhNh3BCJRgWDXu2Bh33syUu/9iLWQEZMsPUa7Gmjtch1Eo9WlM6
CFOc8bJkyGjp9dv134mYSsbLxr3xQp34Xd1+zyT4sOBDhCTti4LO5fHXz7tqHvCV1h8MFm
buGZnVFOfKoaVeWtx/MQLN+xj9nWjeRZetgyiwDYozRi1s/XoziAArzHnbd01MifzfDZw5
umrHvooWh9lecZks8piPwcWfxtBqZr5oTz4BJRi6wDf5zsC3TWKKq6J5cRzwQ+G9gbd8+d
1d8a8K99MCxzK4hqbM+qhXsRqTb/QC/sbmo1RDHGuPWadrpSwjvQU3ER8qalPbiKzCKvfi
YEL/j+8hL9yHHbE6oTWwZhyHayigxedUTZUXhwmi+eBIJuBKv2KIM7MFgklqLF+NXMfn2M
04ExAneoDqWVI8r/LOdcF40TG6XqndeojwosjnEhErwbxlK2bIOdVp40WBgQ
X-ME-Proxy: <xmx:bF_oaiTx8CPeQmNTjA2y-ucrEsHE-UXvTn3vItY2eSqn3oY2AJuRKQ>
<xmx:bF_oaup_zrVcH3P90RsNuQgiYWy6uFUX_LZ-WW_oCw9vsOshphDfpw>
<xmx:bF_oaswzItJ2jDxo8QKit0aAdv6ZS4psVirgct528-Lo8UghiCRUOQ>
<xmx:bF_oarJf_EjOITLV3buG47Ppk8jqfNCwe46pPisA_WsNTpdT-DH3aw>
<xmx:bF_oanTkyVlZ5G8ZxKcYsfVf2rsueYS_w23e-kiufbvOhCgRsJppKVFj>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
2 Nov 2026 05:01:15 -0500 (EST)
X-Cc: git@vger.kernel.org
X-In-Reply-To: <20261101192502.1920-1-edsonwasswa54@gmail.com> (Edson's message
of "Sun, 1 Nov 2026 22:25:01 +0300")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list