Merge branch 'jc/add-u-A-default-to-top' into maint
[gitweb.git] / wt-status.c
index 04e01e42383f555bd819701e381aaf974bf5e12e..3e3b8c098924d655bccb395e95cee832abb1d39f 100644 (file)
@@ -1,5 +1,4 @@
 #include "cache.h"
-#include "pathspec.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
@@ -1171,7 +1170,7 @@ static void show_rebase_in_progress(struct wt_status *s,
                        status_printf_ln(s, color,
                                _("  (use \"git rebase --abort\" to check out the original branch)"));
                }
-       } else if (state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
+       } else if (state->rebase_in_progress || !stat(git_path_merge_msg(), &st)) {
                print_rebase_state(s, state, color);
                if (s->hints)
                        status_printf_ln(s, color,
@@ -1320,6 +1319,12 @@ static int grab_1st_switch(unsigned char *osha1, unsigned char *nsha1,
        hashcpy(cb->nsha1, nsha1);
        for (end = target; *end && *end != '\n'; end++)
                ;
+       if (!memcmp(target, "HEAD", end - target)) {
+               /* HEAD is relative. Resolve it to the right reflog entry. */
+               strbuf_addstr(&cb->buf,
+                             find_unique_abbrev(nsha1, DEFAULT_ABBREV));
+               return 1;
+       }
        strbuf_add(&cb->buf, target, end - target);
        return 1;
 }
@@ -1368,7 +1373,7 @@ void wt_status_get_state(struct wt_status_state *state,
        struct stat st;
        unsigned char sha1[20];
 
-       if (!stat(git_path("MERGE_HEAD"), &st)) {
+       if (!stat(git_path_merge_head(), &st)) {
                state->merge_in_progress = 1;
        } else if (!stat(git_path("rebase-apply"), &st)) {
                if (!stat(git_path("rebase-apply/applying"), &st)) {
@@ -1387,7 +1392,7 @@ void wt_status_get_state(struct wt_status_state *state,
                        state->rebase_in_progress = 1;
                state->branch = read_and_strip_branch("rebase-merge/head-name");
                state->onto = read_and_strip_branch("rebase-merge/onto");
-       } else if (!stat(git_path("CHERRY_PICK_HEAD"), &st) &&
+       } else if (!stat(git_path_cherry_pick_head(), &st) &&
                        !get_sha1("CHERRY_PICK_HEAD", sha1)) {
                state->cherry_pick_in_progress = 1;
                hashcpy(state->cherry_pick_head_sha1, sha1);
@@ -1396,7 +1401,7 @@ void wt_status_get_state(struct wt_status_state *state,
                state->bisect_in_progress = 1;
                state->branch = read_and_strip_branch("BISECT_START");
        }
-       if (!stat(git_path("REVERT_HEAD"), &st) &&
+       if (!stat(git_path_revert_head(), &st) &&
            !get_sha1("REVERT_HEAD", sha1)) {
                state->revert_in_progress = 1;
                hashcpy(state->revert_head_sha1, sha1);