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

git branch -v output ambiguous for parser

From
Thibault Kruse <tibokruse@googlemail.com>
Date
Jul 23, 2015, 13:29 UTC
Message-ID
<CAByu6UVzsoK=OHkYv_zBCYf2YnBqx268TZ+_pi98N6pMt_NSgw@mail.gmail.com>
Hi,
trying to write a git wrapper, I wanted to parse the output of git branch -v

However, I realized that the output prints the last commit message at the end of the line, without any disambigution char, or hyphens. This makes it possible to have these outputs:

  foo                 6d29736 [foo/bar] test123
  master              9726de6 [ahead 2, behind 2] line 1 line 2 line 3

where foo is a branch that does not track another branch, and the last commit message on branch foo is '[foo/bar] test123'. The opening brackets '[' are even aligned in the output, making that distinction also difficult for the human eye.

So as a small improvement I would suggest some separating char or hyphens around the commit message, e.g.:

  foo                 6d29736 '[foo/bar] test123'
  foo                 6d29736 | [foo/bar] test123
regards,
  Thibault Kruse
Next: Dennis Kaarsemaker
Message 1 of 2 in “git branch -v output ambiguous for parser”
  1. Thibault KruseJul 23, 2015
  2. Dennis KaarsemakerJul 23, 2015

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.