{"thread":{"id":"1272","subject":"[PATCH UPDATED] cg-commit chokes when given a very large list of files","startedAt":"2005-07-18T04:37:22Z","lastAt":"2005-07-18T04:37:22Z","messageCount":1,"participants":["Bryan Larsen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"6237","messageId":"20050718043713.22322.21445.sendpatchset@bryan-larsens-ibook-g4.local","threadId":"1272","inReplyTo":null,"subject":"[PATCH UPDATED] cg-commit chokes when given a very large list of files","fromName":"Bryan Larsen","fromEmail":"bryanlarsen@yahoo.com","sentAt":"2005-07-18T04:37:22Z","receivedAt":"2005-07-18T04:37:22Z","isPatch":true,"sender":{"key":"bryan@larsen.st","avatar":"https://avatars.githubusercontent.com/u/32073?v=4"},"body":"cg-commit currently chokes when passed a very large list of files.  Fix it.\n\nResent again.  This time we completely avoid messing with IFS, resulting \nin support for filenames with line feeds.\n\nSigned-off-by: Bryan Larsen <bryan.larsen@gmail.com>\n---\n\n cg-Xlib   |   18 ++++++++++++++++++\n cg-commit |    6 +++---\n 2 files changed, 21 insertions(+), 3 deletions(-)\n\ndiff --git a/cg-Xlib b/cg-Xlib\n--- a/cg-Xlib\n+++ b/cg-Xlib\n@@ -49,6 +49,24 @@ mktemp () {\n \t$(which mktemp) $dirarg $prefix\"$1\"\n }\n \n+\n+# this function is useful when you want to execute a command that's bigger\n+# than the system's limit.\n+#\n+# this is similar to piping output to xargs -0r\n+# \n+# example usage:  eval_via_xargs \"git-update-cache --add --\" \"$@\"\n+eval_via_xargs () {\n+    local cmd=$1\n+    shift\n+    if [ \"$1\" ] ; then\t\n+\t( for f in \"$@\" ; do\n+\t    echo -ne ${f}\\\\000\n+\tdone ) | xargs -0 $cmd\n+    fi\n+}\n+\n+\n stat () {\n \tif [ \"$1\" != \"-c\" ] || [ \"$2\" != \"%s\" ]; then\n \t\techo \"INTERNAL ERROR: Unsupported stat call $@\" >&2\ndiff --git a/cg-commit b/cg-commit\n--- a/cg-commit\n+++ b/cg-commit\n@@ -289,9 +289,9 @@ precommit_update () {\n \t\teval \"queue$op[\\${#queue$op[@]}]=\\\"\\$fname\\\"\"\n \tdone\n \t# XXX: Do we even need to do the --add and --remove update-caches?\n-\t[ \"$queueN\" ] && { git-update-cache --add ${infoonly} -- \"${queueN[@]}\" || return 1; }\n-\t[ \"$queueD\" ] && { git-update-cache --force-remove -- \"${queueD[@]}\" || return 1; }\n-\t[ \"$queueM\" ] && { git-update-cache ${infoonly} -- \"${queueM[@]}\" || return 1; }\n+\teval_via_xargs \"git-update-cache --add ${infoonly} --\" \"${queueN[@]}\" || return 1\n+\teval_via_xargs \"git-update-cache --force-remove --\" \"${queueD[@]}\" || return 1\n+\teval_via_xargs \"git-update-cache ${infoonly} --\" \"${queueM[@]}\" || return 1\n \treturn 0\n }\n \n"}]}