{"thread":{"id":"294","subject":"[PATCH] git add - recursive directories","startedAt":"2005-04-24T20:51:23Z","lastAt":"2005-04-24T20:51:23Z","messageCount":1,"participants":["Joshua T. Corbin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1543","messageId":"200504241651.24276.jcorbin@wunjo.org","threadId":"294","inReplyTo":null,"subject":"[PATCH] git add - recursive directories","fromName":"Joshua T. Corbin","fromEmail":"jcorbin@wunjo.org","sentAt":"2005-04-24T20:51:23Z","receivedAt":"2005-04-24T20:51:23Z","isPatch":true,"sender":{"key":"jcorbin@wunjo.org","avatar":null},"body":"This patch does two things:\n  1) git add will now by default recursively add any directories given to it.\n  2) this can be disabled and the old behavior used instead with the new -n\n     switch.\n\nSigned-off-by: Joshua T. Corbin <jcorbin@wunjo.org>\n\nIndex: git\n===================================================================\n--- 2aaf94eae20acc451553766f3c063bc46cfa75c6/git  (mode:100755 \nsha1:f8f5e0e4e5c50102415cd479619dd7598d3c42e1)\n+++ 58dd789846677d8d0848b608e365e9742d2db642/git  (mode:100755 \nsha1:24d8c30383fa11d049aafcd659cefe700afe1cf1)\n@@ -25,7 +25,7 @@\n Usage: git COMMAND [ARG]...\n \n Available commands:\n-\tadd\t\tFILE...\n+\tadd\t\t[-n] FILE...\n \taddremote\tRNAME RSYNC_URL\n \tapply\t\t\t\t< patch on stdin\n \tcancel\nIndex: gitadd.sh\n===================================================================\n--- 2aaf94eae20acc451553766f3c063bc46cfa75c6/gitadd.sh  (mode:100755 \nsha1:fa77d96198dd7d5ebf47bdedb296995ab7e77cf3)\n+++ 58dd789846677d8d0848b608e365e9742d2db642/gitadd.sh  (mode:100755 \nsha1:f0b030e1b4d770d96dabd5350e25f2e8fad5e59d)\n@@ -5,10 +5,31 @@\n #\n # Takes a list of file names at the command line, and schedules them\n # for addition to the GIT repository at the next commit.\n+# Optional \"-n\" parameter specifies that you don't want to add directories\n+# recursively.\n \n if [ ! \"$1\" ]; then\n-\techo \"gitadd.sh: usage: git add FILE...\" >&2\n+\techo \"gitadd.sh: usage: git add [-n] FILE...\" >&2\n \texit 1;\n fi\n \n-update-cache --add -- \"$@\"\n+recur=1\n+if [ \"$1\" = \"-n\" ]; then\n+  shift\n+  recur=\n+fi\n+\n+if [ $recur ]; then\n+  ADDFILE=$(mktemp -t gitadd.XXXXXX)\n+  while [ \"$1\" ]; do\n+    if [ -d \"$1\" ]; then\n+      find $1 -type f -and -not -name '.*'\n+    else\n+      echo \"$1\"\n+    fi\n+    shift\n+  done > $ADDFILE\n+  update-cache --add -- $(cat $ADDFILE)\n+else\n+  update-cache --add -- \"$@\"\n+fi\n"}]}