diff options
author | Junio C Hamano <junkio@cox.net> | 2007-01-03 01:09:34 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-08 03:02:10 -0800 |
commit | bda324cf6158672b91a478036731d332c1a14cac (patch) | |
tree | 1f2059b927132c8cf701aca6c02b438f30c0179c | |
parent | 4083c2fce86c777415a3bc0d5813bcb73f676f98 (diff) | |
download | git-bda324cf6158672b91a478036731d332c1a14cac.tar.gz |
git-status: show detached HEAD
This makes git-status to state when you are not on any branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | wt-status.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/wt-status.c b/wt-status.c index c48127daca..2a002baabd 100644 --- a/wt-status.c +++ b/wt-status.c @@ -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), "#"); |