git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCHSET] cg-log cleanups and enhancements
@ 2005-06-04 14:38 Jonas Fonseca
  2005-06-04 14:39 ` [PATCH 1/10] Cleanup conversion to human readable date Jonas Fonseca
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:38 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

The patchset contains the following 10 patches:

  [PATCH 1/10] Cleanup conversion to human readable date
  [PATCH 2/10] Separate handling of tree and parent in commit headers
  [PATCH 3/10] Separate handling of author and committer in commit headers
  [PATCH 4/10] First parse all commit header entries then print them
  [PATCH 5/10] Move printing of the commit info line inside the loop
  [PATCH 6/10] Remove the catch all rule
  [PATCH 7/10] Move log printing to separate function
  [PATCH 8/10] Move the username matching inside the loop
  [PATCH 9/10] Move file matching inside the loop.
  [PATCH 10/10] Add -s option to show log summary

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/10] Cleanup conversion to human readable date
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
@ 2005-06-04 14:39 ` Jonas Fonseca
  2005-06-04 14:39 ` [PATCH 2/10] Separate handling of tree and parent in commit headers Jonas Fonseca
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:39 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Simplify the date substitution to reduce code duplication.

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

 cg-log     |    8 ++------
 cg-mkpatch |    7 ++-----
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -188,12 +188,8 @@ $revls | $revsort | while read time comm
 
 				date=(${rest#*> })
 				pdate="$(showdate $date)"
-				if [ "$pdate" ]; then
-					echo -n $color$key $rest | sed "s/>.*/> $pdate/"
-					echo $coldefault
-				else
-					echo $color$key $rest $coldefault
-				fi
+				[ "$pdate" ] && rest="${rest%> *}> $pdate"
+				echo $color$key $rest $coldefault
 				;;
 			"tree"|"parent")
 				if [ -z $tree1 ]; then
diff --git a/cg-mkpatch b/cg-mkpatch
--- a/cg-mkpatch
+++ b/cg-mkpatch
@@ -53,11 +53,8 @@ showpatch () {
 		"author"|"committer")
 			date=(${rest#*> })
 			pdate="$(showdate $date)"
-			if [ "$pdate" ]; then
-				echo $key $rest | sed "s/>.*/> $pdate/" >>$header
-			else
-				echo $key $rest >>$header
-			fi
+			[ "$pdate" ] && rest="${rest%> *}> $pdate"
+			echo $key $rest >>$header
 			;;
 		"")
 			cat

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/10] Separate handling of tree and parent in commit headers
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
  2005-06-04 14:39 ` [PATCH 1/10] Cleanup conversion to human readable date Jonas Fonseca
@ 2005-06-04 14:39 ` Jonas Fonseca
  2005-06-04 14:40 ` [PATCH 3/10] Separate handling of author and committer " Jonas Fonseca
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:39 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Parse tree and parent commit header entries separately so the logic for
deciding where to save the IDs can be removed. Save all parents in an array.

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

 cg-log |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -162,8 +162,8 @@ fi
 
 $revls | $revsort | while read time commit parents; do
 	trap exit SIGPIPE
-	tree1=
-	tree2=
+	tree=
+	parents=()
 	[ "$revfmt" = "git-rev-list" ] && commit="$time"
 	if [ $# -ne 0 ]; then
 		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
@@ -191,17 +191,17 @@ $revls | $revsort | while read time comm
 				[ "$pdate" ] && rest="${rest%> *}> $pdate"
 				echo $color$key $rest $coldefault
 				;;
-			"tree"|"parent")
-				if [ -z $tree1 ]; then
-					tree1=$rest
-				elif [ -z $tree2 ]; then
-					tree2=$rest
-				fi
+			"tree")
+				tree="$rest"
+				echo $colheader$key $tree $coldefault
+				;;
+			"parent")
+				parents[${#parents[@]}]="$rest"
 				echo $colheader$key $rest $coldefault
 				;;
 			"")
 				if [ -n "$list_files" ]; then
-					list_commit_files "$tree1" "$tree2"
+					list_commit_files "$tree" "${parents[0]}"
 				fi
 				echo; sed -re '
 					/ *Signed-off-by:.*/Is//'$colsignoff'&'$coldefault'/

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/10] Separate handling of author and committer in commit headers
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
  2005-06-04 14:39 ` [PATCH 1/10] Cleanup conversion to human readable date Jonas Fonseca
  2005-06-04 14:39 ` [PATCH 2/10] Separate handling of tree and parent in commit headers Jonas Fonseca
@ 2005-06-04 14:40 ` Jonas Fonseca
  2005-06-04 14:40 ` [PATCH 4/10] First parse all commit header entries then print them Jonas Fonseca
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:40 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Parse and print the author and committer header entries so the color logic
can be removed.

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

 cg-log |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -162,6 +162,8 @@ fi
 
 $revls | $revsort | while read time commit parents; do
 	trap exit SIGPIPE
+	author=
+	committer=
 	tree=
 	parents=()
 	[ "$revfmt" = "git-rev-list" ] && commit="$time"
@@ -179,17 +181,19 @@ $revls | $revsort | while read time comm
 		while read key rest; do
 			trap exit SIGPIPE
 			case "$key" in
-			"author"|"committer")
-				if [ "$key" = "author" ]; then
-					color="$colauthor"
-				else
-					color="$colcommitter"
-				fi
-
-				date=(${rest#*> })
+			"author")
+				author="$rest"
+				date=(${author#*> })
+				pdate="$(showdate $date)"
+				[ "$pdate" ] && author="${author%> *}> $pdate"
+				echo $colauthor$key $author $coldefault
+				;;
+			"committer")
+				committer="$rest"
+				date=(${committer#*> })
 				pdate="$(showdate $date)"
-				[ "$pdate" ] && rest="${rest%> *}> $pdate"
-				echo $color$key $rest $coldefault
+				[ "$pdate" ] && committer="${committer%> *}> $pdate"
+				echo $colcommitter$key $committer $coldefault
 				;;
 			"tree")
 				tree="$rest"

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 4/10] First parse all commit header entries then print them
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (2 preceding siblings ...)
  2005-06-04 14:40 ` [PATCH 3/10] Separate handling of author and committer " Jonas Fonseca
@ 2005-06-04 14:40 ` Jonas Fonseca
  2005-06-04 14:41 ` [PATCH 5/10] Move printing of the commit info line inside the loop Jonas Fonseca
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:40 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Change the main loop to first parse all header entries before printing
them. Makes the cg-log output more independent of the order of the git
commit header.

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

 cg-log |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -183,27 +183,33 @@ $revls | $revsort | while read time comm
 			case "$key" in
 			"author")
 				author="$rest"
-				date=(${author#*> })
-				pdate="$(showdate $date)"
-				[ "$pdate" ] && author="${author%> *}> $pdate"
-				echo $colauthor$key $author $coldefault
 				;;
 			"committer")
 				committer="$rest"
-				date=(${committer#*> })
-				pdate="$(showdate $date)"
-				[ "$pdate" ] && committer="${committer%> *}> $pdate"
-				echo $colcommitter$key $committer $coldefault
 				;;
 			"tree")
 				tree="$rest"
-				echo $colheader$key $tree $coldefault
 				;;
 			"parent")
 				parents[${#parents[@]}]="$rest"
-				echo $colheader$key $rest $coldefault
 				;;
 			"")
+				echo ${colheader}tree $tree $coldefault
+
+				for parent in "${parents[@]}"; do
+					echo ${colheader}parent $parent $coldefault
+				done
+
+				date=(${author#*> })
+				pdate="$(showdate $date)"
+				[ "$pdate" ] && author="${author%> *}> $pdate"
+				echo ${colauthor}author $author $coldefault
+
+				date=(${committer#*> })
+				pdate="$(showdate $date)"
+				[ "$pdate" ] && committer="${committer%> *}> $pdate"
+				echo ${colcommitter}committer $committer $coldefault
+
 				if [ -n "$list_files" ]; then
 					list_commit_files "$tree" "${parents[0]}"
 				fi

-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 5/10] Move printing of the commit info line inside the loop
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (3 preceding siblings ...)
  2005-06-04 14:40 ` [PATCH 4/10] First parse all commit header entries then print them Jonas Fonseca
@ 2005-06-04 14:41 ` Jonas Fonseca
  2005-06-04 14:41 ` [PATCH 6/10] Remove the catch all rule Jonas Fonseca
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:41 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Printing of all the log headers are now handled the same place.

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

 cg-log |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -176,7 +176,6 @@ $revls | $revsort | while read time comm
 	if [ "$user" ]; then
 		git-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi "$user" || continue
 	fi
-	echo $colheader""commit ${commit%:*} $coldefault;
 	git-cat-file commit $commit | \
 		while read key rest; do
 			trap exit SIGPIPE
@@ -194,6 +193,7 @@ $revls | $revsort | while read time comm
 				parents[${#parents[@]}]="$rest"
 				;;
 			"")
+				echo ${colheader}commit ${commit%:*} $coldefault
 				echo ${colheader}tree $tree $coldefault
 
 				for parent in "${parents[@]}"; do
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 6/10] Remove the catch all rule
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (4 preceding siblings ...)
  2005-06-04 14:41 ` [PATCH 5/10] Move printing of the commit info line inside the loop Jonas Fonseca
@ 2005-06-04 14:41 ` Jonas Fonseca
  2005-06-04 14:42 ` [PATCH 7/10] Move log printing to separate function Jonas Fonseca
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:41 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

All commit header entries are already be handled so no need for a default
case pattern.

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

 cg-log |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -219,11 +219,7 @@ $revls | $revsort | while read time comm
 					s/./    &/
 				'
 				;;
-			*)
-				echo $colheader$key $rest $coldefault
-				;;
 			esac
-
 		done
 	echo
 done | pager
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 7/10] Move log printing to separate function
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (5 preceding siblings ...)
  2005-06-04 14:41 ` [PATCH 6/10] Remove the catch all rule Jonas Fonseca
@ 2005-06-04 14:42 ` Jonas Fonseca
  2005-06-04 14:42 ` [PATCH 8/10] Move the username matching inside the loop Jonas Fonseca
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:42 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Each commit log is now handled in the new print_commit_log() function.

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

 cg-log |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -160,22 +160,13 @@ else
 	revfmt="git-rev-list"
 fi
 
-$revls | $revsort | while read time commit parents; do
-	trap exit SIGPIPE
+print_commit_log() {
+	commit="$1"
 	author=
 	committer=
 	tree=
 	parents=()
-	[ "$revfmt" = "git-rev-list" ] && commit="$time"
-	if [ $# -ne 0 ]; then
-		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
-		diff_ops=
-		[ "$parent" ] || diff_ops=--root
-		[ "$(git-diff-tree -r $diff_ops $commit $parent "$@")" ] || continue
-	fi
-	if [ "$user" ]; then
-		git-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi "$user" || continue
-	fi
+
 	git-cat-file commit $commit | \
 		while read key rest; do
 			trap exit SIGPIPE
@@ -221,5 +212,20 @@ $revls | $revsort | while read time comm
 				;;
 			esac
 		done
+}
+
+$revls | $revsort | while read time commit parents; do
+	trap exit SIGPIPE
+	[ "$revfmt" = "git-rev-list" ] && commit="$time"
+	if [ $# -ne 0 ]; then
+		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
+		diff_ops=
+		[ "$parent" ] || diff_ops=--root
+		[ "$(git-diff-tree -r $diff_ops $commit $parent "$@")" ] || continue
+	fi
+	if [ "$user" ]; then
+		git-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi "$user" || continue
+	fi
+	print_commit_log $commit
 	echo
 done | pager
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 8/10] Move the username matching inside the loop
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (6 preceding siblings ...)
  2005-06-04 14:42 ` [PATCH 7/10] Move log printing to separate function Jonas Fonseca
@ 2005-06-04 14:42 ` Jonas Fonseca
  2005-06-04 14:43 ` [PATCH 9/10] Move file " Jonas Fonseca
  2005-06-04 14:43 ` [PATCH 10/10] Add -s option to show log summary Jonas Fonseca
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:42 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

By handling -u in the commit parsing loop no extra git-cat-file call is
necessary. Keep the line-based matching scheme so that it is still possible
to restrict searches by using prefixing the search string with either
'author' or 'committer' (e.g. -u'author.*miciah').

This change also magically removes trailing empty lines from commit logs.

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

 cg-log |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -184,6 +184,10 @@ print_commit_log() {
 				parents[${#parents[@]}]="$rest"
 				;;
 			"")
+				if [ "$user" ]; then
+					echo -e "author $author\ncommitter $committer" \
+						| grep -qi "$user" || return
+				fi
 				echo ${colheader}commit ${commit%:*} $coldefault
 				echo ${colheader}tree $tree $coldefault
 
@@ -223,9 +227,9 @@ $revls | $revsort | while read time comm
 		[ "$parent" ] || diff_ops=--root
 		[ "$(git-diff-tree -r $diff_ops $commit $parent "$@")" ] || continue
 	fi
-	if [ "$user" ]; then
-		git-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi "$user" || continue
+	log="$(print_commit_log $commit)"
+	if [ "$log" ]; then
+		echo "$log"
+		echo
 	fi
-	print_commit_log $commit
-	echo
 done | pager
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 9/10] Move file matching inside the loop.
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (7 preceding siblings ...)
  2005-06-04 14:42 ` [PATCH 8/10] Move the username matching inside the loop Jonas Fonseca
@ 2005-06-04 14:43 ` Jonas Fonseca
  2005-06-04 14:43 ` [PATCH 10/10] Add -s option to show log summary Jonas Fonseca
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:43 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

Handling of -f is done inide the loop so no extra git-cat-file call is
necessary. Store file arguments to cg-log in an array to make them easier
to access from print_commit_log().

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

 cg-log |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -73,6 +73,7 @@ log_start=
 log_end=
 user=
 mergebase=
+files=()
 
 while [ "$1" ]; do
 	case "$1" in
@@ -107,6 +108,7 @@ while [ "$1" ]; do
 		mergebase=1
 		;;
 	*)
+		files=("$@")
 		break
 		;;
 	esac
@@ -184,6 +186,12 @@ print_commit_log() {
 				parents[${#parents[@]}]="$rest"
 				;;
 			"")
+				if [ "$files" ]; then
+					parent="${parents[0]}"
+					diff_ops=
+					[ "$parent" ] || diff_ops=--root
+					[ "$(git-diff-tree -r $diff_ops $commit $parent "${files[@]}")" ] || return 1
+				fi
 				if [ "$user" ]; then
 					echo -e "author $author\ncommitter $committer" \
 						| grep -qi "$user" || return
@@ -221,12 +229,6 @@ print_commit_log() {
 $revls | $revsort | while read time commit parents; do
 	trap exit SIGPIPE
 	[ "$revfmt" = "git-rev-list" ] && commit="$time"
-	if [ $# -ne 0 ]; then
-		parent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')
-		diff_ops=
-		[ "$parent" ] || diff_ops=--root
-		[ "$(git-diff-tree -r $diff_ops $commit $parent "$@")" ] || continue
-	fi
 	log="$(print_commit_log $commit)"
 	if [ "$log" ]; then
 		echo "$log"
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 10/10] Add -s option to show log summary
  2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
                   ` (8 preceding siblings ...)
  2005-06-04 14:43 ` [PATCH 9/10] Move file " Jonas Fonseca
@ 2005-06-04 14:43 ` Jonas Fonseca
  9 siblings, 0 replies; 11+ messages in thread
From: Jonas Fonseca @ 2005-06-04 14:43 UTC (permalink / raw
  To: Petr Baudis; +Cc: git

When passing -s to cg-log each log entry is summarized in one line. The line
carries info about commit date, author, first log line and the commit id. It
will look something like the following (with only:

  2005-05-20 11:46 Linus Torvalds   sparse cleanup   e99d59ff0bff349ef20...

The result ends up being 130 chars wide however the commit id is placed so
that it can easily be hidden if line wrapping in the pager is enabled.

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

 cg-Xlib |    4 +++-
 cg-log  |   53 ++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 47 insertions(+), 10 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -47,10 +47,12 @@ mktemp () {
 
 showdate () {
 	date="$1"
+	format="$2"
+	[ "$format" ] || format=-R
 	sec=${date[0]}; tz=${date[1]}
 	dtz=${tz/+/}
 	lsec=$(expr $dtz / 100 \* 3600 + $dtz % 100 \* 60 + $sec)
-	pdate="$(date -Rud "1970-01-01 UTC + $lsec sec" 2>/dev/null)"
+	pdate="$(date -ud "1970-01-01 UTC + $lsec sec" "$format" 2>/dev/null)"
 
 	echo "${pdate/+0000/$tz}"
 }
diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log
@@ -14,15 +14,21 @@
 # cg-log then displays only changes in those files.
 #
 # -c::
-#	Add color to the output. Currently, the colors are:
-#	- `author`:	'cyan'
-#	- `committer`:	'magenta'
-#	- `header`:	'green'
-#	- `files`:	'blue'
-#	- `signoff`:	'yellow'
+#	Colorize to the output. When getting log summary the `date` is
+#	colored 'green', the `author` is colored 'cyan', the `commit ID`
+#	is colored 'blue' and the special line trimming character (~) is
+#	colored 'magenta'. +
+#	+
+#	When getting the full log the colors are:
+#		- `author`:	'cyan'
+#		- `committer`:	'magenta'
+#		- `header`:	'green'
+#		- `files`:	'blue'
+#		- `signoff`:	'yellow'
 #
 # -f::
-#	List affected files.
+#	List affected files. This option does not make sense when using
+#	`-s` to get a log summary.
 #
 # -r FROM_ID[:TO_ID]::
 #	Limit the log information to a set of revisions using either
@@ -36,6 +42,12 @@
 #	End the log listing at the merge base of the -r arguments
 #	(defaulting to master and origin).
 #
+# -s::
+#	Show a one line summary for each log entry. The summary contains
+#	information about the commit date, the author, the first line
+#	of the commit log and the commit ID. Long author and commit log
+#	titles are trimmed but marked with an ending tilde (~).
+#
 # -uUSERNAME::
 #	List only commits where author or committer contains 'USERNAME'.
 #	The search for 'USERNAME' is case-insensitive.
@@ -55,7 +67,7 @@
 #
 #	$ cg-log -r releasetag-0.9:releasetag-0.10
 
-USAGE="cg-log [-c] [-f] [m] [-uUSERNAME] [-r FROM_ID[:TO_ID] FILE..."
+USAGE="cg-log [-c] [-f] [-m] [-s] [-uUSERNAME] [-r FROM_ID[:TO_ID] FILE..."
 
 . ${COGITO_LIB}cg-Xlib
 # Try to fix the annoying "Broken pipe" output. May not help, but apparently
@@ -71,6 +83,7 @@ coldefault=
 list_files=
 log_start=
 log_end=
+summary=
 user=
 mergebase=
 files=()
@@ -107,6 +120,9 @@ while [ "$1" ]; do
 	-m)
 		mergebase=1
 		;;
+	-s)
+		summary=1
+		;;
 	*)
 		files=("$@")
 		break
@@ -196,6 +212,8 @@ print_commit_log() {
 					echo -e "author $author\ncommitter $committer" \
 						| grep -qi "$user" || return
 				fi
+				[ "$summary" ] && continue
+
 				echo ${colheader}commit ${commit%:*} $coldefault
 				echo ${colheader}tree $tree $coldefault
 
@@ -222,6 +240,23 @@ print_commit_log() {
 					s/./    &/
 				'
 				;;
+			*)
+				# Print summary
+				author="${author% <*}"
+				date=(${committer#*> })
+				date="$(showdate $date '+%F %H:%M')"
+				title="$key $rest"
+				if [ "${#title}" -gt 51 ]; then
+					title="${title:0:50}$colcommitter~"
+				fi
+				if [ "${#author}" -gt 20 ]; then
+					author="${author:0:19}$colcommitter~"
+				fi
+
+				printf "$colheader$date $colauthor%-20s $coldefault%-51s $colfiles${commit%:*}$coldefault\n" \
+					"$author" "$title"
+				return
+				;;
 			esac
 		done
 }
@@ -232,6 +267,6 @@ $revls | $revsort | while read time comm
 	log="$(print_commit_log $commit)"
 	if [ "$log" ]; then
 		echo "$log"
-		echo
+		[ "$summary" ] || echo
 	fi
 done | pager
-- 
Jonas Fonseca

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2005-06-04 14:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-04 14:38 [PATCHSET] cg-log cleanups and enhancements Jonas Fonseca
2005-06-04 14:39 ` [PATCH 1/10] Cleanup conversion to human readable date Jonas Fonseca
2005-06-04 14:39 ` [PATCH 2/10] Separate handling of tree and parent in commit headers Jonas Fonseca
2005-06-04 14:40 ` [PATCH 3/10] Separate handling of author and committer " Jonas Fonseca
2005-06-04 14:40 ` [PATCH 4/10] First parse all commit header entries then print them Jonas Fonseca
2005-06-04 14:41 ` [PATCH 5/10] Move printing of the commit info line inside the loop Jonas Fonseca
2005-06-04 14:41 ` [PATCH 6/10] Remove the catch all rule Jonas Fonseca
2005-06-04 14:42 ` [PATCH 7/10] Move log printing to separate function Jonas Fonseca
2005-06-04 14:42 ` [PATCH 8/10] Move the username matching inside the loop Jonas Fonseca
2005-06-04 14:43 ` [PATCH 9/10] Move file " Jonas Fonseca
2005-06-04 14:43 ` [PATCH 10/10] Add -s option to show log summary Jonas Fonseca

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).