summaryrefslogtreecommitdiff
path: root/builtin-commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-06-03 05:17:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-06-03 06:55:57 (GMT)
commit67bfc030d7b27c007853776e8028598bdfa2cae0 (patch)
tree8fae799207c6263f9826e333de27fdfd9eb50c51 /builtin-commit.c
parent69e66f5500ef6079e3374a6654ef1f6df0c6f360 (diff)
downloadgit-67bfc030d7b27c007853776e8028598bdfa2cae0.zip
git-67bfc030d7b27c007853776e8028598bdfa2cae0.tar.gz
git-67bfc030d7b27c007853776e8028598bdfa2cae0.tar.bz2
commit: drop duplicated parents
The scripted version of git-commit internally used git-commit-tree which omitted duplicated parents given from the command line. This prevented a nonsensical octopus merge from getting created even when you said "git merge A B" while you are already on branch A. However, when git-commit was rewritten in C, this sanity check was lost. This resurrects it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-commit.c')
-rw-r--r--builtin-commit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin-commit.c b/builtin-commit.c
index b294c1f..90200ed 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -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);
}