push: support pushing HEAD to real branch name
[gitweb.git] / git.c
diff --git a/git.c b/git.c
index 4e10581101c26444da5c7c44a80219b11607705b..7604319b5a9e8c12b2f00b4d5e6480445e02daa6 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);
@@ -343,9 +338,9 @@ static void handle_internal_command(int argc, const char **argv)
                { "rerere", cmd_rerere, RUN_SETUP },
                { "reset", cmd_reset, RUN_SETUP },
                { "rev-list", cmd_rev_list, RUN_SETUP },
-               { "rev-parse", cmd_rev_parse, RUN_SETUP },
+               { "rev-parse", cmd_rev_parse },
                { "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 },