Merge branch 'maint'
[gitweb.git] / git.c
diff --git a/git.c b/git.c
index 4e10581101c26444da5c7c44a80219b11607705b..4a250f7e8b84f2334c84daaf93baa0fe1f0ca344 100644 (file)
--- a/git.c
+++ b/git.c
@@ -249,14 +249,9 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
                prefix = setup_git_directory();
        if (p->option & USE_PAGER)
                setup_pager();
-       if (p->option & NEED_WORK_TREE) {
-               const char *work_tree = get_git_work_tree();
-               const char *git_dir = get_git_dir();
-               if (!is_absolute_path(git_dir))
-                       set_git_dir(make_absolute_path(git_dir));
-               if (!work_tree || chdir(work_tree))
-                       die("%s must be run in a work tree", p->cmd);
-       }
+       if (p->option & NEED_WORK_TREE)
+               setup_work_tree();
+
        trace_argv_printf(argv, argc, "trace: built-in: git");
 
        status = p->fn(argc, argv, prefix);
@@ -345,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 },