Subject: [PATCH 1/10] Cleanup conversion to human readable date

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

Simplify the date substitution to reduce code duplication.

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

 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