From: Mike Hommey Date: Sat, 3 Nov 2007 11:23:13 +0000 (+0100) Subject: Don't always require working tree for git-rm X-Git-Tag: v1.5.4-rc0~254^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=271bb08735435b859464c22506ba512f003a4191;p=git.git 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 Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- diff --git a/builtin-rm.c b/builtin-rm.c index bca2bd970..a3d25e6a5 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 eb31c93d0..4a250f7e8 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 },