All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Bill Lear <rael@zopyra.com>
Cc: git@vger.kernel.org
Subject: Re: Listing of branch creation time?
Date: Tue, 27 Mar 2007 19:35:52 -0400	[thread overview]
Message-ID: <20070327233552.GA7186@coredump.intra.peff.net> (raw)
In-Reply-To: <17929.37382.984339.742025@lisa.zopyra.com>

On Tue, Mar 27, 2007 at 03:52:06PM -0600, Bill Lear wrote:

> I'm sure the git developers grow tired of working with addle-brained
> users, but I sometimes forget what the contents of a topic branch are,
> how old it is, etc.  As to content, I can make better branch names,
> but I think it would be useful to be able to query git as to the
> creation time of all of my branches, perhaps sorted from newest to
> oldest.

I'm not sure you can always accurately get that information. If you have
reflogs turned on, you can look at the oldest reflog for the that ref;
however, the reflog may have been pruned. You can also try looking at
the commit graph, but then you need a reference branch ("when did I
branch from master"), and even that's not entirely useful. You have to
look at the latest merge-base, but that tells you the last time you
merged with master, not necessarily the first time.

That being said, something like this should work:

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

branch_date() {
  git-rev-list -g --pretty=format:'%ct %cd' $1 | tail -n 1
}

git-show-ref --heads |
  while read sha1 branch; do
    echo "$branch `branch_date $branch`"
  done |
  sort -k 2nr |
  while read branch timestamp date; do
    printf '%20s %s\n' ${branch#refs/heads/} "$date"
  done
-- >8 --

Unfortunately, there is a bug in git-rev-list; I've just posted a patch, but
the one-liner fix is:

diff --git a/commit.c b/commit.c
index 718e568..a92958c 100644
--- a/commit.c
+++ b/commit.c
@@ -760,7 +760,7 @@ static void fill_person(struct interp *table, const char *msg, int len)
 	if (msg + start == ep)
 		return;
 
-	table[5].value = xstrndup(msg + start, ep - msg + start);
+	table[5].value = xstrndup(msg + start, ep - (msg + start));
 
 	/* parse tz */
 	for (start = ep - msg + 1; start < len && isspace(msg[start]); start++)

With that fix, the script above should hopefully produce what you want.

-Peff

  parent reply	other threads:[~2007-03-27 23:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-27 21:52 Listing of branch creation time? Bill Lear
2007-03-27 23:03 ` [PATCH] git-branch: add --sort-by-date option Johannes Schindelin
2007-03-27 23:53   ` Bill Lear
2007-07-23 23:38     ` [PATCH] Teach revision machinery about --no-walk Johannes Schindelin
2007-03-27 23:35 ` Jeff King [this message]
2007-03-28  0:00   ` Listing of branch creation time? Bill Lear
     [not found]     ` <2007032 8000149.GA12808@coredump.intra.peff.net>
2007-03-28  0:01     ` Jeff King
2007-03-28  0:08       ` Bill Lear
2007-03-28  0:10         ` Jeff King
2007-03-28  0:14           ` Bill Lear
2007-03-27 23:51             ` David Lang
2007-03-28  0:21               ` Jeff King
2007-03-28  1:29         ` Nicolas Pitre
2007-03-28  1:25       ` Nicolas Pitre
2007-03-28  1:06   ` Linus Torvalds
2007-03-28  2:04     ` Junio C Hamano
2007-03-28  2:52     ` Jeff King

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=20070327233552.GA7186@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=rael@zopyra.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.