Code

Windows: Implement start_command().
[git.git] / builtin-commit.c
index d75224381b7ad88d6bbb67db3a85bbb881cea941..90200ed643bcf21f28a66396f0d15db920a5d4c8 100644 (file)
@@ -223,6 +223,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
 
        if (interactive) {
                interactive_add(argc, argv, prefix);
+               if (read_cache() < 0)
+                       die("index file corrupt");
                commit_style = COMMIT_AS_IS;
                return get_index_file();
        }
@@ -806,7 +808,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        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;
@@ -860,7 +862,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
        }
 }
 
-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)
@@ -869,7 +871,7 @@ int git_commit_config(const char *k, const char *v)
                return 0;
        }
 
-       return git_status_config(k, v);
+       return git_status_config(k, v, cb);
 }
 
 static const char commit_utf8_warn[] =
@@ -881,10 +883,19 @@ static void add_parent(struct strbuf *sb, const unsigned char *sha1)
 {
        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);
 }
 
@@ -897,7 +908,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
        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);