git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git branch -v output ambiguous for parser
@ 2015-07-23 13:29 Thibault Kruse
  2015-07-23 13:44 ` Dennis Kaarsemaker
  0 siblings, 1 reply; 2+ messages in thread
From: Thibault Kruse @ 2015-07-23 13:29 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: git branch -v output ambiguous for parser
  2015-07-23 13:29 git branch -v output ambiguous for parser Thibault Kruse
@ 2015-07-23 13:44 ` Dennis Kaarsemaker
  0 siblings, 0 replies; 2+ messages in thread
From: Dennis Kaarsemaker @ 2015-07-23 13:44 UTC (permalink / raw)
  To: Thibault Kruse; +Cc: git

On do, 2015-07-23 at 15:29 +0200, Thibault Kruse wrote:
> Hi,
> 
> trying to write a git wrapper, I wanted to parse the output of git branch -v

The output of git branch is not meant to be machine-parsed. Try using
git for-each-ref :)
-- 
Dennis Kaarsemaker
http://www.kaarsemaker.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-23 13:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-23 13:29 git branch -v output ambiguous for parser Thibault Kruse
2015-07-23 13:44 ` Dennis Kaarsemaker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).