]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'rs/wt-status-detached-branch-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 5 Nov 2015 20:18:15 +0000 (12:18 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Nov 2015 20:18:15 +0000 (12:18 -0800)
"git status --branch --short" accessed beyond the constant string
"HEAD", which has been corrected.

* rs/wt-status-detached-branch-fix:
  wt-status: use skip_prefix() to get rid of magic string length constants
  wt-status: don't skip a magical number of characters blindly
  wt-status: avoid building bogus branch name with detached HEAD
  wt-status: exit early using goto in wt_shortstatus_print_tracking()
  t7060: add test for status --branch on a detached HEAD

1  2 
t/t7060-wtstatus.sh
wt-status.c

Simple merge
diff --cc wt-status.c
index 3e3b8c098924d655bccb395e95cee832abb1d39f,62383a27f93cf4594b0669a22fa14031931badcb..435fc2806ec0a59acf390ee89ed2efc79f229a0e
@@@ -1442,15 -1318,10 +1438,13 @@@ void wt_status_print(struct wt_status *
        if (s->branch) {
                const char *on_what = _("On branch ");
                const char *branch_name = s->branch;
-               if (starts_with(branch_name, "refs/heads/"))
-                       branch_name += 11;
-               else if (!strcmp(branch_name, "HEAD")) {
+               if (!strcmp(branch_name, "HEAD")) {
                        branch_status_color = color(WT_STATUS_NOBRANCH, s);
                        if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
 -                              on_what = _("rebase in progress; onto ");
 +                              if (state.rebase_interactive_in_progress)
 +                                      on_what = _("interactive rebase in progress; onto ");
 +                              else
 +                                      on_what = _("rebase in progress; onto ");
                                branch_name = state.onto;
                        } else if (state.detached_from) {
                                branch_name = state.detached_from;