git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* question re: git show-ref and matching ref patterns from the front
@ 2021-04-11  1:24 Chris Jerdonek
  2021-04-11  1:54 ` brian m. carlson
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Jerdonek @ 2021-04-11  1:24 UTC (permalink / raw)
  To: git

Hi, I noticed that git-show-ref only seems to permit matching patterns
from the end of a ref name:
https://git-scm.com/docs/git-show-ref#Documentation/git-show-ref.txt-ltpatterngt82308203
For example, "git show-ref master" will include both
"refs/heads/master" and "refs/remotes/origin/master".

However, is there a way to limit Git to showing refs starting with a
prefix, and that doesn't also require Git to iterate over all refs?

It seems like that would be natural and useful e.g. for repos with
many refs and/or repos with namespaces. Am I missing something, or
would that be a useful addition?

Thanks,
--Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question re: git show-ref and matching ref patterns from the front
  2021-04-11  1:24 question re: git show-ref and matching ref patterns from the front Chris Jerdonek
@ 2021-04-11  1:54 ` brian m. carlson
  2021-04-11  2:09   ` Chris Jerdonek
  0 siblings, 1 reply; 3+ messages in thread
From: brian m. carlson @ 2021-04-11  1:54 UTC (permalink / raw)
  To: Chris Jerdonek; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

On 2021-04-11 at 01:24:57, Chris Jerdonek wrote:
> Hi, I noticed that git-show-ref only seems to permit matching patterns
> from the end of a ref name:
> https://git-scm.com/docs/git-show-ref#Documentation/git-show-ref.txt-ltpatterngt82308203
> For example, "git show-ref master" will include both
> "refs/heads/master" and "refs/remotes/origin/master".
> 
> However, is there a way to limit Git to showing refs starting with a
> prefix, and that doesn't also require Git to iterate over all refs?
> 
> It seems like that would be natural and useful e.g. for repos with
> many refs and/or repos with namespaces. Am I missing something, or
> would that be a useful addition?

I believe you can do this with git for-each-ref.  It accepts prefixes,
and assuming you don't use a case-insensitive comparison, it will
restrict itself to iterating over only those prefixes you specify, not
all refs.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question re: git show-ref and matching ref patterns from the front
  2021-04-11  1:54 ` brian m. carlson
@ 2021-04-11  2:09   ` Chris Jerdonek
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Jerdonek @ 2021-04-11  2:09 UTC (permalink / raw)
  To: brian m. carlson, git

On Sat, Apr 10, 2021 at 6:54 PM brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2021-04-11 at 01:24:57, Chris Jerdonek wrote:
> > However, is there a way to limit Git to showing refs starting with a
> > prefix, and that doesn't also require Git to iterate over all refs?
>
> I believe you can do this with git for-each-ref.  It accepts prefixes,
> and assuming you don't use a case-insensitive comparison, it will
> restrict itself to iterating over only those prefixes you specify, not
> all refs.

Thanks. One minor difference, though, seems to be that git
for-each-ref doesn't support including the HEAD ref, which you can do
with git-show-ref by passing ---head.

--Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-11  2:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-11  1:24 question re: git show-ref and matching ref patterns from the front Chris Jerdonek
2021-04-11  1:54 ` brian m. carlson
2021-04-11  2:09   ` Chris Jerdonek

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).