From: Junio C Hamano <gitster@pobox.com>
To: "D. Ben Knoble" <ben.knoble+github@gmail.com>
Cc: git@vger.kernel.org, Noah Pendleton <noah.pendleton@gmail.com>,
Patrick Steinhardt <ps@pks.im>,
Phillip Wood <phillip.wood123@gmail.com>,
Thranur Andul <thranur@gmail.com>,
Michael Grosser <grosser.michael@gmail.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 0/3] Support :(optional) filepaths
Date: Sun, 28 Sep 2025 15:40:17 -0700 [thread overview]
Message-ID: <xmqqh5wm5hgu.fsf@gitster.g> (raw)
In-Reply-To: <cover.1759094936.git.ben.knoble+github@gmail.com> (D. Ben Knoble's message of "Sun, 28 Sep 2025 17:29:13 -0400")
"D. Ben Knoble" <ben.knoble+github@gmail.com> writes:
Before "notes" you would want an overall description of what the
topic is for those who no longer remember the previous iteration,
or for those this iteration is the first one they see.
> Notes:
> - Based on commit 2da08f2c3d (parseopt: values of pathname type can be
> prefixed with :(optional), 2024-10-14) (broken-out/wip/optional-path)
> - Rebased on v2.51.0
Thanks.
> - I'm least sure of the 3rd patch and am happy to drop it in support of
> the first 2. I think it might be better to (a) integrate :(optional)
> support as pathspec magic and (b) use pathspec magic in parse-options
> when getting filenames. But I'm not sure, and this has other
> ramifications I'm not prepared to deal with. (For example: `git grep
> path <file>… :(optional)non-existent` could pretend like
> `non-existent` was never given?)
While it might not hurt, I do not see a need for such a support.
Pathspec _is_ a pattern. If an existing path does not match the
pattern, there is no ill effect. In other words, in this command
invocation:
$ git grep -e needle -- Makefile no-such-file.txt
neither Makefile or no-such-file.txt is required nor optional. If
there are paths that match these two "patterns" among the paths in
the working tree that are known to the index, the contents of these
paths are inspected by the command. If no paths match the patterns,
that is fine as well.
The command line parser helpfully offers to notice a pathspec
pattern that did not match any path when you do not give "--", but
that is up to the caller of match_pathspec() API to do so. The
pathspec machinery only reports if each pathspec element matched a
path in its seen[] array, and the caller can use that information to
report which pathspec elements did not contribute to finding the set
of paths to work on.
> - The parsing is not exactly a "clean API," but I wasn't sure how to
> make it cleaner :)
What you have in [2/3], the update to git_config_pathname(), seems
quite reasonable and something that cannot be made cleaner, to me.
> Changes in v2:
> - Only check for missing files, not empty files
> - Move a test change to the appropriate commit
> - Document optional magic in options in gitcli(1)
I agree that it is a better design not to special case an empty file
like the previous round did. Looking better.
> This series adds support for optional filepaths in config and
> parse-options, which supports use-cases such as missing commit templates
> or blame.ignoreRevsFile values without erroring.
Yes, this is what you wanted to have at the very beginning, before
listing points you want to call attention to under "Notes" label.
Will queue. Thanks for resurrecting the topic.
next prev parent reply other threads:[~2025-09-28 22:40 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-07 20:27 [PATCH 0/1] blame: Skip missing ignore-revs file Noah Pendleton
2021-08-07 20:58 ` Junio C Hamano
2021-08-07 21:34 ` Noah Pendleton
2021-08-08 5:43 ` Junio C Hamano
2021-08-08 17:50 ` Junio C Hamano
2021-08-08 18:21 ` Noah Pendleton
2021-08-09 15:47 ` Junio C Hamano
2024-10-14 20:44 ` [PATCH 0/3] specifying a file that can optionally exist Junio C Hamano
2024-10-14 20:44 ` [PATCH 1/3] t7500: make each piece more independent Junio C Hamano
2024-10-14 20:44 ` [PATCH 2/3] config: values of pathname type can be prefixed with :(optional) Junio C Hamano
2024-10-14 20:44 ` [PATCH 3/3] parseopt: " Junio C Hamano
2025-05-01 21:40 ` [PATCH 0/3] specifying a file that can optionally exist Junio C Hamano
2025-05-01 21:40 ` [PATCH 1/3] t7500: make each piece more independent Junio C Hamano
2025-05-01 21:40 ` [PATCH 2/3] config: values of pathname type can be prefixed with :(optional) Junio C Hamano
2025-05-02 8:52 ` Patrick Steinhardt
2025-05-02 14:28 ` Phillip Wood
2025-05-02 20:05 ` Junio C Hamano
2025-05-01 21:40 ` [PATCH 3/3] parseopt: " Junio C Hamano
2025-09-28 21:29 ` [PATCH v2 0/3] Support :(optional) filepaths D. Ben Knoble
2025-09-28 21:29 ` [PATCH v2 1/3] t7500: make each piece more independent D. Ben Knoble
2025-09-28 21:29 ` [PATCH v2 2/3] config: values of pathname type can be prefixed with :(optional) D. Ben Knoble
2025-09-30 15:26 ` Phillip Wood
2025-10-06 19:00 ` Junio C Hamano
2025-10-06 19:59 ` Junio C Hamano
2025-10-06 20:21 ` Junio C Hamano
2025-10-06 20:22 ` Junio C Hamano
2025-10-07 12:24 ` Kristoffer Haugsbakk
2025-10-07 17:04 ` Junio C Hamano
2025-09-28 21:29 ` [PATCH v2 3/3] parseopt: " D. Ben Knoble
2025-09-30 15:26 ` Phillip Wood
2025-09-28 22:40 ` Junio C Hamano [this message]
2025-09-29 16:42 ` [PATCH v2 0/3] Support :(optional) filepaths Ben Knoble
2022-03-04 9:51 ` [PATCH 0/1] blame: Skip missing ignore-revs file Thranur Andul
2021-08-08 17:48 ` [PATCH v2] blame: add config `blame.ignoreRevsFileIsOptional` Noah Pendleton
-- strict thread matches above, loose matches on Subject: below --
2025-04-25 18:41 Feature request: automatically read .git-blame-ignore-revs or allow global optional config Michael Grosser
2025-04-25 19:54 ` Eric Sunshine
2025-05-01 18:00 ` D. Ben Knoble
2025-05-01 18:28 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqh5wm5hgu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=ben.knoble+github@gmail.com \
--cc=git@vger.kernel.org \
--cc=grosser.michael@gmail.com \
--cc=noah.pendleton@gmail.com \
--cc=phillip.wood123@gmail.com \
--cc=ps@pks.im \
--cc=sunshine@sunshineco.com \
--cc=thranur@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).