bill-auger / git-branch-status

A shell script that prints out pretty git branch sync status reports
GNU General Public License v3.0
237 stars 34 forks source link

Feature request: porcelain version #3

Closed najamelan closed 8 years ago

najamelan commented 8 years ago

This tool is really nice for scripting, but parsing the report is a bit of a pain. It would be nice to be able to ask the situation for a branch and get a oneline output, maybe like: origin 1 -2 Or even if the remote can be specified, just: 1 -2 Personally I'm looking for the simplest way to tell if a remote branch can be pulled --ff-only without actually doing the pull...

bill-auger commented 8 years ago

this feature you are requesting is essentially the original primitive behavior from 5 years ago - you could reset this repo to the original commit and you would have essentially that - this was never intended for scripting - the main use case for this script is the human-readable report

if that is all the output you wanted for a single branch you could get that like this

remote="origin"
branch="master"
ahead=$(git rev-list $branch..$remote/$branch --count) 
behind=$(git rev-list $remote/$branch..$branch --count) 
echo "$remote/$branch $ahead $behind"

you could also use git --dry-run for your specific purpose

najamelan commented 8 years ago

Ok,

thank you for the tips, I'll most likely do it like that then. Ill still keep git-branch-status for my own pleasure when using the command line ;)