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

Re: $> git branch splat response considered harmful

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Aug 8, 2019, 21:30 UTC
Message-ID
<20190808213002.GI20404@szeder.dev>
In-Reply-To
<CAJfuBxx5R28cjUj1v+mB4J+uUpbTMWnYowrCc=iOAbOcqWX-_w@mail.gmail.com>
On Thu, Aug 08, 2019 at 03:08:06PM -0600, jim.cromie@gmail.com wrote:
Show 18 quoted lines
> 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

'git branch' is not intended for scripting, try 'git for-each-ref' instead. The equivalent command should be:

  git for-each-ref --format='%(refname:strip=2)' refs/heads/
> also, I found no mention of the splat in the man page.
It's in the first sentence of the description :)
  If --list is given, or if there are no non-option arguments, existing
  branches are listed; the current branch will be highlighted in green
  and marked with an asterisk.
Previous: Emily ShafferNext: Junio C Hamano
Message 4 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. SZEDER GáborAug 8, 2019
  5. Junio C HamanoAug 8, 2019
  6. Philip OakleyAug 9, 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.