]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-commit.c
Print info about "git help COMMAND" on git's main usage pages
[git.git] / builtin-commit.c
index b294c1f88c1eecde8d96d265c72376c789f24899..90200ed643bcf21f28a66396f0d15db920a5d4c8 100644 (file)
@@ -883,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);
 }