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

Re: $> git branch splat response considered harmful

From
Philip Oakley <philipoakley@iee.email>
Date
Aug 9, 2019, 18:01 UTC
Message-ID
<5f533351-3d77-3859-fe27-b3d96b0b8b30@iee.email>
In-Reply-To
<CAJoAoZ=K0LhCmnEUk1rsan2J5APzcye7+RryjBG+mKgjGf6qzA@mail.gmail.com>
On 08/08/2019 22:28, Emily Shaffer wrote:
Show 34 quoted lines
> On Thu, Aug 8, 2019 at 2:20 PM Bryan Turner <bturner@atlassian.com> wrote:
>> On Thu, Aug 8, 2019 at 2:08 PM <jim.cromie@gmail.com> wrote:
>>> fwiw,
>>>
>>> jimc@frodo:~/prj-1/capnproto.git$ git branch -l
>>> * master
>>>
>>> I find the splat in the response unhelpful
>>> when wrapped in shell for loop, the splat expands into everything in
>>> current directory
>>>
>>> jimc@frodo:~/prj-1/capnproto.git$ for b in `git branch -l`; do echo $b; done
>>> appveyor.yml
>>> c++
>>> CMakeLists.txt
>>> CONTRIBUTORS
>>> ...
>>>
>>> it would be nice if some flag combo would suppress that splat.
>>> save me from fugly brittle sh $IFS fiddlery and incomplete workarounds
>> Have you tried "git for-each-ref --format="%(refname:short)"
>> refs/heads/"? That's going to provide short names for branches without
>> any indicator for the default branch, and without any special
>> ordering.
> More generally, I think you should take a look at `git help git` and
> check out the difference between "porcelain" and "plumbing" commands.
> The former, of which `git branch` is one, are intended for interactive
> use and not really meant for scripting or piping. You can usually come
> up with an equivalent from the plumbing commands, which Bryan has
> suggested for you with `git for-each-ref`.  Git project tries very
> hard to maintain output format of the plumbing commands so as to not
> break folks' scripts, but such promises aren't usually made for
> porcelain commands.
>

I think this (the broad Q&A) also suggests that the porcelain command documentation could be more helpful for pointing to the appropriate plumbing commands for these scripting issues (and it could reduce list noise..). -- Philip

Previous: Junio C HamanoNext: SZEDER Gábor
Message 5 of 6 in “$> git branch splat response considered harmful”
  1. jim.cromie@gmail.comAug 8, 2019
  2. Bryan TurnerAug 8, 2019
  3. Emily ShafferAug 8, 2019
  4. Junio C HamanoAug 8, 2019
  5. Philip OakleyAug 9, 2019
  6. SZEDER GáborAug 8, 2019

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.