Git development
 help / color / mirror / Atom feed
* [PATCH] cg-rm: Add option to remove all files which are gone from the working copy
@ 2006-04-06 16:17 Dennis Stosberg
  0 siblings, 0 replies; only message in thread
From: Dennis Stosberg @ 2006-04-06 16:17 UTC (permalink / raw)
  To: git

Add an -a option to cg-rm, which removes all files that have been
physically deleted.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>


---

 cg-rm |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

ac5fc0c8d9c9ccecba7cbf83a74a163bff79f8f4
diff --git a/cg-rm b/cg-rm
index 5ab5dc8..0276632 100755
--- a/cg-rm
+++ b/cg-rm
@@ -19,13 +19,18 @@ #
 # -r:: Remove files recursively
 #	If you pass cg-rm this flag and any directory names, it will try
 #	to remove files in those directories recursively.
+#
+# -a:: Remove all files which are gone from the working copy
+#	Remove all files which have been deleted in the working copy
+#	from the index.
 
-USAGE="cg-rm [-f] [-n] [-r] FILE..."
+USAGE="cg-rm [-f] [-n] [-r] [-a] FILE..."
 
 . "${COGITO_LIB}"cg-Xlib || exit 1
 
 delete=
 recursive=
+rmgone=
 while optparse; do
 	if optparse -f; then
 		delete=1
@@ -33,12 +38,14 @@ while optparse; do
 		delete=
 	elif optparse -r; then
 		recursive=1
+	elif optparse -a; then
+		rmgone=1
 	else
 		optfail
 	fi
 done
 
-[ -n "${ARGS[*]}" ] || usage
+[ -n "${ARGS[*]}" -o "$rmgone" ] || usage
 
 TMPFILE="$(mktemp -t gitrm.XXXXXX)" || exit 1
 TMPDIRFILE="$(mktemp -t gitrm.XXXXXX)" || exit 1
@@ -57,6 +64,14 @@ for file in "${ARGS[@]}"; do
 		echo "$file" >>"$TMPFILE"
 	fi
 done
+
+if [ "$rmgone" ]; then
+	cg-status -s \! -n -w >>"$TMPFILE"
+	if [ ! $(cat "$TMPFILE" | sed -n "$=") ]; then
+		rm "$TMPFILE" "$TMPDIRFILE"
+		die "no files to remove"
+	fi
+fi
 
 cat "$TMPFILE" | sed 's/^/Removing file /'
 if [ "$delete" ]; then (
-- 
1.3-rc2.GIT

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-06 16:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-06 16:17 [PATCH] cg-rm: Add option to remove all files which are gone from the working copy Dennis Stosberg

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