From: Ryan Schmitt <rschmitt@pobox.com>
To: git@vger.kernel.org
Cc: Ryan Schmitt <rschmitt@u.rochester.edu>,
Ryan Schmitt <rschmitt@pobox.com>
Subject: [PATCH] rm: Accept --staged as a synonym of --cached
Date: Fri, 21 Feb 2014 21:30:09 -0800 [thread overview]
Message-ID: <1393047009-30168-1-git-send-email-rschmitt@pobox.com> (raw)
From: Ryan Schmitt <rschmitt@u.rochester.edu>
This makes git-rm more consistent with git-diff, which also accepts
--staged as a synonym of --cached.
Signed-off-by: Ryan Schmitt <rschmitt@pobox.com>
---
Documentation/git-rm.txt | 2 +-
builtin/rm.c | 1 +
t/t3600-rm.sh | 6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git Documentation/git-rm.txt Documentation/git-rm.txt
index f1efc11..8635e67 100644
--- Documentation/git-rm.txt
+++ Documentation/git-rm.txt
@@ -58,7 +58,7 @@ OPTIONS
--cached::
Use this option to unstage and remove paths only from the index.
Working tree files, whether modified or not, will be
- left alone.
+ left alone. --staged is a synonym for --cached.
--ignore-unmatch::
Exit with a zero status even if no files matched.
diff --git builtin/rm.c builtin/rm.c
index 960634d..a88697b 100644
--- builtin/rm.c
+++ builtin/rm.c
@@ -269,6 +269,7 @@ static struct option builtin_rm_options[] = {
OPT__DRY_RUN(&show_only, N_("dry run")),
OPT__QUIET(&quiet, N_("do not list removed files")),
OPT_BOOL( 0 , "cached", &index_only, N_("only remove from the index")),
+ OPT_BOOL( 0 , "staged", &index_only, N_("synonym for --cached")),
OPT__FORCE(&force, N_("override the up-to-date check")),
OPT_BOOL('r', NULL, &recursive, N_("allow recursive removal")),
OPT_BOOL( 0 , "ignore-unmatch", &ignore_unmatch,
diff --git t/t3600-rm.sh t/t3600-rm.sh
index 3d30581..c32dbf4 100755
--- t/t3600-rm.sh
+++ t/t3600-rm.sh
@@ -72,6 +72,12 @@ test_expect_success \
git rm --cached -f foo'
test_expect_success \
+ 'Test that git rm --staged foo is synonymous with git rm --cached foo' \
+ 'echo content > foo
+ git add foo
+ git rm --staged foo'
+
+test_expect_success \
'Post-check that foo exists but is not in index after git rm foo' \
'[ -f foo ] && test_must_fail git ls-files --error-unmatch foo'
--
1.8.3.2
reply other threads:[~2014-02-22 5:30 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=1393047009-30168-1-git-send-email-rschmitt@pobox.com \
--to=rschmitt@pobox.com \
--cc=git@vger.kernel.org \
--cc=rschmitt@u.rochester.edu \
/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;
as well as URLs for NNTP newsgroup(s).