{"thread":{"id":"32190","subject":"Query for certain branches, but not the rest","startedAt":"2012-11-25T09:24:59Z","lastAt":"2012-11-28T01:57:14Z","messageCount":2,"participants":["Felipe Contreras","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"203784","messageId":"CAMP44s02=E3imOv00dwyXR13nQdo1XeZTjJb_y0EVQoyYMEcQw@mail.gmail.com","threadId":"32190","inReplyTo":null,"subject":"Query for certain branches, but not the rest","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2012-11-25T09:24:59Z","receivedAt":"2012-11-25T09:24:59Z","isPatch":false,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nSuppose I have these branches:\n\n  fc/feature-a\n  fc/feature-b\n  master\n  next\n\nI want to show this: fc/feature-a fc/feature-b ^master ^next. I can do\n'git log --branches=fc' to show the branches that begin with fc/, but\nthere's no way to specify the rest. If they were under a prefix, I\ncould do '--not --branches=prefix', but they are not.\n\nAnybody knows a way to query branches that don't have any prefix?\n\nIt appears this works:\n\n% git for-each-ref refs/heads/*\n\nBut I would like something parsable by rev-parse.\n\nAny ideas?\n\nCheers.\n\n-- \nFelipe Contreras\n"},{"id":"204094","messageId":"20121128015714.GB23776@sigill.intra.peff.net","threadId":"32190","inReplyTo":"CAMP44s02=E3imOv00dwyXR13nQdo1XeZTjJb_y0EVQoyYMEcQw@mail.gmail.com","subject":"Re: Query for certain branches, but not the rest","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-11-28T01:57:14Z","receivedAt":"2012-11-28T01:57:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 25, 2012 at 10:24:59AM +0100, Felipe Contreras wrote:\n\n> Suppose I have these branches:\n> \n>   fc/feature-a\n>   fc/feature-b\n>   master\n>   next\n> \n> I want to show this: fc/feature-a fc/feature-b ^master ^next. I can do\n> 'git log --branches=fc' to show the branches that begin with fc/, but\n> there's no way to specify the rest. If they were under a prefix, I\n> could do '--not --branches=prefix', but they are not.\n> \n> Anybody knows a way to query branches that don't have any prefix?\n\nI don't think there is a way. `--branches` can take a pattern (and there\nis always `--glob`), but we do not pass FNM_PATHNAME to fnmatch, so \"*\"\nwill match across `/` boundaries.\n\nYou are stuck with:\n\n  git log --branches=fc --not $(\n    git for-each-ref --format='%(refname:short)' refs/heads |\n    grep -v /\n  )\n\nwhich is at least robust due to the restrictions on refnames (i.e., no\nwhitespace).\n\nAs an aside, I noticed that:\n\n  git log --branches=does-not-exist\n\nwill see that we matched no refs and fall back to showing HEAD. That\nseems a bit surprising to me.\n\n-Peff\n"}]}