static void show_one_commit(struct commit *commit, int no_name)
{
- char pretty[256], *cp;
+ struct strbuf pretty;
+ const char *pretty_str = "(unavailable)";
struct commit_name *name = commit->util;
- if (commit->object.parsed)
- pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
- pretty, sizeof(pretty), 0, NULL, NULL, 0);
- else
- strcpy(pretty, "(unavailable)");
- if (!prefixcmp(pretty, "[PATCH] "))
- cp = pretty + 8;
- else
- cp = pretty;
+
+ strbuf_init(&pretty, 0);
+ if (commit->object.parsed) {
+ pretty_print_commit(CMIT_FMT_ONELINE, commit,
+ &pretty, 0, NULL, NULL, 0, 0);
+ pretty_str = pretty.buf;
+ }
+ if (!prefixcmp(pretty_str, "[PATCH] "))
+ pretty_str += 8;
if (!no_name) {
if (name && name->head_name) {
printf("[%s] ",
find_unique_abbrev(commit->object.sha1, 7));
}
- puts(cp);
+ puts(pretty_str);
+ strbuf_release(&pretty);
}
static char *ref_name[MAX_REVS + 1];
static int git_show_branch_config(const char *var, const char *value)
{
if (!strcmp(var, "showbranch.default")) {
+ if (!value)
+ return config_error_nonbool(var);
if (default_alloc <= default_num + 1) {
default_alloc = default_alloc * 3 / 2 + 20;
default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);