Subject: [PATCH 7/10] Move log printing to separate function

From: Jonas Fonseca <[email-masked]>
Date: Sat, 4 Jun 2005 16:42:03 +0200

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

Signed-off-by: Jonas Fonseca <[email-masked]>
---

 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