{"thread":{"id":"295","subject":"[PATCH] git rm -- recursive directories","startedAt":"2005-04-24T21:09:05Z","lastAt":"2005-04-24T21:34:52Z","messageCount":2,"participants":["Joshua T. Corbin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1545","messageId":"200504241709.05689.jcorbin@wunjo.org","threadId":"295","inReplyTo":null,"subject":"[PATCH] git rm -- recursive directories","fromName":"Joshua T. Corbin","fromEmail":"jcorbin@wunjo.org","sentAt":"2005-04-24T21:09:05Z","receivedAt":"2005-04-24T21:09:05Z","isPatch":true,"sender":{"key":"jcorbin@wunjo.org","avatar":null},"body":"After posting the previous patch, I realized it made sense, to me at least ;), \nto have git rm work the same way. Same idea as my previous patch except this \ntime the recursion is off by default, must pass -r.\n\nSigned-off-by: Joshua T. Corbin <jcorbin@wunjo.org>\n\nIndex: git\n===================================================================\n--- be4029f0225729bd52a08ac39214264247e1d319/git  (mode:100755 \nsha1:24d8c30383fa11d049aafcd659cefe700afe1cf1)\n+++ e925e99aef139d50acc11d906be86809f3a08bcb/git  (mode:100755 \nsha1:3928887f010454a41853b8a836e1b87eeb0aaf51)\n@@ -42,7 +42,7 @@\n \tmerge\t\t[-c] [-b BASE_ID] FROM_ID\n \tpatch\t\t[COMMIT_ID | COMMIT_ID:COMMIT_ID]\n \tpull\t\t[RNAME]\n-\trm\t\tFILE...\n+\trm\t\t[-r] FILE...\n \tseek\t\t[COMMIT_ID]\n \tstatus\n \ttag\t\tTNAME [COMMIT_ID]\nIndex: gitrm.sh\n===================================================================\n--- be4029f0225729bd52a08ac39214264247e1d319/gitrm.sh  (mode:100755 \nsha1:3cc50fb9f12d2bf93a285ea18daadca7d3f5b549)\n+++ e925e99aef139d50acc11d906be86809f3a08bcb/gitrm.sh  (mode:100755 \nsha1:236261a53fdce287d32b40b8baf46c338515e555)\n@@ -5,11 +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 \"-r\" parameter specifies that you don't want to remove directories\n+# recursively.\n \n if [ ! \"$1\" ]; then\n \techo \"gitrm.sh: usage: git rm FILE...\" >&2\n \texit 1;\n fi\n \n-rm -f \"$@\"\n-update-cache --remove -- \"$@\"\n+recur=\n+if [ \"$1\" = \"-r\" ]; then\n+  shift\n+  recur=1\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+else\n+  rm -f \"$@\"\n+  update-cache --remove -- \"$@\"\n+fi\n"},{"id":"1550","messageId":"7vmzrnsvsz.fsf@assigned-by-dhcp.cox.net","threadId":"295","inReplyTo":"200504241709.05689.jcorbin@wunjo.org","subject":"Re: [PATCH] git rm -- recursive directories","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-24T21:34:52Z","receivedAt":"2005-04-24T21:34:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Why not also make add non recursive by default and give -r\noption when you want recursive?\n\n"}]}