All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cg-log: Add -f switch to list changed files
@ 2005-04-26 23:03 Jonas Fonseca
  0 siblings, 0 replies; only message in thread
From: Jonas Fonseca @ 2005-04-26 23:03 UTC (permalink / raw)
  To: pasky; +Cc: git

Add -f switch to show changed files between the commit header and log message.
It doesn't do anything fancy like wrapping long lines and can be quite costly.

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

---
commit e5eb91b0a47e1169006034af434312c7f38dc902
tree bd580d135661ff0bc8eb32cb36025cd1e7bdda13
parent 580058cf4cbb6c95e5e84480499ca1c635d99376
author Jonas Fonseca <fonseca@diku.dk> 1114556053 +0200
committer Jonas Fonseca <fonseca@diku.dk> 1114556053 +0200

 cg-help |    2 +-
 cg-log  |   44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

Index: cg-help
===================================================================
--- 57a559984564e31e79db28d9ad62b8ea3a55dda1/cg-help  (mode:100755 sha1:86f29161aadf15411244db9514a1fdfb03e664bd)
+++ bd580d135661ff0bc8eb32cb36025cd1e7bdda13/cg-help  (mode:100755 sha1:18cc6a72de1cbe8ad7c66c30485350b5da252f9f)
@@ -21,7 +21,7 @@
 	cg-export	DESTDIR [TREE_ID]
 	cg-help
 	cg-init		[SOURCE_LOC]
-	cg-log		[-c] [COMMIT_ID | COMMIT_ID:COMMIT_ID]
+	cg-log		[-c] [-f] [COMMIT_ID | COMMIT_ID:COMMIT_ID]
 	cg-ls		[TREE_ID]
 	cg-merge	[-c] [-b BASE_ID] FROM_ID
 	cg-mkpatch	[COMMIT_ID | COMMIT_ID:COMMIT_ID]
Index: cg-log
===================================================================
--- 57a559984564e31e79db28d9ad62b8ea3a55dda1/cg-log  (mode:100755 sha1:58dd26ebf549cfb2e8e96fa2128f0dd34561ad55)
+++ bd580d135661ff0bc8eb32cb36025cd1e7bdda13/cg-log  (mode:100755 sha1:1c53b31a956e7c8cbfe653143cc0f91df02a2f86)
@@ -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.
 
@@ -26,16 +29,44 @@
 	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
+
+list_commit_files()
+{
+	tree1="$1"
+	tree2="$2"
+	sep="    * $colfiles"
+	# List all files for for the initial commit
+	if [ -z $tree2 ]; then
+		list_cmd="ls-tree $tree1"
+	else
+		list_cmd="diff-tree -r $tree1 $tree2"
+	fi
+	echo
+	$list_cmd | while read modes type sha1s file; do
+		echo -n "$sep$file"
+		sep=", "
+	done
+	echo "$coldefault:"
+}
+
 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
@@ -51,6 +82,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
@@ -75,11 +108,22 @@
 				fi
 				;;
 			"")
+				if [ -n "$list_files" ]; then
+					list_commit_files "$tree1" "$tree2"
+				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
+				fi
+				echo $colheader$key $rest $coldefault
+				;;
 			*)
 				echo $colheader$key $rest $coldefault
 				;;


-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-04-26 22:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-26 23:03 [PATCH] cg-log: Add -f switch to list changed files Jonas Fonseca

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.