From: Junio C Hamano Date: Wed, 14 Jan 2015 20:37:07 +0000 (-0800) Subject: Merge branch 'ak/show-branch-usage-string' X-Git-Tag: v2.3.0-rc1~12 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d62078e9107f01c902c260e34b509a6c7467ac70?hp=-c Merge branch 'ak/show-branch-usage-string' * ak/show-branch-usage-string: show-branch: line-wrap show-branch usage --- d62078e9107f01c902c260e34b509a6c7467ac70 diff --combined builtin/show-branch.c index 270e39c6c1,fee1ba17db..691eeda345 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@@ -6,7 -6,10 +6,10 @@@ #include "parse-options.h" static const char* show_branch_usage[] = { - N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=] | --no-color] [--sparse] [--more= | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [( | )...]"), + N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order]\n" + " [--current] [--color[=] | --no-color] [--sparse]\n" + " [--more= | --list | --independent | --merge-base]\n" + " [--no-name | --sha1-name] [--topics] [( | )...]"), N_("git show-branch (-g|--reflog)[=[,]] [--list] []"), NULL }; @@@ -563,7 -566,7 +566,7 @@@ static int git_show_branch_config(cons default_arg[default_num++] = "show-branch"; } else if (default_alloc <= default_num + 1) { default_alloc = default_alloc * 3 / 2 + 20; - default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc); + REALLOC_ARRAY(default_arg, default_alloc); } default_arg[default_num++] = xstrdup(value); default_arg[default_num] = NULL; @@@ -723,14 -726,11 +726,14 @@@ int cmd_show_branch(int ac, const char char nth_desc[256]; char *ref; int base = 0; + unsigned int flags = 0; if (ac == 0) { static const char *fake_av[2]; - fake_av[0] = resolve_refdup("HEAD", sha1, 1, NULL); + fake_av[0] = resolve_refdup("HEAD", + RESOLVE_REF_READING, + sha1, NULL); fake_av[1] = NULL; av = fake_av; ac = 1; @@@ -752,18 -752,18 +755,18 @@@ /* Ah, that is a date spec... */ unsigned long at; at = approxidate(reflog_base); - read_ref_at(ref, at, -1, sha1, NULL, + read_ref_at(ref, flags, at, -1, sha1, NULL, NULL, NULL, &base); } } for (i = 0; i < reflog; i++) { - char *logmsg, *m; + char *logmsg; const char *msg; unsigned long timestamp; int tz; - if (read_ref_at(ref, 0, base+i, sha1, &logmsg, + if (read_ref_at(ref, flags, 0, base+i, sha1, &logmsg, ×tamp, &tz, NULL)) { reflog = i; break; @@@ -773,14 -773,15 +776,14 @@@ msg = "(none)"; else msg++; - m = xmalloc(strlen(msg) + 200); - sprintf(m, "(%s) %s", - show_date(timestamp, tz, 1), - msg); - reflog_msg[i] = m; + reflog_msg[i] = xstrfmt("(%s) %s", + show_date(timestamp, tz, 1), + msg); free(logmsg); sprintf(nth_desc, "%s@{%d}", *av, base+i); append_ref(nth_desc, sha1, 1); } + free(ref); } else if (all_heads + all_remotes) snarf_refs(all_heads, all_remotes); @@@ -791,8 -792,7 +794,8 @@@ } } - head_p = resolve_ref_unsafe("HEAD", head_sha1, 1, NULL); + head_p = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING, + head_sha1, NULL); if (head_p) { head_len = strlen(head_p); memcpy(head, head_p, head_len + 1);