{"thread":{"id":"3812","subject":"[PATCH] cg-rm: Add option to remove all files which are gone from the working copy","startedAt":"2006-04-06T16:17:44Z","lastAt":"2006-04-06T16:17:44Z","messageCount":1,"participants":["Dennis Stosberg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"18425","messageId":"20060406161744.G5527deba@leonov.stosberg.net","threadId":"3812","inReplyTo":null,"subject":"[PATCH] cg-rm: Add option to remove all files which are gone from the working copy","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-04-06T16:17:44Z","receivedAt":"2006-04-06T16:17:44Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"Add an -a option to cg-rm, which removes all files that have been\nphysically deleted.\n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n\n\n---\n\n cg-rm |   19 +++++++++++++++++--\n 1 files changed, 17 insertions(+), 2 deletions(-)\n\nac5fc0c8d9c9ccecba7cbf83a74a163bff79f8f4\ndiff --git a/cg-rm b/cg-rm\nindex 5ab5dc8..0276632 100755\n--- a/cg-rm\n+++ b/cg-rm\n@@ -19,13 +19,18 @@ #\n # -r:: Remove files recursively\n #\tIf you pass cg-rm this flag and any directory names, it will try\n #\tto remove files in those directories recursively.\n+#\n+# -a:: Remove all files which are gone from the working copy\n+#\tRemove all files which have been deleted in the working copy\n+#\tfrom the index.\n \n-USAGE=\"cg-rm [-f] [-n] [-r] FILE...\"\n+USAGE=\"cg-rm [-f] [-n] [-r] [-a] FILE...\"\n \n . \"${COGITO_LIB}\"cg-Xlib || exit 1\n \n delete=\n recursive=\n+rmgone=\n while optparse; do\n \tif optparse -f; then\n \t\tdelete=1\n@@ -33,12 +38,14 @@ while optparse; do\n \t\tdelete=\n \telif optparse -r; then\n \t\trecursive=1\n+\telif optparse -a; then\n+\t\trmgone=1\n \telse\n \t\toptfail\n \tfi\n done\n \n-[ -n \"${ARGS[*]}\" ] || usage\n+[ -n \"${ARGS[*]}\" -o \"$rmgone\" ] || usage\n \n TMPFILE=\"$(mktemp -t gitrm.XXXXXX)\" || exit 1\n TMPDIRFILE=\"$(mktemp -t gitrm.XXXXXX)\" || exit 1\n@@ -57,6 +64,14 @@ for file in \"${ARGS[@]}\"; do\n \t\techo \"$file\" >>\"$TMPFILE\"\n \tfi\n done\n+\n+if [ \"$rmgone\" ]; then\n+\tcg-status -s \\! -n -w >>\"$TMPFILE\"\n+\tif [ ! $(cat \"$TMPFILE\" | sed -n \"$=\") ]; then\n+\t\trm \"$TMPFILE\" \"$TMPDIRFILE\"\n+\t\tdie \"no files to remove\"\n+\tfi\n+fi\n \n cat \"$TMPFILE\" | sed 's/^/Removing file /'\n if [ \"$delete\" ]; then (\n-- \n1.3-rc2.GIT\n"}]}