cg-mkpatch: Show human-readable dates
PATCH 1/1 cg-mkpatch: Show human-readable dates
Use the approach from from cg-log to show author and commit date in a human-readable format.
---
commit e9f5d35741f92d64945a072759450b1c43b2b6e4
tree 01bda4c4ac0c3b938fb4e7954193f2441554acfb
parent e5eb91b0a47e1169006034af434312c7f38dc902
author Jonas Fonseca <[email protected]> Wed, 27 Apr 2005 01:24:31 +0200 committer Jonas Fonseca <[email protected]> Wed, 27 Apr 2005 01:24:31 +0200
cg-mkpatch | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-)
cg-mkpatch (mode:100755 sha1:efee5dc887677d3122d8630b9ee3ef396b7adbd3) renamed from cg-mkpatch (mode:100755 sha1:25c67a29296730daeac00e43fd4c18cf914a1c87) +25 -9
@@ -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
Signature · 1 line
Jonas Fonseca
Dear diary, on Wed, Apr 27, 2005 at 01:27:29AM CEST, I got a letter where Jonas Fonseca <[email protected]> told me that...
Quoted 4 lines
Use the approach from from cg-log to show author and commit date in a human-readable format.
Signed-off-by Jonas Fonseca <[email protected]>
That means you want this in the library. ;-)
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
PATCH 1/1 Move common date code to the library file
Move common date conversion code to showdate() library function.
---
commit e7ab52f0d69a45e69d78f2992c7997283855ac48
tree 01c206a9520ffa599c3ce17c901b4fce9b162b08
parent 09da825be78580e991bfd0ccbb90de15bfa18113
author Jonas Fonseca <[email protected]> Wed, 27 Apr 2005 01:53:04 +0200 committer Jonas Fonseca <[email protected]> Wed, 27 Apr 2005 01:53:04 +0200
cg-Xlib | 9 +++++++++ cg-log | 7 ++----- cg-mkpatch | 7 ++----- 3 files changed, 13 insertions(+), 10 deletions(-)
cg-Xlib (mode:100755 sha1:665b84360050e7151eb2aa34327a10821ddc9ccf) renamed from cg-Xlib (mode:100755 sha1:5d84bbdb19510b7399f39ffd920636821a37248c) +9 -0
@@ -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
cg-log (mode:100755 sha1:5d0b602d32068af0d6e958f1c9c4dd6c870a9ce1) renamed from cg-log (mode:100755 sha1:1c53b31a956e7c8cbfe653143cc0f91df02a2f86) +2 -5
@@ -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
cg-mkpatch (mode:100755 sha1:c6aa52b6c773718a64feef47a165885b684b593b) renamed from cg-mkpatch (mode:100755 sha1:efee5dc887677d3122d8630b9ee3ef396b7adbd3) +2 -5
@@ -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
Signature · 1 line
Jonas Fonseca