git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do I...

From
TKThomas 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
Previous: David WoodhouseNext: David Woodhouse
Message 21 of 24 in “How do I...”
  1. Frank SorensonMay 6, 2005
  2. Thomas GlanzmannMay 6, 2005
  3. Thomas GlanzmannMay 6, 2005
  4. Dave KleikampMay 6, 2005
  5. Frank SorensonMay 6, 2005
  6. Dave KleikampMay 6, 2005
  7. Frank SorensonMay 6, 2005
  8. Linus TorvaldsMay 6, 2005
  9. Junio C HamanoMay 6, 2005
  10. Frank SorensonMay 6, 2005
  11. Daniel BarkalowMay 6, 2005
  12. Frank SorensonMay 6, 2005
  13. Linus TorvaldsMay 6, 2005
  14. David WoodhouseMay 6, 2005
  15. Linus TorvaldsMay 6, 2005
  16. David WoodhouseMay 6, 2005
  17. Linus TorvaldsMay 6, 2005
  18. David WoodhouseMay 6, 2005
  19. Linus TorvaldsMay 6, 2005
  20. David WoodhouseMay 7, 2005
  21. Thomas KolejkaMay 6, 2005
  22. David WoodhouseMay 6, 2005
  23. Benjamin HerrenschmidtMay 7, 2005
  24. Linus TorvaldsMay 6, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.