{
if (!strcmp(var, "format.pretty"))
return git_config_string(&fmt_pretty, var, value);
- if (!strcmp(var, "format.subjectprefix")) {
- if (!value)
- config_error_nonbool(var);
- fmt_patch_subject_prefix = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "format.subjectprefix"))
+ return git_config_string(&fmt_patch_subject_prefix, var, value);
if (!strcmp(var, "log.date"))
return git_config_string(&default_date_mode, var, value);
if (!strcmp(var, "log.showroot")) {
static int show_tree_object(const unsigned char *sha1,
const char *base, int baselen,
- const char *pathname, unsigned mode, int stage)
+ const char *pathname, unsigned mode, int stage, void *context)
{
printf("%s%s\n", pathname, S_ISDIR(mode) ? "/" : "");
return 0;
t->tag,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
ret = show_object(o->sha1, 1, &rev);
- objects[i].item = (struct object *)t->tagged;
+ if (ret)
+ break;
+ o = parse_object(t->tagged->sha1);
+ if (!o)
+ ret = error("Could not read object %s",
+ sha1_to_hex(t->tagged->sha1));
+ objects[i].item = o;
i--;
break;
}
name,
diff_get_color_opt(&rev.diffopt, DIFF_RESET));
read_tree_recursive((struct tree *)o, "", 0, 0, NULL,
- show_tree_object);
+ show_tree_object, NULL);
break;
case OBJ_COMMIT:
rev.pending.nr = rev.pending.alloc = 0;
static void add_header(const char *value)
{
int len = strlen(value);
- while (value[len - 1] == '\n')
+ while (len && value[len - 1] == '\n')
len--;
if (!strncasecmp(value, "to: ", 4)) {
ALLOC_GROW(extra_to, extra_to_nr + 1, extra_to_alloc);
add_header(value);
return 0;
}
- if (!strcmp(var, "format.suffix")) {
- if (!value)
- return config_error_nonbool(var);
- fmt_patch_suffix = xstrdup(value);
- return 0;
- }
+ if (!strcmp(var, "format.suffix"))
+ return git_config_string(&fmt_patch_suffix, var, value);
if (!strcmp(var, "format.cc")) {
if (!value)
return config_error_nonbool(var);
committer = git_committer_info(IDENT_ERROR_ON_NO_NAME);
endpos = strchr(committer, '>');
if (!endpos)
- die("bogos committer info %s\n", committer);
+ die("bogus committer info %s\n", committer);
add_signoff = xmemdupz(committer, endpos - committer + 1);
}
else if (!strcmp(argv[i], "--attach")) {
}
static const char cherry_usage[] =
-"git-cherry [-v] <upstream> [<head>] [<limit>]";
+"git cherry [-v] <upstream> [<head>] [<limit>]";
int cmd_cherry(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;