diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-01 09:05:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-01 09:05:45 -0700 |
commit | afc2e81247042e11d9cf981ac5671746caddc22a (patch) | |
tree | bd55302ff9258081eeb50570b4c6dd95da838238 /builtin | |
parent | 6d37c162bb5b9cb4453e43d4488e953fe65cc67e (diff) | |
parent | 6deab24d8832e3cb2f554b827af521b094a2b32d (diff) | |
download | git-afc2e81247042e11d9cf981ac5671746caddc22a.tar.gz |
Merge branch 'nd/branch-show-rebase-bisect-state'
Add a bit more information to "git status" during a rebase/bisect
session.
* nd/branch-show-rebase-bisect-state:
status, branch: fix the misleading "bisecting" message
branch: show more information when HEAD is detached
status: show more info than "currently not on any branch"
wt-status: move wt_status_get_state() out to wt_status_print()
wt-status: split wt_status_state parsing function out
wt-status: move strbuf into read_and_strip_branch()
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/branch.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index 00d17d25d1..e09ce51c2e 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -18,6 +18,7 @@ #include "string-list.h" #include "column.h" #include "utf8.h" +#include "wt-status.h" static const char * const builtin_branch_usage[] = { N_("git branch [options] [-r | -a] [--merged | --no-merged]"), @@ -550,6 +551,29 @@ static int calc_maxwidth(struct ref_list *refs) return w; } +static char *get_head_description(void) +{ + struct strbuf desc = STRBUF_INIT; + struct wt_status_state state; + memset(&state, 0, sizeof(state)); + wt_status_get_state(&state, 1); + if (state.rebase_in_progress || + state.rebase_interactive_in_progress) + strbuf_addf(&desc, _("(no branch, rebasing %s)"), + state.branch); + else if (state.bisect_in_progress) + strbuf_addf(&desc, _("(no branch, bisect started on %s)"), + state.branch); + else if (state.detached_from) + strbuf_addf(&desc, _("(detached from %s)"), + state.detached_from); + else + strbuf_addstr(&desc, _("(no branch)")); + free(state.branch); + free(state.onto); + free(state.detached_from); + return strbuf_detach(&desc, NULL); +} static void show_detached(struct ref_list *ref_list) { @@ -557,7 +581,7 @@ static void show_detached(struct ref_list *ref_list) if (head_commit && is_descendant_of(head_commit, ref_list->with_commit)) { struct ref_item item; - item.name = xstrdup(_("(no branch)")); + item.name = get_head_description(); item.width = utf8_strwidth(item.name); item.kind = REF_LOCAL_BRANCH; item.dest = NULL; |