[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: vcswatch



Le Sun, Aug 03, 2014 at 12:02:45AM +0800, Thomas Goirand a écrit :
> FYI, in shell scripting, here's the full solution to print the default
> branch on the remote:
> 
> HEADREF=`git ls-remote
> https://alioth.debian.org/anonscm/git/openstack/ceilometer.git | grep
> HEAD | awk '{print $1}'`
> 
> git ls-remote
> https://alioth.debian.org/anonscm/git/openstack/ceilometer.git | grep
> ${HEADREF} | grep refs/heads | awk '{print $2}' | sed 's#refs/heads/##'
> 
> Is there something quicker than 2 "git ls-remote" calls?

Hi Thomas,

For HTTP URLs (skipping the last awk and sed commands for clarity).

curl https://alioth.debian.org/anonscm/git/openstack/ceilometer.git/HEAD

The approach with ls-remote is not guaranteed to give the default branch, if
there are one or more additional branches with the same hash.  With this
limitation in mind, it can still be simplified as follows.

git ls-remote https://alioth.debian.org/anonscm/git/openstack/ceilometer.git | sort | sort  | grep -i HEAD | sed -n 2p 

Have a nice Sunday,

-- 
Charles Plessy
Tsurumi, Kanagawa, Japan


Reply to: