Merge branch 'jc/diff-filter-negation'
[gitweb.git] / builtin / show-branch.c
index 7c57985c40095a4e068f5f60772cf46617f52a55..001f29ca1b9ef8bfe2a06cda4d98c704584812fe 100644 (file)
@@ -162,29 +162,28 @@ static void name_commits(struct commit_list *list,
                        nth = 0;
                        while (parents) {
                                struct commit *p = parents->item;
-                               char newname[1000], *en;
+                               struct strbuf newname = STRBUF_INIT;
                                parents = parents->next;
                                nth++;
                                if (p->util)
                                        continue;
-                               en = newname;
                                switch (n->generation) {
                                case 0:
-                                       en += sprintf(en, "%s", n->head_name);
+                                       strbuf_addstr(&newname, n->head_name);
                                        break;
                                case 1:
-                                       en += sprintf(en, "%s^", n->head_name);
+                                       strbuf_addf(&newname, "%s^", n->head_name);
                                        break;
                                default:
-                                       en += sprintf(en, "%s~%d",
-                                               n->head_name, n->generation);
+                                       strbuf_addf(&newname, "%s~%d",
+                                                   n->head_name, n->generation);
                                        break;
                                }
                                if (nth == 1)
-                                       en += sprintf(en, "^");
+                                       strbuf_addch(&newname, '^');
                                else
-                                       en += sprintf(en, "^%d", nth);
-                               name_commit(p, xstrdup(newname), 0);
+                                       strbuf_addf(&newname, "^%d", nth);
+                               name_commit(p, strbuf_detach(&newname, NULL), 0);
                                i++;
                                name_first_parent_chain(p);
                        }
@@ -647,35 +646,35 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
        int dense = 1;
        const char *reflog_base = NULL;
        struct option builtin_show_branch_options[] = {
-               OPT_BOOLEAN('a', "all", &all_heads,
-                           N_("show remote-tracking and local branches")),
-               OPT_BOOLEAN('r', "remotes", &all_remotes,
-                           N_("show remote-tracking branches")),
+               OPT_BOOL('a', "all", &all_heads,
+                        N_("show remote-tracking and local branches")),
+               OPT_BOOL('r', "remotes", &all_remotes,
+                        N_("show remote-tracking branches")),
                OPT__COLOR(&showbranch_use_color,
                            N_("color '*!+-' corresponding to the branch")),
                { OPTION_INTEGER, 0, "more", &extra, N_("n"),
                            N_("show <n> more commits after the common ancestor"),
                            PARSE_OPT_OPTARG, NULL, (intptr_t)1 },
                OPT_SET_INT(0, "list", &extra, N_("synonym to more=-1"), -1),
-               OPT_BOOLEAN(0, "no-name", &no_name, N_("suppress naming strings")),
-               OPT_BOOLEAN(0, "current", &with_current_branch,
-                           N_("include the current branch")),
-               OPT_BOOLEAN(0, "sha1-name", &sha1_name,
-                           N_("name commits with their object names")),
-               OPT_BOOLEAN(0, "merge-base", &merge_base,
-                           N_("show possible merge bases")),
-               OPT_BOOLEAN(0, "independent", &independent,
+               OPT_BOOL(0, "no-name", &no_name, N_("suppress naming strings")),
+               OPT_BOOL(0, "current", &with_current_branch,
+                        N_("include the current branch")),
+               OPT_BOOL(0, "sha1-name", &sha1_name,
+                        N_("name commits with their object names")),
+               OPT_BOOL(0, "merge-base", &merge_base,
+                        N_("show possible merge bases")),
+               OPT_BOOL(0, "independent", &independent,
                            N_("show refs unreachable from any other ref")),
                OPT_SET_INT(0, "topo-order", &sort_order,
                            N_("show commits in topological order"),
                            REV_SORT_IN_GRAPH_ORDER),
-               OPT_BOOLEAN(0, "topics", &topics,
-                           N_("show only commits not on the first branch")),
+               OPT_BOOL(0, "topics", &topics,
+                        N_("show only commits not on the first branch")),
                OPT_SET_INT(0, "sparse", &dense,
                            N_("show merges reachable from only one tip"), 0),
                OPT_SET_INT(0, "date-order", &sort_order,
-                           N_("show commits where no parent comes before its "
-                              "children"),
+                           N_("topologically sort, maintaining date order "
+                              "where possible"),
                            REV_SORT_BY_COMMIT_DATE),
                { OPTION_CALLBACK, 'g', "reflog", &reflog_base, N_("<n>[,<base>]"),
                            N_("show <n> most recent ref-log entries starting at "