Subject: [PATCH] Make cg-add use xargs -0

From: Dan Holmsand <[email-masked]>
Date: Sun, 05 Jun 2005 21:15:38 +0200

Make cg-add use xargs -0, to avoid failure on files with
quotes of all kinds, spaces, etc.

Signed-off-by: Dan Holmsand <[email-masked]>
 cg-add |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/cg-add b/cg-add
--- a/cg-add
+++ b/cg-add
@@ -19,10 +19,13 @@ USAGE="cg-add FILE..."
 
 [ "$1" ] || usage
 
-TMPFILE=$(mktemp -t gitadd.XXXXXX)
-find "$@" -type f > $TMPFILE || die "not all files exist, nothing added"
+TMPFILE=$(mktemp -t gitadd.XXXXXX) || exit 1
+find "$@" -type f -print0 > $TMPFILE || {
+	die "not all files exist, nothing added"
+	rm $TMPFILE
+}
 
-cat $TMPFILE | awk '{print "Adding file "  $0}'
-cat $TMPFILE | xargs git-update-cache --add --
+cat $TMPFILE | tr \\0 \\n | awk '{print "Adding file "  $0}'
+cat $TMPFILE | xargs -0r git-update-cache --add --
 
 rm $TMPFILE