[PATCH] cg-history FILE [NTH_PARENT] - was: Re: Wanted - a file browser interface to git
- From
- John Ellson <ellson@research.att.com>
- Date
- Oct 19, 2005, 03:15 UTC
- Message-ID
- <4355BA43.5030509@research.att.com>
- In-Reply-To
- <Pine.LNX.4.64.0510181806250.3369@g5.osdl.org>
Linus Torvalds wrote:
Show 14 quoted lines
> > On Tue, 18 Oct 2005, John Ellson wrote: >> An example is: "I know that file xxx contained algorithm yyy at some point in >> the past and now I'd like to browse back through the history of xxx to find >> the exact details." > > You are aware of "git whatchanged -p xxx", right? > > Yeah, it's not graphical, and I agree that it might be very cool to have a > graphical version of it. But I thought I'd mention it even so. A > surprising number of people seem to have never realized, and at least for > me personally, it's one of the most common things I do. > > Linus
OK. Here is a not-very-smart cogito command to display the history of a file, or the state of the nth parent of the file in its history.
Feedback and or complete rewrites are requested ;-)
John
produce the history of a file, or its state at its nth_parent
--- commit 8478ad1164e37e9cca039a3f9552d2a98f7bead6 tree 40b39d5f9af573a7815f073cada03c7903bfc6fa parent 5d74e4859afc81a4658133d5a83809ac814dbf34 author John Ellson <ellson@ontap.ellson.com> Tue, 18 Oct 2005 23:13:44 -0400 committer John Ellson <ellson@ontap.ellson.com> Tue, 18 Oct 2005 23:13:44 -0400
cg-history | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/cg-history b/cg-history new file mode 100755 index 0000000..ba86f71 --- /dev/null +++ b/cg-history @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# +# Display the change history of a file. +# Copyright (c) John Ellson, 2005 +# +# The change history of a file is displayed on stdout, or +# if an integer is provided for NTH_PARENT, then the complete +# state of the file at that step in its history is sent to stdout. +# + +USAGE="cg-history FILE [NTH_PARENT]" + +. ${COGITO_LIB}cg-Xlib || exit 1 + +[ "$ARGS" ] || usage + +if [ "${ARGS[1]}" = "" ]; then + git-whatchanged -p "${ARGS[0]}" +else + i=0 + git-whatchanged -p "${ARGS[0]}" | + while read -r cmd sha rest + do + case "$cmd" in + diff-tree) + i=`expr $i + 1` + if [ $i = ${ARGS[1]} ] ; then + cg-admin-cat -r "$sha" "${ARGS[0]}" + exit 0 + fi + ;; + *) + ;; + esac + done +fi