Re: [COGITO PATCH] Fix cg-log and cg-status for non-GNU sed/sort
From: Mark Allen <hidden>
Date: 2016-06-15 22:41:59
Subsystem:
the rest · Maintainer:
Linus Torvalds
--- Petr Baudis <pasky@ucw.cz> wrote:I think we don't really need -r anyway. Could you please try with the 'i' flag instead of 'I'? (The manpage is somewhat unclear on the difference and portability.) Also, could you try if it works with the newlines?
I tried with an i\ which is what the sed on Darwin wants, and it didn't work very well... so, I just removed the I and i\ and that worked pretty nicely. I shaved off the -r and made for a simpler patch. I also added $has_gnudate to cg-Xlib and modified the logic in showdate to use the appropriate command depending on whether $has_gnudate is true or false. Finally, I stripped the -z from sort because it seems to do the right thing anyway without it and it makes the sort on Darwin unhappy. Anyway, here's another try, this against the tip of the most recent cogito tree. --- Modify cg-log, cg-Xlib and cg-status for non-GNU sed, sort and date. Signed-off-by: Mark Allen <redacted>
diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib@@ -42,9 +42,13 @@ mktemp () { 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)" + if [ ! "$has_gnudate" ]; then + pdate="$(date -u -r ${date[0]} 2>/dev/null)" + else + dtz=${tz/+/} + lsec=$(expr $dtz / 100 \* 3600 + $dtz % 100 \* 60 + $sec) + pdate="$(date -Rud "1970-01-01 UTC + $lsec sec" 2>/dev/null)" + fi echo "${pdate/+0000/$tz}" }
@@ -137,3 +141,4 @@ fi export BROKEN_MKTEMP=1 del=$($(which mktemp) -t 2>/dev/null) && { rm $del; export BROKEN_MKTEMP=; } +has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)
diff --git a/cg-log b/cg-log
--- a/cg-log
+++ b/cg-log@@ -190,8 +190,7 @@ $revls | $revsort | while read time comm date=(${rest#*> }) pdate="$(showdate $date)" if [ "$pdate" ]; then - echo -n $color$key $rest | sed "s/>.*/>
$pdate/"
- echo $coldefault
+ echo -n $color$key $rest | sed "s/>.*/>
$pdate$coldefault/"
else
echo $color$key $rest $coldefault
fi@@ -208,9 +207,9 @@ $revls | $revsort | while read time comm if [ -n "$list_files" ]; then list_commit_files "$tree1" "$tree2" fi - echo; sed -re ' - / *Signed-off-by:.*/Is//'$colsignoff'&'$
coldefault'/
- / *Acked-by:.*/Is//'$colsignoff'&'$colde
fault'/
+ echo; sed -e '
+ / *Signed-off-by:.*/s//'$colsignoff'&'$c
oldefault'/
+ / *Acked-by:.*/s//'$colsignoff'&'$coldef
ault'/
s/./ &/
'
;;diff --git a/cg-status b/cg-status
--- a/cg-status
+++ b/cg-status@@ -41,7 +41,7 @@ fi { git-ls-files -z -t --others --deleted --unmerged $EXCLUDE -} | sort -z -k 2 | xargs -0 sh -c ' +} | sort -k 2 | xargs -0 sh -c ' while [ "$1" ]; do tag=${1% *}; filename=${1#* };