Re: [PATCH] checkout: implement "-" shortcut name for last branch
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 16, 2009, 11:18 UTC
- Message-ID
- <alpine.DEB.1.00.0901161213370.3586@pacific.mpi-cbg.de>
- In-Reply-To
- <200901161008.16234.trast@student.ethz.ch>
Hi,
On Fri, 16 Jan 2009, Thomas Rast wrote:
Show 17 quoted lines
> 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