~ubuntu-branches/debian/sid/git/sid

« back to all changes in this revision

Viewing changes to builtin/show-branch.c

  • Committer: Package Import Robot
  • Author(s): Jonathan Nieder
  • Date: 2013-06-12 07:50:53 UTC
  • mfrom: (1.2.19) (2.1.31 experimental)
  • Revision ID: package-import@ubuntu.com-20130612075053-uue9xe0dq0rvm44y
Tags: 1:1.8.3.1-1
* merge branch debian-experimental
* new upstream point release (see RelNotes/1.8.3.1.txt).
* debian/watch: use xz-compressed tarballs from kernel.org.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#include "parse-options.h"
7
7
 
8
8
static const char* show_branch_usage[] = {
9
 
    "git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=<when>] | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]",
10
 
    "git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]",
 
9
    N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=<when>] | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"),
 
10
    N_("git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]"),
11
11
    NULL
12
12
};
13
13
 
162
162
                        nth = 0;
163
163
                        while (parents) {
164
164
                                struct commit *p = parents->item;
165
 
                                char newname[1000], *en;
 
165
                                struct strbuf newname = STRBUF_INIT;
166
166
                                parents = parents->next;
167
167
                                nth++;
168
168
                                if (p->util)
169
169
                                        continue;
170
 
                                en = newname;
171
170
                                switch (n->generation) {
172
171
                                case 0:
173
 
                                        en += sprintf(en, "%s", n->head_name);
 
172
                                        strbuf_addstr(&newname, n->head_name);
174
173
                                        break;
175
174
                                case 1:
176
 
                                        en += sprintf(en, "%s^", n->head_name);
 
175
                                        strbuf_addf(&newname, "%s^", n->head_name);
177
176
                                        break;
178
177
                                default:
179
 
                                        en += sprintf(en, "%s~%d",
180
 
                                                n->head_name, n->generation);
 
178
                                        strbuf_addf(&newname, "%s~%d",
 
179
                                                    n->head_name, n->generation);
181
180
                                        break;
182
181
                                }
183
182
                                if (nth == 1)
184
 
                                        en += sprintf(en, "^");
 
183
                                        strbuf_addch(&newname, '^');
185
184
                                else
186
 
                                        en += sprintf(en, "^%d", nth);
187
 
                                name_commit(p, xstrdup(newname), 0);
 
185
                                        strbuf_addf(&newname, "^%d", nth);
 
186
                                name_commit(p, strbuf_detach(&newname, NULL), 0);
188
187
                                i++;
189
188
                                name_first_parent_chain(p);
190
189
                        }
648
647
        const char *reflog_base = NULL;
649
648
        struct option builtin_show_branch_options[] = {
650
649
                OPT_BOOLEAN('a', "all", &all_heads,
651
 
                            "show remote-tracking and local branches"),
 
650
                            N_("show remote-tracking and local branches")),
652
651
                OPT_BOOLEAN('r', "remotes", &all_remotes,
653
 
                            "show remote-tracking branches"),
 
652
                            N_("show remote-tracking branches")),
654
653
                OPT__COLOR(&showbranch_use_color,
655
 
                            "color '*!+-' corresponding to the branch"),
656
 
                { OPTION_INTEGER, 0, "more", &extra, "n",
657
 
                            "show <n> more commits after the common ancestor",
 
654
                            N_("color '*!+-' corresponding to the branch")),
 
655
                { OPTION_INTEGER, 0, "more", &extra, N_("n"),
 
656
                            N_("show <n> more commits after the common ancestor"),
658
657
                            PARSE_OPT_OPTARG, NULL, (intptr_t)1 },
659
 
                OPT_SET_INT(0, "list", &extra, "synonym to more=-1", -1),
660
 
                OPT_BOOLEAN(0, "no-name", &no_name, "suppress naming strings"),
 
658
                OPT_SET_INT(0, "list", &extra, N_("synonym to more=-1"), -1),
 
659
                OPT_BOOLEAN(0, "no-name", &no_name, N_("suppress naming strings")),
661
660
                OPT_BOOLEAN(0, "current", &with_current_branch,
662
 
                            "include the current branch"),
 
661
                            N_("include the current branch")),
663
662
                OPT_BOOLEAN(0, "sha1-name", &sha1_name,
664
 
                            "name commits with their object names"),
 
663
                            N_("name commits with their object names")),
665
664
                OPT_BOOLEAN(0, "merge-base", &merge_base,
666
 
                            "show possible merge bases"),
 
665
                            N_("show possible merge bases")),
667
666
                OPT_BOOLEAN(0, "independent", &independent,
668
 
                            "show refs unreachable from any other ref"),
 
667
                            N_("show refs unreachable from any other ref")),
669
668
                OPT_BOOLEAN(0, "topo-order", &lifo,
670
 
                            "show commits in topological order"),
 
669
                            N_("show commits in topological order")),
671
670
                OPT_BOOLEAN(0, "topics", &topics,
672
 
                            "show only commits not on the first branch"),
 
671
                            N_("show only commits not on the first branch")),
673
672
                OPT_SET_INT(0, "sparse", &dense,
674
 
                            "show merges reachable from only one tip", 0),
 
673
                            N_("show merges reachable from only one tip"), 0),
675
674
                OPT_SET_INT(0, "date-order", &lifo,
676
 
                            "show commits where no parent comes before its "
677
 
                            "children", 0),
678
 
                { OPTION_CALLBACK, 'g', "reflog", &reflog_base, "<n>[,<base>]",
679
 
                            "show <n> most recent ref-log entries starting at "
680
 
                            "base",
 
675
                            N_("show commits where no parent comes before its "
 
676
                               "children"), 0),
 
677
                { OPTION_CALLBACK, 'g', "reflog", &reflog_base, N_("<n>[,<base>]"),
 
678
                            N_("show <n> most recent ref-log entries starting at "
 
679
                               "base"),
681
680
                            PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
682
681
                            parse_reflog_param },
683
682
                OPT_END()