From: Dennis Stosberg <dennis@stosberg.net>
To: git@vger.kernel.org
Subject: [PATCH] cg-rm: Add option to remove all files which are gone from the working copy
Date: Thu, 6 Apr 2006 18:17:44 +0200 [thread overview]
Message-ID: <20060406161744.G5527deba@leonov.stosberg.net> (raw)
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
reply other threads:[~2006-04-06 16:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20060406161744.G5527deba@leonov.stosberg.net \
--to=dennis@stosberg.net \
--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