Thread (5 messages) flat view 5 messages, 5 authors, 2016-06-15

Re: git-branch --print-current

From: Arnaud Lacombe <hidden>
Date: 2016-06-15 22:45:51

Hi,

On Thu, Jan 1, 2009 at 10:28 PM, Karl Chen [off-list ref] wrote:
How about an option to git-branch that just prints the name of the
current branch for scripts' sake?  To replace:

   git branch --no-color 2>/dev/null | perl -ne '/^[*] (.*)/ && print $1'
FWIW, I had this in a stalled modification in a tree, it just add the
'-c' (as "current") option to git branch. Patch is mostly for the
record :/

The main trouble I have with pipe stuff is that it forks a process for
something that can be done natively. Previously, I was using awk(1) to
extract the current branch:

$ git branch | awk '/^\*/ {print $2}'

 - Arnaud

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help