Code

git-status: show detached HEAD
authorJunio C Hamano <junkio@cox.net>
Wed, 3 Jan 2007 09:09:34 +0000 (01:09 -0800)
committerJunio C Hamano <junkio@cox.net>
Mon, 8 Jan 2007 11:02:10 +0000 (03:02 -0800)
This makes git-status to state when you are not on any branch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
wt-status.c

index c48127daca9b96ce43a86508705dbaa4c24059be..2a002baabd2eeb166ffbe6634d7b1ecf0b04bbc6 100644 (file)
@@ -288,9 +288,18 @@ void wt_status_print(struct wt_status *s)
        unsigned char sha1[20];
        s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
 
-       if (s->branch)
+       if (s->branch) {
+               const char *on_what = "On branch ";
+               const char *branch_name = s->branch;
+               if (!strncmp(branch_name, "refs/heads/", 11))
+                       branch_name += 11;
+               else if (!strcmp(branch_name, "HEAD")) {
+                       branch_name = "";
+                       on_what = "Not currently on any branch.";
+               }
                color_printf_ln(color(WT_STATUS_HEADER),
-                       "# On branch %s", s->branch);
+                       "# %s%s", on_what, branch_name);
+       }
 
        if (s->is_initial) {
                color_printf_ln(color(WT_STATUS_HEADER), "#");