# [PATCH 2/5] cogito: remove use of cp -a, a non-portable GNU extension

6 messages from 2005-07-16 to 2005-07-16. Participants: Bryan Larsen.
Thread: https://gitlist.dev/t/1265

## Bryan Larsen, 2005-07-16 23:23

Subject: [PATCH 0/5] cogito: compatibility with OS X
Message-ID: <20050716232308.7317.56890.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050716232308.7317.56890.sendpatchset%40bryan-larsens-ibook-g4.local

```
Since Linus and Junio were unhappy with my previous set of patches to
make git and cogito compatible with OS X and other BSD unices, I have
redone my patches to cogito along a similar line.

There is still one outstanding incompatibility:  cogito makes use of
cp -u.  I have this message from Junio:

> I do not speak for Pasky, but to me "cp -u" sounds just like an
> optimization, so maybe defining CP_U='cp -u' and detect missing
> support at config time and falling back on the simple "cp" would
> be an option?

Pasky, does this seem reasonable?  Is there a better way?  So far I
have been able to avoid adding the "config.sh" contained in my first
script.

cheers,
Bryan

```

## Bryan Larsen, 2005-07-16 23:23

Subject: [PATCH 1/5] cogito: remove use of xargs -r, a non-portable GNU extension
Message-ID: <20050716232319.7317.23031.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050716232319.7317.23031.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050716232308.7317.56890.sendpatchset@bryan-larsens-ibook-g4.local>

```
Remove usage of xargs -r, a non-portable gnu extension.  

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 cg-add  |    6 +++---
 cg-init |    2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cg-add b/cg-add
--- a/cg-add
+++ b/cg-add
@@ -25,8 +25,6 @@ USAGE="cg-add [-N] FILE..."
 
 . ${COGITO_LIB}cg-Xlib
 
-[ "$1" ] || usage
-
 infoonly=
 while optparse; do
 	if optparse -N; then
@@ -36,6 +34,8 @@ while optparse; do
 	fi
 done
 
+[ "$ARGS" ] || usage
+
 TMPFILE=$(mktemp -t gitadd.XXXXXX) || exit 1
 find "${ARGS[@]}" -type f -print0 > $TMPFILE || {
 	die "not all files exist, nothing added"
@@ -43,6 +43,6 @@ find "${ARGS[@]}" -type f -print0 > $TMP
 }
 
 cat $TMPFILE | tr '\0' '\n' | sed 's/^/Adding file /'
-cat $TMPFILE | xargs -0r git-update-cache --add ${infoonly} --
+cat $TMPFILE | xargs -0 git-update-cache --add ${infoonly} --
 
 rm $TMPFILE
diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -55,7 +55,7 @@ if [ "$uri" ]; then
 	echo "Cloned (origin $uri available as branch \"origin\")"
 else
 	git-read-tree # Seed the dircache
-	find * \( -type f -o -type l \) -print0 | xargs -0r cg-add ${infoonly}
+	[ `ls` ] && find * \( -type f -o -type l \) -print0 | xargs -0 cg-add ${infoonly}
 	cg-commit -C -m"Initial commit" -E ${infoonly}
 fi
 

```

## Bryan Larsen, 2005-07-16 23:23

Subject: [PATCH 2/5] cogito: remove use of cp -a, a non-portable GNU extension
Message-ID: <20050716232330.7317.50646.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050716232330.7317.50646.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050716232308.7317.56890.sendpatchset@bryan-larsens-ibook-g4.local>

```
Remove usage of cp -a, a non-portable gnu extension.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 cg-pull |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cg-pull b/cg-pull
--- a/cg-pull
+++ b/cg-pull
@@ -217,7 +217,7 @@ fetch_local () {
 	[ "$1" = "-i" ] && shift
 	[ "$1" = "-s" ] && shift
 
-	cp_flags_l="-va"
+	cp_flags_l="-vdpR"
 	if [ "$1" = "-u" ]; then
 		cp_flags_l="$cp_flags_l -u$can_hardlink"
 		suggest_hardlink=

```

## Bryan Larsen, 2005-07-16 23:23

Subject: [PATCH 3/5] cogito: try harder to find gnu stat
Message-ID: <20050716232341.7317.4962.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050716232341.7317.4962.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050716232308.7317.56890.sendpatchset@bryan-larsens-ibook-g4.local>

```
Look harder for gnu stat.

Cogito has code to use awk if gnu stat is missing.  Look harder 
for gnu stat under alternate names such as gstat and gnustat, avoiding
the use of awk if possible.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 cg-Xlib |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -229,11 +229,11 @@ fi
 
 
 # Compatibility hacks:
-# Fortunately none as of now.
-
 
 export BROKEN_MKTEMP=1
 del=$($(which mktemp) -t 2>/dev/null) && { rm $del; export BROKEN_MKTEMP=; }
-has_stat=$(which stat 2>/dev/null)
+has_stat=$(which gnustat 2> /dev/null ||
+    which gstat 2> /dev/null ||
+    which stat 2>/dev/null)
 [ "$has_stat" ] && $has_stat -c %s / 2>/dev/null >&2 || has_stat=
 has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)

```

## Bryan Larsen, 2005-07-16 23:24

Subject: [PATCH 4/5] cogito: try harder to find gnu date
Message-ID: <20050716232353.7317.63574.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050716232353.7317.63574.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050716232308.7317.56890.sendpatchset@bryan-larsens-ibook-g4.local>

```
Look harder for gnu date, use if available.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 cg-Xlib |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cg-Xlib b/cg-Xlib
--- a/cg-Xlib
+++ b/cg-Xlib
@@ -70,7 +70,7 @@ showdate () {
 	secs=$(($secs + $tzhours * 3600 + $tzmins * 60))
 	[ "$format" ] || format="+%a, %d %b %Y %H:%M:%S $2"
 	if [ "$has_gnudate" ]; then
-		LANG=C date -ud "1970-01-01 UTC + $secs sec" "$format"
+		LANG=C ${has_gnudate} -ud "1970-01-01 UTC + $secs sec" "$format"
 	else
 		LANG=C date -u -r $secs "$format"
 	fi
@@ -236,4 +236,8 @@ has_stat=$(which gnustat 2> /dev/null ||
     which gstat 2> /dev/null ||
     which stat 2>/dev/null)
 [ "$has_stat" ] && $has_stat -c %s / 2>/dev/null >&2 || has_stat=
-has_gnudate=$(date -Rud "1970-01-01 UTC" 2>/dev/null)
+has_gnudate=$(which gnudate 2> /dev/null || 
+    which gdate 2> /dev/null || 
+    which stat 2>/dev/null)
+[ "$has_gnudate" ] && 
+    $has_gnudate -Rud  "1970-01-01 UTC" 2> /dev/null >&2 || has_gnudate=

```

## Bryan Larsen, 2005-07-16 23:24

Subject: [PATCH 5/5] cogito: remove findutils dependency from Portfile
Message-ID: <20050716232404.7317.86971.sendpatchset@bryan-larsens-ibook-g4.local>
URL: https://gitlist.dev/e/20050716232404.7317.86971.sendpatchset%40bryan-larsens-ibook-g4.local
In-Reply-To: <20050716232308.7317.56890.sendpatchset@bryan-larsens-ibook-g4.local>

```
Gnu findutils (xargs) is no longer required; remove the dependency.  
Gnu coreutils is still required, but only if awk is not installed.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

 Portfile.in |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/Portfile.in b/Portfile.in
--- a/Portfile.in
+++ b/Portfile.in
@@ -14,8 +14,7 @@ long_description  The git core, develope
 homepage          http://kernel.org/pub/software/scm/cogito/
 master_sites      http://kernel.org/pub/software/scm/cogito/
 configure	  {}
-depends_lib       bin:gcp:coreutils
-depends_lib       bin:gnuxargs:findutils
+depends_lib       bin:gstat:coreutils
 build.type        gnu
 destroot.type     gnu
 destroot.destdir  prefix=${prefix} DESTDIR=${destroot}

```
