Re: [PATCH] branch: support sorting branches by mtime

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

 



On Thu, Nov 18, 2010 at 09:22:06PM +0700, Nguyán ThÃi Ngác Duy wrote:

> I lost in my branches again while looking for a topic that I feel like
> working on tonight. Too old branches are out of question.
> 
> This throwaway patch demonstrates the idea. I should have looked into
> reflog for this kind of information, but my laziness won over me.

I do something similar, but rather than using mtime, I sort by
authordate, which for-each-ref supports already. In fact, the script I
use is:

-- >8 --
#!/bin/sh

format='%(refname:short)'
sortby=refname
set -- $(getopt vt "$@")
while test $# -gt 0; do
	case "$1" in
	-v) format='%(refname:short) %(subject)' ;;
	-t) sortby=-authordate ;;
	--) break ;;
	 *) echo >&2 "unknown option: $1"; exit 100 ;;
	esac
	shift
done

git for-each-ref --sort=$sortby --format="$format" refs/heads |
egrep '^[a-z]{2,3}/' |
perl -pe '
  s/(\S+) /$1 . " " x (22 - length($1))/e; # line up subjects
  s/^(.{79}).*/$1/; # truncate long lines
'
-- 8< --

It might be nice if git-branch supported the same sortby that
for-each-ref does.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]