Git development
 help / color / mirror / Atom feed
From: "Joshua T. Corbin" <jcorbin@wunjo.org>
To: git@vger.kernel.org
Subject: [PATCH] git rm -- recursive directories
Date: Sun, 24 Apr 2005 17:09:05 -0400	[thread overview]
Message-ID: <200504241709.05689.jcorbin@wunjo.org> (raw)

After posting the previous patch, I realized it made sense, to me at least ;), 
to have git rm work the same way. Same idea as my previous patch except this 
time the recursion is off by default, must pass -r.

Signed-off-by: Joshua T. Corbin <jcorbin@wunjo.org>

Index: git
===================================================================
--- be4029f0225729bd52a08ac39214264247e1d319/git  (mode:100755 
sha1:24d8c30383fa11d049aafcd659cefe700afe1cf1)
+++ e925e99aef139d50acc11d906be86809f3a08bcb/git  (mode:100755 
sha1:3928887f010454a41853b8a836e1b87eeb0aaf51)
@@ -42,7 +42,7 @@
 	merge		[-c] [-b BASE_ID] FROM_ID
 	patch		[COMMIT_ID | COMMIT_ID:COMMIT_ID]
 	pull		[RNAME]
-	rm		FILE...
+	rm		[-r] FILE...
 	seek		[COMMIT_ID]
 	status
 	tag		TNAME [COMMIT_ID]
Index: gitrm.sh
===================================================================
--- be4029f0225729bd52a08ac39214264247e1d319/gitrm.sh  (mode:100755 
sha1:3cc50fb9f12d2bf93a285ea18daadca7d3f5b549)
+++ e925e99aef139d50acc11d906be86809f3a08bcb/gitrm.sh  (mode:100755 
sha1:236261a53fdce287d32b40b8baf46c338515e555)
@@ -5,11 +5,36 @@
 #
 # Takes a list of file names at the command line, and schedules them
 # for removal from the GIT repository at the next commit.
+# Optional "-r" parameter specifies that you don't want to remove directories
+# recursively.
 
 if [ ! "$1" ]; then
 	echo "gitrm.sh: usage: git rm FILE..." >&2
 	exit 1;
 fi
 
-rm -f "$@"
-update-cache --remove -- "$@"
+recur=
+if [ "$1" = "-r" ]; then
+  shift
+  recur=1
+fi
+
+if [ $recur ]; then
+  RMFILE=$(mktemp -t gitrm.XXXXXX)
+  RMDIRS=
+  while [ "$1" ]; do
+    if [ -d "$1" ]; then
+      RMDIRS="$DIRS $1"
+      find $1 -type f -and -not -name '.*'
+    else
+      echo "$1"
+    fi
+    shift
+  done > $RMFILE
+  rm -f $(cat $RMFILE)
+  rmdir $(find $RMDIRS -depth -type d)
+  update-cache --remove -- $(cat $RMFILE)
+else
+  rm -f "$@"
+  update-cache --remove -- "$@"
+fi

             reply	other threads:[~2005-04-24 21:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-24 21:09 Joshua T. Corbin [this message]
2005-04-24 21:34 ` [PATCH] git rm -- recursive directories Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200504241709.05689.jcorbin@wunjo.org \
    --to=jcorbin@wunjo.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox