git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] Update :/abc ambiguity check

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 21, 2013, 19:27 UTC
Message-ID
<7vsj5ufia6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1358773249-24384-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
Show 14 quoted lines
> :/abc may mean two things:
>
> - as a revision, it means the revision that has "abc" in commit
>   message.
>
> - as a pathpec, it means "abc" from root.
>
> Currently we see ":/abc" as a rev (most of the time), but never see it
> as a pathspec even if "abc" exists and "git log :/abc" will gladly
> take ":/abc" as rev even it's ambiguous. This patch makes it:
>
> - ambiguous when "abc" exists on worktree
> - a rev if abc does not exist on worktree
> - a path if abc is not found in any commits (although better use

The "any commits" above sounds very scary. Are you really going to check against all the commits?

Show 6 quoted lines
>   "--" to avoid ambiguation because searching through commit DAG is
>   expensive)
>
> A plus from this patch is, because ":/" never matches anything as a
> rev, it is never considered a valid rev and because root directory
> always exists, ":/" is always unambiguously seen as a pathspec.
That is the primary plus in practice, I think, and it is a big one.

When naming a directory that belongs to a different subdirectory hierarchy, typing ":/that/directory/name" is not any easier than having your shell help you complete "../../that/directory/name"; I suspect nobody uses the relative-to-root notation to name anything but the root in real life.

Previous: Nguyễn Thái Ngọc DuyNext: Duy Nguyen
Message 3 of 5 in “Update :/abc ambiguity check”
  1. 1/2 Update :/abc ambiguity checkNguyễn Thái Ngọc Duy, Jan 21, 2013
  2. 2/2 grep: avoid accepting ambiguous revisionNguyễn Thái Ngọc Duy, Jan 21, 2013
  3. Junio C HamanoJan 21, 2013
  4. Duy NguyenJan 22, 2013
  5. Junio C HamanoJan 22, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.