{"thread":{"id":"319","subject":"[PATCH] cogito recursive cg-add and cg-rm","startedAt":"2005-04-26T04:27:02Z","lastAt":"2005-04-26T13:21:36Z","messageCount":4,"participants":["Joshua T. Corbin","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1708","messageId":"200504260027.03451.jcorbin@wunjo.org","threadId":"319","inReplyTo":null,"subject":"[PATCH] cogito recursive cg-add and cg-rm","fromName":"Joshua T. Corbin","fromEmail":"jcorbin@wunjo.org","sentAt":"2005-04-26T04:27:02Z","receivedAt":"2005-04-26T04:27:02Z","isPatch":true,"sender":{"key":"jcorbin@wunjo.org","avatar":null},"body":"This patch adds recursive addition and removal to cg-add and cg-rm, recursion \ncan be disabled with the -n switch.\n\nSigned-off-by: Joshua T. Corbin <jcorbin@wunjo.org>\n\nIndex: cg-add\n===================================================================\n--- f262000f302b749e485f5eb971e6aabefbb85680/cg-add  (mode:100755 \nsha1:8ba5351a4c7e28a577ea1aa4afa1078c54e9bccc)\n+++ ddd5e0ab084034b713bb2f7d9de6f365d5a2e5bf/cg-add  (mode:100755 \nsha1:1b7a821fd0b3f9702508503a082869ed4ec3ab52)\n@@ -5,9 +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 . cg-Xlib\n \n-[ \"$1\" ] || die \"usage: cg-add FILE...\"\n+[ \"$1\" ] || die \"usage: cg-add [-n] FILE...\"\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+  rm -f $RMFILE\n+else\n+  update-cache --add -- \"$@\"\n+fi\nIndex: cg-help\n===================================================================\n--- f262000f302b749e485f5eb971e6aabefbb85680/cg-help  (mode:100755 \nsha1:86f29161aadf15411244db9514a1fdfb03e664bd)\n+++ ddd5e0ab084034b713bb2f7d9de6f365d5a2e5bf/cg-help  (mode:100755 \nsha1:36480174eba9cc54e9baba100cbd368fbced5c76)\n@@ -11,7 +11,7 @@\n Usage: cg-COMMAND [ARG]...\n \n Available commands:\n- cg-add  FILE...\n+ cg-add  [-n] FILE...\n  cg-branch-add BNAME SOURCE_LOC\n  cg-branch-ls\n  cg-cancel\n@@ -27,7 +27,7 @@\n  cg-mkpatch [COMMIT_ID | COMMIT_ID:COMMIT_ID]\n  cg-patch   < patch on stdin\n  cg-pull  [BNAME]\n- cg-rm  FILE...\n+ cg-rm  [-n] FILE...\n  cg-seek  [COMMIT_ID]\n  cg-status\n  cg-tag  TNAME [COMMIT_ID]\nIndex: cg-rm\n===================================================================\n--- f262000f302b749e485f5eb971e6aabefbb85680/cg-rm  (mode:100755 \nsha1:029a03128eb7a8dd807335fea2ff52cb2bcda4fa)\n+++ ddd5e0ab084034b713bb2f7d9de6f365d5a2e5bf/cg-rm  (mode:100755 \nsha1:1e0c64567767668454a0360785ac84883c7bbd58)\n@@ -5,10 +5,36 @@\n #\n # Takes a list of file names at the command line, and schedules them\n # for removal from the GIT repository at the next commit.\n+# Optional \"-n\" parameter specifies that you don't want to remove directories\n+# recursively.\n \n . cg-Xlib\n \n-[ \"$1\" ] || die \"usage: cg-rm FILE...\"\n+[ \"$1\" ] || die \"usage: cg-rm [-n] FILE...\"\n \n-rm -f \"$@\"\n-update-cache --remove -- \"$@\"\n+recur=1\n+if [ \"$1\" = \"-n\" ]; then\n+  shift\n+  recur=\n+fi\n+\n+if [ $recur ]; then\n+  RMFILE=$(mktemp -t gitrm.XXXXXX)\n+  RMDIRS=\n+  while [ \"$1\" ]; do\n+    if [ -d \"$1\" ]; then\n+      RMDIRS=\"$DIRS $1\"\n+      find $1 -type f -and -not -name '.*'\n+    else\n+      echo \"$1\"\n+    fi\n+    shift\n+  done > $RMFILE\n+  rm -f $(cat $RMFILE)\n+  rmdir $(find $RMDIRS -depth -type d)\n+  update-cache --remove -- $(cat $RMFILE)\n+  rm -f $RMFILE\n+else\n+  rm -f \"$@\"\n+  update-cache --remove -- \"$@\"\n+fi\n"},{"id":"1711","messageId":"200504260117.20205.jcorbin@wunjo.org","threadId":"319","inReplyTo":"200504260027.03451.jcorbin@wunjo.org","subject":"Re: [PATCH] cogito recursive cg-add and cg-rm","fromName":"Joshua T. Corbin","fromEmail":"jcorbin@wunjo.org","sentAt":"2005-04-26T05:17:19Z","receivedAt":"2005-04-26T05:17:19Z","isPatch":true,"sender":{"key":"jcorbin@wunjo.org","avatar":null},"body":"Small one line fix on top of the previos patch, apparently I was too hasty and \ndidn't test cg-rm on a single file ;)\n\nSigned-off-by: Joshua T. Corbin <jcorbin@wunjo.org>\n\nIndex: cg-rm\n===================================================================\n--- bb131a04832677b22959ffe47f68900b94accc0c/cg-rm  (mode:100755 \nsha1:f2d2e0c042fdf9496d53e833a50d960331e145b4)\n+++ 5b396356f2c852f95a4226e955e186f46851a1f0/cg-rm  (mode:100755 \nsha1:7701a83878c1e02dbce3abc0e3f1290c56c1be16)\n@@ -40,7 +40,7 @@\n     shift\n   done > $RMFILE\n   rm -f $(cat $RMFILE)\n-  rmdir $(find $RMDIRS -depth -type d)\n+  [ -n \"$RMDIRS\" ] && rmdir $(find $RMDIRS -depth -type d)\n   update-cache --remove -- $(cat $RMFILE)\n   rm -f $RMFILE\n else\n"},{"id":"1732","messageId":"20050426123901.GF18971@pasky.ji.cz","threadId":"319","inReplyTo":"200504260027.03451.jcorbin@wunjo.org","subject":"Re: [PATCH] cogito recursive cg-add and cg-rm","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-04-26T12:39:01Z","receivedAt":"2005-04-26T12:39:01Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Apr 26, 2005 at 06:27:02AM CEST, I got a letter\nwhere \"Joshua T. Corbin\" <jcorbin@wunjo.org> told me that...\n> This patch adds recursive addition and removal to cg-add and cg-rm, recursion \n> can be disabled with the -n switch.\n> \n> Signed-off-by: Joshua T. Corbin <jcorbin@wunjo.org>\n\nI'd actually prefer -r to explicitly turn the recursion on. That is more\nconsistent with the rest of the UNIX world and I really don't feel\ncomfortable with cg-rm recursing by default. ;-)\n\nAlso please use tabs for indentation.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"1734","messageId":"200504260921.36736.jcorbin@wunjo.org","threadId":"319","inReplyTo":"20050426123901.GF18971@pasky.ji.cz","subject":"Re: [PATCH] cogito recursive cg-add and cg-rm","fromName":"Joshua T. Corbin","fromEmail":"jcorbin@wunjo.org","sentAt":"2005-04-26T13:21:36Z","receivedAt":"2005-04-26T13:21:36Z","isPatch":true,"sender":{"key":"jcorbin@wunjo.org","avatar":null},"body":"On 26 April 2005 08:39, Petr Baudis wrote:\n> Dear diary, on Tue, Apr 26, 2005 at 06:27:02AM CEST, I got a letter\n> where \"Joshua T. Corbin\" <jcorbin@wunjo.org> told me that...\n>\n> > This patch adds recursive addition and removal to cg-add and cg-rm,\n> > recursion can be disabled with the -n switch.\n> >\n> > Signed-off-by: Joshua T. Corbin <jcorbin@wunjo.org>\n>\n> I'd actually prefer -r to explicitly turn the recursion on. That is more\n> consistent with the rest of the UNIX world and I really don't feel\n> comfortable with cg-rm recursing by default. ;-)\nHmm, I guess for it to work the way I was inteding would take a little more \nwork; it should bail if any of the files are not in the repository or are \nlocally modified.\n\n> Also please use tabs for indentation.\nWill do\n\n-- \nRegards,\nJoshua T. Corbin <jcorbin@wunjo.org>\n"}]}