{"thread":{"id":"55474","subject":"question re: git show-ref and matching ref patterns from the front","startedAt":"2021-04-11T01:31:01Z","lastAt":"2021-04-11T02:09:43Z","messageCount":3,"participants":["Chris Jerdonek","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"421560","messageId":"CAOTb1wef2w_H4mwMMwR4En8665GduAMoceL45+OYC4DSBPtozQ@mail.gmail.com","threadId":"55474","inReplyTo":null,"subject":"question re: git show-ref and matching ref patterns from the front","fromName":"Chris Jerdonek","fromEmail":"chris.jerdonek@gmail.com","sentAt":"2021-04-11T01:24:57Z","receivedAt":"2021-04-11T01:31:01Z","isPatch":false,"sender":{"key":"chris.jerdonek@gmail.com","avatar":"https://gravatar.com/avatar/86b2cff752baeaabcfaf26ff30fd8f74c5caf8657fdb7990dc3c787d542f26a3?d=mp&s=160"},"body":"Hi, I noticed that git-show-ref only seems to permit matching patterns\nfrom the end of a ref name:\nhttps://git-scm.com/docs/git-show-ref#Documentation/git-show-ref.txt-ltpatterngt82308203\nFor example, \"git show-ref master\" will include both\n\"refs/heads/master\" and \"refs/remotes/origin/master\".\n\nHowever, is there a way to limit Git to showing refs starting with a\nprefix, and that doesn't also require Git to iterate over all refs?\n\nIt seems like that would be natural and useful e.g. for repos with\nmany refs and/or repos with namespaces. Am I missing something, or\nwould that be a useful addition?\n\nThanks,\n--Chris\n"},{"id":"421563","messageId":"YHJW4xCgw6GN0Rag@camp.crustytoothpaste.net","threadId":"55474","inReplyTo":"CAOTb1wef2w_H4mwMMwR4En8665GduAMoceL45+OYC4DSBPtozQ@mail.gmail.com","subject":"Re: question re: git show-ref and matching ref patterns from the front","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2021-04-11T01:54:43Z","receivedAt":"2021-04-11T02:03:16Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2021-04-11 at 01:24:57, Chris Jerdonek wrote:\n> Hi, I noticed that git-show-ref only seems to permit matching patterns\n> from the end of a ref name:\n> https://git-scm.com/docs/git-show-ref#Documentation/git-show-ref.txt-ltpatterngt82308203\n> For example, \"git show-ref master\" will include both\n> \"refs/heads/master\" and \"refs/remotes/origin/master\".\n> \n> However, is there a way to limit Git to showing refs starting with a\n> prefix, and that doesn't also require Git to iterate over all refs?\n> \n> It seems like that would be natural and useful e.g. for repos with\n> many refs and/or repos with namespaces. Am I missing something, or\n> would that be a useful addition?\n\nI believe you can do this with git for-each-ref.  It accepts prefixes,\nand assuming you don't use a case-insensitive comparison, it will\nrestrict itself to iterating over only those prefixes you specify, not\nall refs.\n-- \nbrian m. carlson (he/him or they/them)\nHouston, Texas, US\n"},{"id":"421564","messageId":"CAOTb1wftqhQSZ8KRyh0hXBE7enM8KG85H-UyxBObnsx8Ff8vvA@mail.gmail.com","threadId":"55474","inReplyTo":"YHJW4xCgw6GN0Rag@camp.crustytoothpaste.net","subject":"Re: question re: git show-ref and matching ref patterns from the front","fromName":"Chris Jerdonek","fromEmail":"chris.jerdonek@gmail.com","sentAt":"2021-04-11T02:09:29Z","receivedAt":"2021-04-11T02:09:43Z","isPatch":false,"sender":{"key":"chris.jerdonek@gmail.com","avatar":"https://gravatar.com/avatar/86b2cff752baeaabcfaf26ff30fd8f74c5caf8657fdb7990dc3c787d542f26a3?d=mp&s=160"},"body":"On Sat, Apr 10, 2021 at 6:54 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2021-04-11 at 01:24:57, Chris Jerdonek wrote:\n> > However, is there a way to limit Git to showing refs starting with a\n> > prefix, and that doesn't also require Git to iterate over all refs?\n>\n> I believe you can do this with git for-each-ref.  It accepts prefixes,\n> and assuming you don't use a case-insensitive comparison, it will\n> restrict itself to iterating over only those prefixes you specify, not\n> all refs.\n\nThanks. One minor difference, though, seems to be that git\nfor-each-ref doesn't support including the HEAD ref, which you can do\nwith git-show-ref by passing ---head.\n\n--Chris\n"}]}