if (interactive) {
interactive_add(argc, argv, prefix);
+ if (read_cache() < 0)
+ die("index file corrupt");
commit_style = COMMIT_AS_IS;
return get_index_file();
}
const char *index_file;
int commitable;
- git_config(git_status_config);
+ git_config(git_status_config, NULL);
if (wt_status_use_color == -1)
wt_status_use_color = git_use_color_default;
}
}
-int git_commit_config(const char *k, const char *v)
+int git_commit_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "commit.template")) {
if (!v)
return 0;
}
- return git_status_config(k, v);
+ return git_status_config(k, v, cb);
}
static const char commit_utf8_warn[] =
{
struct object *obj = parse_object(sha1);
const char *parent = sha1_to_hex(sha1);
+ const char *cp;
+
if (!obj)
die("Unable to find commit parent %s", parent);
if (obj->type != OBJ_COMMIT)
die("Parent %s isn't a proper commit", parent);
+
+ for (cp = sb->buf; cp && (cp = strstr(cp, "\nparent ")); cp += 8) {
+ if (!memcmp(cp + 8, parent, 40) && cp[48] == '\n') {
+ error("duplicate parent %s ignored", parent);
+ return;
+ }
+ }
strbuf_addf(sb, "parent %s\n", parent);
}
unsigned char commit_sha1[20];
struct ref_lock *ref_lock;
- git_config(git_commit_config);
+ git_config(git_commit_config, NULL);
argc = parse_and_validate_options(argc, argv, builtin_commit_usage);