Git development
 help / color / mirror / Atom feed
* [PATCH] git rm -- recursive directories
@ 2005-04-24 21:09 Joshua T. Corbin
  2005-04-24 21:34 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Joshua T. Corbin @ 2005-04-24 21:09 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-04-24 21:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-24 21:09 [PATCH] git rm -- recursive directories Joshua T. Corbin
2005-04-24 21:34 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox