[PATCH] cg-rm: Add option to remove all files which are gone from the working copy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Dennis Stosberg <dennis@xxxxxxxxxxxx>


---

 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


-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]