Re: How do I...
- From
- Thomas Kolejka <thomas.kolejka@gmx.at>
- Date
- May 6, 2005, 19:35 UTC
- Message-ID
- <15316.1115408107@www80.gmx.net>
- In-Reply-To
- <Pine.LNX.4.58.0505061158520.2233@ppc970.osdl.org>
I've written a script that shows all commits when a certain file was changed.
It goes back the commits, looks into the tree ... and if a change is found, print out the commit.
Thomas
--- /dev/null 1970-01-01 01:00:00.000000000 +0100 +++ git-file-history-script 2005-05-06 21:24:41.000000000 +0200
@@ -0,0 +1,59 @@ +#!/bin/sh +# +# Copyright (C) 2005 Thomas Kolejka +# +# usage - $0 [commit] pathname + + +if [ $# -gt 1 ] +then + HEAD=$1 + shift +else + HEAD=`cat $SHA1_FILE_DIRECTORY/../HEAD` +fi + +git-cat-file commit $HEAD >> /dev/null + +if [ $? -ne 0 ] +then + exit +fi + +f_name=$1 + + +echo "starting from commit $HEAD" + +last_sha1="last-revision" +last_commit=$HEAD + +git-rev-list $HEAD | while read the_commit +do + + the_tree=`git-cat-file commit $the_commit|head -n1 | awk '{ print $2 }'` + + + the_sha1=`git-ls-tree -r $the_tree|grep -w "${f_name}$"|awk '{ print $3 }'` + + if [ -z "$the_sha1" ] + then + continue + fi + + + if [ $last_sha1 != $the_sha1 ] + then + echo commit $the_commit - tree $the_tree - sha1 $the_sha1 + echo " " + # echo "$the_sha1 -> $last_sha1" + last_sha1=$the_sha1 + git-cat-file commit $last_commit + + echo " " + echo " " + echo " " + fi + + last_commit=$the_commit +done
-- +++ Neu: Echte DSL-Flatrates von GMX - Surfen ohne Limits +++ Always online ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl