From: Junio C Hamano <gitster@pobox.com>
To: "Anselm Schüler" <mail@anselmschueler.com>
Cc: git@vger.kernel.org
Subject: Re: Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form
Date: Wed, 19 Feb 2025 09:11:50 -0800 [thread overview]
Message-ID: <xmqqr03tg8q1.fsf@gitster.g> (raw)
In-Reply-To: <216a7288-b599-4333-ba62-10665d6a94d8@anselmschueler.com> ("Anselm Schüler"'s message of "Wed, 19 Feb 2025 11:49:39 +0100")
Anselm Schüler <mail@anselmschueler.com> writes:
> If you run git diff for a pathspec with an empty magic word/symbol
> list in short form (prefixed by ::) and in long form (prefixed by
> :():), you get different results.
The short form is prefixed by a ":" and optionally ends by a ":",
but the optional termination may not be required when there is no
ambiguity (e.g. ":/!path" is "from the top, not matching "path", as
"p" cannot be a magic signature; ":/:!path" is "from the top,
matching "!path", as the set of magic signatures ends with the
second disambiguating colon).
The long form is prefixed by a ":(" and ends by a ")".
> Here’s an example use of git that illustrates this:
>
> ~☭ mkdir gittest
> ~☭ y gittest/
> ~/gittest☭ git init
> Initialized empty Git repository in /home/anselmschueler/gittest/.git/
> ~/gittest (b0)☭ uuidgen >file
> ~/gittest (b0)☭ git add file && git commit -m "$(read)"
> read> initial commit
> [b0 (root-commit) cd3bd43] initial commit
> 1 file changed, 1 insertion(+)
> create mode 100644 file
> ~/gittest (b0)☭ uuidgen >file
> ~/gittest (b0)☭ git diff -- "::file"
>
> file
> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>
> ───┐
> 1: │
> ───┘
> 66d18ffa-1128-42a5-8d4e-f9d75eb86b92
> 9acea2b5-50a6-4f87-ae1a-64019a93e55e
> ~/gittest (b0)☭ git diff -- ":():file"
> ~/gittest (b0)☭
Doesn't ":():file" ask for a match for the pattern ":file", with a
leading colon?
next prev parent reply other threads:[~2025-02-19 17:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 10:49 Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form Anselm Schüler
2025-02-19 14:28 ` Lucas Oshiro
2025-02-19 17:11 ` Junio C Hamano [this message]
2025-02-24 14:11 ` Anselm Schüler
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=xmqqr03tg8q1.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mail@anselmschueler.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).