From: Johannes Schindelin Date: Fri, 16 Jan 2009 11:18:48 GMT Subject: Re: [PATCH] checkout: implement "-" shortcut name for last branch Message-ID: In-Reply-To: <200901161008.16234.trast@student.ethz.ch> Hi, On Fri, 16 Jan 2009, Thomas Rast wrote: > search_reflog () { > next= > git reflog show HEAD | > while read sha ref msg; do > if test -n "$next"; then > next= > echo ${sha%...} > fi > if echo "$msg" | grep -q "^checkout: moving from $branch "; then > next=t > fi > if echo "$msg" | grep -q "^merge $branch:"; then > git rev-list --parents -1 ${sha%...} \ > | cut -d' ' -f3 > fi > done > } How about this instead: search_reflog () { sed -n 's/\([^ ]*\) .*\tcheckout: moving from $branch .*/\1/p' \ < .git/logs/HEAD } Of course, this leaves out the merges... but I'd make that a command line option anyway: would you like to resurrect a branch that you recently were on, or one that you recently merged, or one that was merged by someone else? Ciao, Dscho