git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [COGITO PATCH] Fix cg-log and cg-status for non-GNU sed/sort

From
MAMark Allen <mrallen1@yahoo.com>
Date
May 31, 2005, 01:19 UTC
Message-ID
<20050531011925.94043.qmail@web41213.mail.yahoo.com>
In-Reply-To
<20050529234911.GZ1036@pasky.ji.cz>
--- 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 <mrallen1@yahoo.com>
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#* };
Previous: Alecs King
Message 6 of 6 in “Fix cg-log and cg-status for non-GNU sed/sort”
  1. Fix cg-log and cg-status for non-GNU sed/sortMark Allen, May 29, 2005
  2. Petr BaudisMay 29, 2005
  3. Mark AllenMay 29, 2005
  4. Petr BaudisMay 29, 2005
  5. Alecs KingMay 30, 2005
  6. Mark AllenMay 31, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.