git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] rm: Accept --staged as a synonym of --cached

From
RSRyan Schmitt <rschmitt@pobox.com>
Date
Feb 22, 2014, 05:30 UTC
Message-ID
<1393047009-30168-1-git-send-email-rschmitt@pobox.com>
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
Message 1 of 1 in “rm: Accept --staged as a synonym of --cached”
  1. rm: Accept --staged as a synonym of --cachedRyan Schmitt, Feb 22, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.