Merge branch 'ds/commit-graph-write-refactor'
[gitweb.git] / builtin / branch.c
index d4359b33ac0fb27b6b8be7109a2a862bc9cd2d77..2ef214632f025b0da7bf5f118aebe3c68d5af2f8 100644 (file)
@@ -47,6 +47,7 @@ static char branch_colors[][COLOR_MAXLEN] = {
        GIT_COLOR_NORMAL,       /* LOCAL */
        GIT_COLOR_GREEN,        /* CURRENT */
        GIT_COLOR_BLUE,         /* UPSTREAM */
+       GIT_COLOR_CYAN,         /* WORKTREE */
 };
 enum color_branch {
        BRANCH_COLOR_RESET = 0,
@@ -54,7 +55,8 @@ enum color_branch {
        BRANCH_COLOR_REMOTE = 2,
        BRANCH_COLOR_LOCAL = 3,
        BRANCH_COLOR_CURRENT = 4,
-       BRANCH_COLOR_UPSTREAM = 5
+       BRANCH_COLOR_UPSTREAM = 5,
+       BRANCH_COLOR_WORKTREE = 6
 };
 
 static const char *color_branch_slots[] = {
@@ -64,6 +66,7 @@ static const char *color_branch_slots[] = {
        [BRANCH_COLOR_LOCAL]    = "local",
        [BRANCH_COLOR_CURRENT]  = "current",
        [BRANCH_COLOR_UPSTREAM] = "upstream",
+       [BRANCH_COLOR_WORKTREE] = "worktree",
 };
 
 static struct string_list output = STRING_LIST_INIT_DUP;
@@ -342,9 +345,10 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
        struct strbuf local = STRBUF_INIT;
        struct strbuf remote = STRBUF_INIT;
 
-       strbuf_addf(&local, "%%(if)%%(HEAD)%%(then)* %s%%(else)  %s%%(end)",
-                   branch_get_color(BRANCH_COLOR_CURRENT),
-                   branch_get_color(BRANCH_COLOR_LOCAL));
+       strbuf_addf(&local, "%%(if)%%(HEAD)%%(then)* %s%%(else)%%(if)%%(worktreepath)%%(then)+ %s%%(else)  %s%%(end)%%(end)",
+                       branch_get_color(BRANCH_COLOR_CURRENT),
+                       branch_get_color(BRANCH_COLOR_WORKTREE),
+                       branch_get_color(BRANCH_COLOR_LOCAL));
        strbuf_addf(&remote, "  %s",
                    branch_get_color(BRANCH_COLOR_REMOTE));
 
@@ -363,9 +367,13 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
                strbuf_addf(&local, " %s ", obname.buf);
 
                if (filter->verbose > 1)
+               {
+                       strbuf_addf(&local, "%%(if:notequals=*)%%(HEAD)%%(then)%%(if)%%(worktreepath)%%(then)(%s%%(worktreepath)%s) %%(end)%%(end)",
+                                   branch_get_color(BRANCH_COLOR_WORKTREE), branch_get_color(BRANCH_COLOR_RESET));
                        strbuf_addf(&local, "%%(if)%%(upstream)%%(then)[%s%%(upstream:short)%s%%(if)%%(upstream:track)"
                                    "%%(then): %%(upstream:track,nobracket)%%(end)] %%(end)%%(contents:subject)",
                                    branch_get_color(BRANCH_COLOR_UPSTREAM), branch_get_color(BRANCH_COLOR_RESET));
+               }
                else
                        strbuf_addf(&local, "%%(if)%%(upstream:track)%%(then)%%(upstream:track) %%(end)%%(contents:subject)");
 
@@ -830,7 +838,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                strbuf_release(&buf);
        } else if (argc > 0 && argc <= 2) {
                if (filter.kind != FILTER_REFS_BRANCHES)
-                       die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
+                       die(_("The -a, and -r, options to 'git branch' do not take a branch name.\n"
+                                 "Did you mean to use: -a|-r --list <pattern>?"));
 
                if (track == BRANCH_TRACK_OVERRIDE)
                        die(_("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead."));