Subject: [PATCH 4/10] First parse all commit header entries then print them

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

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 <[email-masked]>
---

 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