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

[PATCH] Make cg-add use xargs -0

From
Dan Holmsand <holmsand@gmail.com>
Date
Jun 5, 2005, 19:15 UTC
Message-ID
<42A34F5A.2090909@gmail.com>
In-Reply-To
<20050605184341.GA21345@immutable.crsr.net>

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

Signed-off-by: Dan Holmsand <holmsand@gmail.com>
 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
Previous: Tommy M. McGuireNext: Petr Baudis
Message 12 of 15 in “cg-init bug”
  1. Zack BrownJun 5, 2005
  2. Radoslaw SzkodzinskiJun 5, 2005
  3. Zack BrownJun 5, 2005
  4. Radoslaw SzkodzinskiJun 5, 2005
  5. Petr BaudisJun 5, 2005
  6. Zack BrownJun 5, 2005
  7. Petr BaudisJun 5, 2005
  8. Zack BrownJun 5, 2005
  9. Tommy M. McGuireJun 5, 2005
  10. Tommy M. McGuireJun 5, 2005
  11. Re: cg-init bug -- identifiedTommy M. McGuire, Jun 5, 2005
  12. Make cg-add use xargs -0Dan Holmsand, Jun 5, 2005
  13. Petr BaudisJun 5, 2005
  14. Zack BrownJun 5, 2005
  15. Junio C HamanoJun 5, 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.