diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh index 879d0c169d6..58df3f3bb1a 100755 --- a/t/t7060-wtstatus.sh +++ b/t/t7060-wtstatus.sh @@ -213,7 +213,7 @@ EOF git checkout master ' -test_expect_failure 'status --branch with detached HEAD' ' +test_expect_success 'status --branch with detached HEAD' ' git reset --hard && git checkout master^0 && git status --branch --porcelain >actual && diff --git a/wt-status.c b/wt-status.c index ac05b9b73d7..0e4a04e695f 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1521,17 +1521,20 @@ static void wt_shortstatus_print_tracking(struct wt_status *s) return; branch_name = s->branch; - if (starts_with(branch_name, "refs/heads/")) - branch_name += 11; - else if (!strcmp(branch_name, "HEAD")) { - branch_name = _("HEAD (no branch)"); - branch_color_local = color(WT_STATUS_NOBRANCH, s); - } - - branch = branch_get(s->branch + 11); if (s->is_initial) color_fprintf(s->fp, header_color, _("Initial commit on ")); + if (!strcmp(s->branch, "HEAD")) { + color_fprintf(s->fp, color(WT_STATUS_NOBRANCH, s), "%s", + _("HEAD (no branch)")); + goto conclude; + } + + if (starts_with(branch_name, "refs/heads/")) + branch_name += 11; + + branch = branch_get(s->branch + 11); + color_fprintf(s->fp, branch_color_local, "%s", branch_name); if (stat_tracking_info(branch, &num_ours, &num_theirs, &base) < 0) {