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>
Junio C Hamano committed
Jan 3, 2007 at 01:09 UTC
bda324cf6158672b91a478036731d332c1a14cac
1 file changed
+11
-2
wt-status.c
+11
-2
@@ -288,9 +288,18 @@ void wt_status_print(struct wt_status *s)
288
unsigned char sha1[20];
289
s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
290
291
- if (s->branch)
291
+ if (s->branch) {
292
+ const char *on_what = "On branch ";
293
+ const char *branch_name = s->branch;
294
+ if (!strncmp(branch_name, "refs/heads/", 11))
295
+ branch_name += 11;
296
+ else if (!strcmp(branch_name, "HEAD")) {
297
+ branch_name = "";
298
+ on_what = "Not currently on any branch.";
299
+ }
300
color_printf_ln(color(WT_STATUS_HEADER),
293
- "# On branch %s", s->branch);
301
+ "# %s%s", on_what, branch_name);
302
+ }
303
304
if (s->is_initial) {
305
color_printf_ln(color(WT_STATUS_HEADER), "#");