Sync with 'maint'
[gitweb.git] / builtin / branch.c
index 94f7de7fa5da4a27dab99c582c5dfbbf25169048..5d44e36cba0e030cb77461784a65f77c44cb67cd 100644 (file)
@@ -191,17 +191,20 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
        int ret = 0;
        int remote_branch = 0;
        struct strbuf bname = STRBUF_INIT;
+       unsigned allowed_interpret;
 
        switch (kinds) {
        case FILTER_REFS_REMOTES:
                fmt = "refs/remotes/%s";
                /* For subsequent UI messages */
                remote_branch = 1;
+               allowed_interpret = INTERPRET_BRANCH_REMOTE;
 
                force = 1;
                break;
        case FILTER_REFS_BRANCHES:
                fmt = "refs/heads/%s";
+               allowed_interpret = INTERPRET_BRANCH_LOCAL;
                break;
        default:
                die(_("cannot use -a with -d"));
@@ -216,7 +219,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                char *target = NULL;
                int flags = 0;
 
-               strbuf_branchname(&bname, argv[i]);
+               strbuf_branchname(&bname, argv[i], allowed_interpret);
                free(name);
                name = mkpathdup(fmt, bname.buf);
 
@@ -335,9 +338,18 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
                    branch_get_color(BRANCH_COLOR_CURRENT));
 
        if (filter->verbose) {
+               struct strbuf obname = STRBUF_INIT;
+
+               if (filter->abbrev < 0)
+                       strbuf_addf(&obname, "%%(objectname:short)");
+               else if (!filter->abbrev)
+                       strbuf_addf(&obname, "%%(objectname)");
+               else
+                       strbuf_addf(&obname, "%%(objectname:short=%d)", filter->abbrev);
+
                strbuf_addf(&local, "%%(align:%d,left)%%(refname:lstrip=2)%%(end)", maxwidth);
                strbuf_addf(&local, "%s", branch_get_color(BRANCH_COLOR_RESET));
-               strbuf_addf(&local, " %%(objectname:short=7) ");
+               strbuf_addf(&local, " %s ", obname.buf);
 
                if (filter->verbose > 1)
                        strbuf_addf(&local, "%%(if)%%(upstream)%%(then)[%s%%(upstream:short)%s%%(if)%%(upstream:track)"
@@ -346,10 +358,12 @@ static char *build_format(struct ref_filter *filter, int maxwidth, const char *r
                else
                        strbuf_addf(&local, "%%(if)%%(upstream:track)%%(then)%%(upstream:track) %%(end)%%(contents:subject)");
 
-               strbuf_addf(&remote, "%s%%(align:%d,left)%s%%(refname:lstrip=2)%%(end)%s%%(if)%%(symref)%%(then) -> %%(symref:short)"
-                           "%%(else) %%(objectname:short=7) %%(contents:subject)%%(end)",
+               strbuf_addf(&remote, "%s%%(align:%d,left)%s%%(refname:lstrip=2)%%(end)%s"
+                           "%%(if)%%(symref)%%(then) -> %%(symref:short)"
+                           "%%(else) %s %%(contents:subject)%%(end)",
                            branch_get_color(BRANCH_COLOR_REMOTE), maxwidth, quote_literal_for_format(remote_prefix),
-                           branch_get_color(BRANCH_COLOR_RESET));
+                           branch_get_color(BRANCH_COLOR_RESET), obname.buf);
+               strbuf_release(&obname);
        } else {
                strbuf_addf(&local, "%%(refname:lstrip=2)%s%%(if)%%(symref)%%(then) -> %%(symref:short)%%(end)",
                            branch_get_color(BRANCH_COLOR_RESET));