Skip to content

Commit

Permalink
git-status: show detached HEAD
Browse files Browse the repository at this point in the history
This makes git-status to state when you are not on any branch.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Jan 8, 2007
1 parent 4083c2f commit bda324c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -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), "#");
Expand Down

0 comments on commit bda324c

Please sign in to comment.