summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 69e66f5)
raw | patch | inline | side by side (parent: 69e66f5)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 3 Jun 2008 05:17:42 +0000 (22:17 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 3 Jun 2008 06:55:57 +0000 (23:55 -0700) |
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>
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>
builtin-commit.c | patch | blob | history | |
t/t7502-commit.sh | patch | blob | history |
diff --git a/builtin-commit.c b/builtin-commit.c
index b294c1f88c1eecde8d96d265c72376c789f24899..90200ed643bcf21f28a66396f0d15db920a5d4c8 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
{
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);
}
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 46ec1ce8aaa0305f6b4569664de041137db137d7..22a13f7aababf43fac0a02b6e9310f74cc6b4f9f 100755 (executable)
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
! test -f .git/index.lock
'
+rm -f .git/MERGE_MSG .git/COMMIT_EDITMSG
+git reset -q --hard
+
+test_expect_success 'Hand committing of a redundant merge removes dups' '
+
+ git rev-parse second master >expect &&
+ test_must_fail git merge second master &&
+ git checkout master g &&
+ EDITOR=: git commit -a &&
+ git cat-file commit HEAD | sed -n -e "s/^parent //p" -e "/^$/q" >actual &&
+ test_cmp expect actual
+
+'
+
test_done