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

[PATCH 3/3] Don't always require working tree for git-rm

From
Mike Hommey <mh@glandium.org>
Date
Nov 3, 2007, 11:23 UTC
Message-ID
<1194088993-25692-3-git-send-email-mh@glandium.org>
In-Reply-To
<1194088993-25692-2-git-send-email-mh@glandium.org>

This allows to do git rm --cached -r directory, instead of git ls-files -z directory | git update-index --remove -z --stdin. This can be particularly useful for git-filter-branch users.

Signed-off-by: Mike Hommey <mh@glandium.org>
---

This replaces the patch from http://article.gmane.org/gmane.comp.version-control.git/63227

 builtin-rm.c |    3 +++
 git.c        |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/builtin-rm.c b/builtin-rm.c
index bca2bd9..a3d25e6 100644
--- a/builtin-rm.c
+++ b/builtin-rm.c
@@ -155,6 +155,9 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	if (!argc)
 		usage_with_options(builtin_rm_usage, builtin_rm_options);
 
+	if (!index_only)
+		setup_work_tree();
+
 	pathspec = get_pathspec(prefix, argv);
 	seen = NULL;
 	for (i = 0; pathspec[i] ; i++)
diff --git a/git.c b/git.c
index eb31c93..4a250f7 100644
--- a/git.c
+++ b/git.c
@@ -340,7 +340,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "rev-list", cmd_rev_list, RUN_SETUP },
 		{ "rev-parse", cmd_rev_parse, RUN_SETUP },
 		{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
-		{ "rm", cmd_rm, RUN_SETUP | NEED_WORK_TREE },
+		{ "rm", cmd_rm, RUN_SETUP },
 		{ "runstatus", cmd_runstatus, RUN_SETUP | NEED_WORK_TREE },
 		{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
 		{ "show-branch", cmd_show_branch, RUN_SETUP },
-- 
1.5.3.5
Previous: Mike HommeyNext: Johannes Schindelin
Message 3 of 6 in “Refactor working tree setup”
  1. 1/3 Refactor working tree setupMike Hommey, Nov 3, 2007
  2. 2/3 Use setup_work_tree() in builtin-ls-files.cMike Hommey, Nov 3, 2007
  3. 3/3 Don't always require working tree for git-rmMike Hommey, Nov 3, 2007
  4. Johannes SchindelinNov 3, 2007
  5. Miles BaderNov 8, 2007
  6. Junio C HamanoNov 8, 2007

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.