From: Jeff King <peff@peff.net>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] branch: support sorting branches by mtime
Date: Thu, 18 Nov 2010 11:13:51 -0500 [thread overview]
Message-ID: <20101118161351.GA19011@sigill.intra.peff.net> (raw)
In-Reply-To: <1290090126-14471-1-git-send-email-pclouds@gmail.com>
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
next prev parent reply other threads:[~2010-11-18 16:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-18 14:22 [PATCH] branch: support sorting branches by mtime Nguyễn Thái Ngọc Duy
2010-11-18 16:13 ` Jeff King [this message]
2010-11-20 4:22 ` Joshua Juran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101118161351.GA19011@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).