Re: Listing of branch creation time?

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

 



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
-
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]