From: Junio C Hamano <gitster@pobox.com>
To: "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Elijah Newren <newren@gmail.com>
Subject: Re: [PATCH v2 1/2] object-name: fix resolution of object names containing curly braces
Date: Sun, 05 Jan 2025 08:14:06 -0800 [thread overview]
Message-ID: <xmqqmsg52q7l.fsf@gitster.g> (raw)
In-Reply-To: <13f68bebe90549ba19452f12abb6fea41c2517fb.1735949870.git.gitgitgadget@gmail.com> (Elijah Newren via GitGitGadget's message of "Sat, 04 Jan 2025 00:17:49 +0000")
"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Given a branch name of 'foo{bar', commands like
>
> git cat-file -p foo{bar:README.md
>
> should succeed (assuming that branch had a README.md file, of course).
> However, the change in cce91a2caef9 (Change 'master@noon' syntax to
> 'master@{noon}'., 2006-05-19) presumed that curly braces would always
> come after an '@' or '^' and be paired, causing e.g. 'foo{bar:README.md'
> to entirely miss the ':' and assume there's no object being referenced.
> In short, git would report:
>
> fatal: Not a valid object name foo{bar:README.md
Naïvely, it seems that a solution is to parse from left to right,
i.e., (1) notice there is a colon, (2) see if everything before that
colon resolves to a treeish, and (3) see if everything after it is a
path that appears in the treeish.
- When we are given foo@{some:thing}, if we did that, we realize
that "foo@{some" is not a valid tree-ish object name (since "@{"
cannot appear in a refname) and then can backtrack by realizing
"foo" is a ref, and @{...} could be a reflog reference (most
likely a way to spell some sort of timestamp), and try that.
- Similarly, for foo:path-gaffed, we would notice "foo" is a valid
tree-ish object name, and if path-gaffed is a path in it, we'd be
happy. Or foo may not be a tree-ish, or path-gaffed may not
exist in that tree-ish. In which case, we can backtrack and see
foo:path-g is an allowed prefix in a desribe name.
Now in the above description, I have assumed that an alternative
interpretation kicks in only as a fallback when we backtrack, but
we could make sure we try all possibilities and notice ambiguity if
we wanted to.
In any case, such an updated structure of the parsing code paths
(whether alternative interpretations are treated as fallbacks or
equally plausible candidates subject to disambiguation) would be
a vast departure from what we currently have, so a targeted "fix"
like these two patches attempt would be more appropriate as an
initial approach, I think.
Thanks, will queue, but probably we'd look at in any seriousness
after the 2.48 final gets tagged.
next prev parent reply other threads:[~2025-01-05 16:14 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-01 2:53 [PATCH] object-name: fix resolution of object names containing curly braces Elijah Newren via GitGitGadget
2025-01-01 17:00 ` Junio C Hamano
2025-01-03 23:34 ` Elijah Newren
2025-01-04 2:52 ` Junio C Hamano
2025-01-03 8:16 ` Patrick Steinhardt
2025-01-03 15:46 ` Junio C Hamano
2025-01-03 23:43 ` Elijah Newren
2025-01-04 0:17 ` [PATCH v2 0/2] " Elijah Newren via GitGitGadget
2025-01-04 0:17 ` [PATCH v2 1/2] " Elijah Newren via GitGitGadget
2025-01-04 17:26 ` Junio C Hamano
2025-01-04 18:54 ` Elijah Newren
2025-01-05 16:14 ` Junio C Hamano [this message]
2025-01-04 0:17 ` [PATCH v2 2/2] object-name: be more strict in parsing describe-like output Elijah Newren via GitGitGadget
2025-01-04 14:35 ` [PATCH v2 0/2] object-name: fix resolution of object names containing curly braces Junio C Hamano
2025-01-04 15:55 ` Elijah Newren
2025-01-04 17:51 ` Junio C Hamano
2025-01-04 18:55 ` Elijah Newren
2025-01-06 17:29 ` Junio C Hamano
2025-01-06 19:26 ` Elijah Newren
2025-01-06 20:38 ` Junio C Hamano
2025-01-13 17:13 ` [PATCH v3 0/2] object-name: fix a pair of object name resolution issues Elijah Newren via GitGitGadget
2025-01-13 17:13 ` [PATCH v3 1/2] object-name: fix resolution of object names containing curly braces Elijah Newren via GitGitGadget
2025-01-13 17:13 ` [PATCH v3 2/2] object-name: be more strict in parsing describe-like output Elijah Newren via GitGitGadget
2025-01-13 18:15 ` [PATCH v3 0/2] object-name: fix a pair of object name resolution issues Junio C Hamano
2025-01-13 19:26 ` Elijah Newren
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=xmqqmsg52q7l.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=newren@gmail.com \
--cc=ps@pks.im \
/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).