Reputation: 83
The title is as simple as it seems; I'm trying to make a prompt for my terminal and that will display all of the information about the current branch. While I could just create all of the scenarios manually, I'm confused about the format of certain commands; for example, if git status -sb
says a branch is 3 up, and 0 behind; I know it will say [3 ahead
, but will it show 0 behind]
, or simply nothing? I am most likely parsing the output of these commands, so it is pretty vital to know. Is there a certain site that shows this, or will I have to create the scenarios on my own?
Upvotes: 0
Views: 51
Reputation: 60585
I am most likely parsing the output of these commands
Don't do that. Those commands are "porcelain", they're human-convenience renditions of the underlying data, and they're explicitly not made for scraping. As the people who work on Git find more convenient ways to work, the convenience commands will be updated. The core command outputs won't change. Guaranteed. The convenience commands all started as scripts based on core commands and could still be done that way.
To take your example, ~how many ahead, how many behind~, you can get those numbers directly, with
base=`git merge-base @{u} @`
ahead=`git rev-list --count $base..@`
behind=`git rev-list --count $base..@{u}`
echo $ahead ahead, $behind behind `git rev-parse --symbolic-full-name @{u}`
@{u}
is shorthand for HEAD@{upstream}
and @
is shorthand for HEAD
.
Upvotes: 1