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

[PATCH] Show which files was changed in the git log output

From
Jonas Fonseca <fonseca@diku.dk>
Date
Apr 25, 2005, 01:22 UTC
Message-ID
<20050425012206.GA29069@diku.dk>
Hi,

I have attached a patch probe to optionally have the git log command list which files was changed by a commit.

It would be nice if someone with a more in depth knowledge of which sha1s to pass to diff-tree when there are multiple parents could comment on whether it does the right thing.

Right now it does the following: if there are only one parent it is diffed against the commit tree and if there are two parents they are diffed. I assume the order they are diffed doesn't matter.

-- 
Jonas Fonseca


Index: githelp.sh
===================================================================
--- 7de71a831508e51e0985cea173f3f7a7012c82b7/githelp.sh  (mode:100755 sha1:e19176d4ef69a2e7c6da6b9893e2c7cdac24760a)
+++ uncommitted/githelp.sh  (mode:100755)
@@ -19,7 +19,7 @@
 	fork		BNAME BRANCH_DIR [COMMIT_ID]
 	help
 	init		RSYNC_URL
-	log		[-c] [COMMIT_ID | COMMIT_ID:COMMIT_ID]
+	log		[-c] [-f] [COMMIT_ID | COMMIT_ID:COMMIT_ID]
 	ls		[TREE_ID]
 	lsobj		[OBJTYPE]
 	lsremote
Index: gitlog.sh
===================================================================
--- 7de71a831508e51e0985cea173f3f7a7012c82b7/gitlog.sh  (mode:100755 sha1:a09ffda484bd859a3bcb1cffcc8fd6f9c65fa8e7)
+++ uncommitted/gitlog.sh  (mode:100755)
@@ -13,8 +13,11 @@
 #	header		Green	
 #	author 		Cyan
 #	committer	Magenta
+#	files		Blue
 #	signoff		Yellow
 #
+# Takes an -f option to show which files was changed.
+#
 # Takes an id resolving to a commit to start from (HEAD by default),
 # or id1:id2 representing an (id1;id2] range of commits to show.
 
@@ -24,16 +27,25 @@
 	colheader="$(tput setaf 2)"    # Green
 	colauthor="$(tput setaf 6)"    # Cyan
 	colcommitter="$(tput setaf 5)" # Magenta
+	colfiles="$(tput setaf 4)"     # Blue
 	colsignoff="$(tput setaf 3)"   # Yellow
 	coldefault="$(tput op)"        # Restore default
 else
 	colheader=
 	colauthor=
 	colcommitter=
+	colfiles=
 	colsignoff=
 	coldefault=
 fi
 
+if [ "$1" = "-f" ]; then
+	shift
+	list_files=1
+else
+	list_files=
+fi
+
 if echo "$1" | grep -q ':'; then
 	id1=$(commit-id $(echo "$1" | cut -d : -f 1)) || exit 1
 	id2=$(commit-id $(echo "$1" | cut -d : -f 2)) || exit 1
@@ -49,6 +61,8 @@
 
 $revls | $revsort | while read time commit parents; do
 	[ "$revfmt" = "rev-list" ] && commit="$time"
+	tree1=
+	tree2=
 	echo $colheader""commit ${commit%:*} $coldefault;
 	cat-file commit $commit | \
 		while read key rest; do
@@ -73,11 +87,32 @@
 				fi
 				;;
 			"")
+				if [ -n $list_files ]; then
+					sep=
+					echo
+					echo -n "    * $colfiles"
+					diff-tree -r $tree1 $tree2 | \
+					while read modes type sha1s file; do
+						echo -n "$sep$file"
+						sep=", "
+					done
+					echo "$coldefault"
+				fi
 				echo; sed -re '
 					/ *Signed-off-by:.*/Is//'$colsignoff'&'$coldefault'/
 					s/^/    /
 				'
 				;;
+			"tree"|"parent")
+				if [ -z $tree1 ]; then
+					tree1=$rest
+				elif [ -z $tree2 ]; then
+					tree2=$rest
+				else
+					tree1=$rest
+				fi
+				echo $colheader$key $rest $coldefault
+				;;
 			*)
 				echo $colheader$key $rest $coldefault
 				;;
Message 1 of 1 in “Show which files was changed in the git log output”
  1. Show which files was changed in the git log outputJonas Fonseca, Apr 25, 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.