Subject: Re: best way to fastforward all tracking branches after a fetch

From: Jakub Narebski <[email-masked]>
Date: Sun, 11 Dec 2011 20:53:05 +0100

Andreas Schwab wrote:
> Jakub Narebski <[email-masked]> writes:
> 
> > Something like
> >
> >   git for-each-ref '--format=%(refname) %(upstream)' |
> >   while read refname upstream
> >   do
> >   	# there is upstream
> >   	test -n "$upstream" || break

Here you should probably also check if we are already up-to-date:

    	test $(git rev-parse $upstream) = $(git rev-parse $refname) || continue

> >   	# and if fast-forwards
> >   	test $(git merge-base $refname $upstream) = $(git rev-parse $refname) || break
> >   	git update-ref -m "$message" $refname $upstream
> >   done
> 
> You probably meant s/break/continue/.

Yes, sorry about that.

BTW. git-update-ref invocation can be replaced by Sitaram's suggestion:

    	git branch -f $refname $upstream

-- 
Jakub Narebski
Poland