All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cg-mkpatch: Show human-readable dates
@ 2005-04-26 23:27 Jonas Fonseca
  2005-04-26 23:34 ` Petr Baudis
  0 siblings, 1 reply; 3+ messages in thread
From: Jonas Fonseca @ 2005-04-26 23:27 UTC (permalink / raw)
  To: pasky; +Cc: git

Use the approach from from cg-log to show author and commit date
in a human-readable format.

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

---
commit e9f5d35741f92d64945a072759450b1c43b2b6e4
tree 01bda4c4ac0c3b938fb4e7954193f2441554acfb
parent e5eb91b0a47e1169006034af434312c7f38dc902
author Jonas Fonseca <fonseca@diku.dk> Wed, 27 Apr 2005 01:24:31 +0200
committer Jonas Fonseca <fonseca@diku.dk> Wed, 27 Apr 2005 01:24:31 +0200

 cg-mkpatch |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

Index: cg-mkpatch
===================================================================
--- bd580d135661ff0bc8eb32cb36025cd1e7bdda13/cg-mkpatch  (mode:100755 sha1:25c67a29296730daeac00e43fd4c18cf914a1c87)
+++ 01bda4c4ac0c3b938fb4e7954193f2441554acfb/cg-mkpatch  (mode:100755 sha1:efee5dc887677d3122d8630b9ee3ef396b7adbd3)
@@ -12,15 +12,31 @@
 showpatch () {
 	header=$(mktemp -t gitpatch.XXXXXX)
 	id=$1
-	cat-file commit $id | while read line; do
-		if [ ! "$line" ]; then
-			cat
-			echo
-			echo ---
-			echo commit $id
-			cat $header
-		fi
-		echo $line >>$header
+	cat-file commit $id | while read key rest; do
+		case "$key" in
+		"author"|"committer")
+			date=(${rest#*> })
+			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)"
+			if [ "$pdate" ]; then
+				echo $key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/" >> $header
+			else
+				echo $key $rest >> $header
+			fi
+			;;
+		"")
+			cat
+			echo
+			echo ---
+			echo commit $id
+			cat $header
+			;;
+		*)
+			echo $key $rest >>$header
+			;;
+		esac
 	done
 	echo
 	cg-diff -p -r $id > $header

-- 
Jonas Fonseca

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

* Re: [PATCH] cg-mkpatch: Show human-readable dates
  2005-04-26 23:27 [PATCH] cg-mkpatch: Show human-readable dates Jonas Fonseca
@ 2005-04-26 23:34 ` Petr Baudis
  2005-04-26 23:55   ` [PATCH] Move common date code to the library file Jonas Fonseca
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Baudis @ 2005-04-26 23:34 UTC (permalink / raw)
  To: git

Dear diary, on Wed, Apr 27, 2005 at 01:27:29AM CEST, I got a letter
where Jonas Fonseca <fonseca@diku.dk> told me that...
> Use the approach from from cg-log to show author and commit date
> in a human-readable format.
> 
> Signed-off-by: Jonas Fonseca <fonseca@diku.dk>

That means you want this in the library. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

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

* [PATCH] Move common date code to the library file
  2005-04-26 23:34 ` Petr Baudis
@ 2005-04-26 23:55   ` Jonas Fonseca
  0 siblings, 0 replies; 3+ messages in thread
From: Jonas Fonseca @ 2005-04-26 23:55 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

Move common date conversion code to showdate() library function.

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

---
commit e7ab52f0d69a45e69d78f2992c7997283855ac48
tree 01c206a9520ffa599c3ce17c901b4fce9b162b08
parent 09da825be78580e991bfd0ccbb90de15bfa18113
author Jonas Fonseca <fonseca@diku.dk> Wed, 27 Apr 2005 01:53:04 +0200
committer Jonas Fonseca <fonseca@diku.dk> Wed, 27 Apr 2005 01:53:04 +0200

 cg-Xlib    |    9 +++++++++
 cg-log     |    7 ++-----
 cg-mkpatch |    7 ++-----
 3 files changed, 13 insertions(+), 10 deletions(-)

Index: cg-Xlib
===================================================================
--- 6b45f2ad7c95fa110c7e8b53dae6d099d726bd4c/cg-Xlib  (mode:100755 sha1:5d84bbdb19510b7399f39ffd920636821a37248c)
+++ 01c206a9520ffa599c3ce17c901b4fce9b162b08/cg-Xlib  (mode:100755 sha1:665b84360050e7151eb2aa34327a10821ddc9ccf)
@@ -33,6 +33,15 @@
 	$(which mktemp) $dirarg $prefix"$1"
 }
 
+showdate () {
+	date="$1"
+	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)"
+
+	echo "${pdate/+0000/$tz}"
+}
 
 # Compatibility hacks:
 # 2005-04-26
Index: cg-log
===================================================================
--- 6b45f2ad7c95fa110c7e8b53dae6d099d726bd4c/cg-log  (mode:100755 sha1:1c53b31a956e7c8cbfe653143cc0f91df02a2f86)
+++ 01c206a9520ffa599c3ce17c901b4fce9b162b08/cg-log  (mode:100755 sha1:5d0b602d32068af0d6e958f1c9c4dd6c870a9ce1)
@@ -96,12 +96,9 @@
 				fi
 
 				date=(${rest#*> })
-				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="$(showdate $date)"
 				if [ "$pdate" ]; then
-					echo -n $color$key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/"
+					echo -n $color$key $rest | sed "s/>.*/> $pdate/"
 					echo $coldefault
 				else
 					echo $color$key $rest $coldefault
Index: cg-mkpatch
===================================================================
--- 6b45f2ad7c95fa110c7e8b53dae6d099d726bd4c/cg-mkpatch  (mode:100755 sha1:efee5dc887677d3122d8630b9ee3ef396b7adbd3)
+++ 01c206a9520ffa599c3ce17c901b4fce9b162b08/cg-mkpatch  (mode:100755 sha1:c6aa52b6c773718a64feef47a165885b684b593b)
@@ -16,12 +16,9 @@
 		case "$key" in
 			"author"|"committer")
 				date=(${rest#*> })
-				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="$(showdate $date)"
 				if [ "$pdate" ]; then
-					echo $key $rest | sed "s/>.*/> ${pdate/+0000/$tz}/" >> $header
+					echo $key $rest | sed "s/>.*/> $pdate/" >> $header
 				else
 					echo $key $rest >> $header
 				fi

-- 
Jonas Fonseca

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

end of thread, other threads:[~2005-04-26 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-26 23:27 [PATCH] cg-mkpatch: Show human-readable dates Jonas Fonseca
2005-04-26 23:34 ` Petr Baudis
2005-04-26 23:55   ` [PATCH] Move common date code to the library file 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.