Don't always require working tree for git-rm
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> Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mike Hommey committed
Nov 3, 2007 at 12:23 UTC
271bb08735435b859464c22506ba512f003a4191
2 files changed
+4
-1
builtin-rm.c
+3
@@ -155,6 +155,9 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
155
if (!argc)
156
usage_with_options(builtin_rm_usage, builtin_rm_options);
157
158
+ if (!index_only)
159
+ setup_work_tree();
160
+
161
pathspec = get_pathspec(prefix, argv);
162
seen = NULL;
163
for (i = 0; pathspec[i] ; i++)
git.c
+1
-1
@@ -340,7 +340,7 @@ static void handle_internal_command(int argc, const char **argv)
340
{ "rev-list", cmd_rev_list, RUN_SETUP },
341
{ "rev-parse", cmd_rev_parse, RUN_SETUP },
342
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
343
- { "rm", cmd_rm, RUN_SETUP | NEED_WORK_TREE },
343
+ { "rm", cmd_rm, RUN_SETUP },
344
{ "runstatus", cmd_runstatus, RUN_SETUP | NEED_WORK_TREE },
345
{ "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
346
{ "show-branch", cmd_show_branch, RUN_SETUP },