summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-07-14 07:09:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-14 07:09:41 (GMT)
commit711f6b295cf463aae07eb76e009faed3d3699623 (patch)
tree7acf1583cb4daad2293415d996517e1164852c7d /commit.c
parent3d1dd4728b83e4c08d9fa7aaf2aa946e1012e061 (diff)
downloadgit-711f6b295cf463aae07eb76e009faed3d3699623.zip
git-711f6b295cf463aae07eb76e009faed3d3699623.tar.gz
git-711f6b295cf463aae07eb76e009faed3d3699623.tar.bz2
reduce_heads(): protect from duplicate input
Because we do not try computing merge base with itself for obvious reasons, the code was not prepared for an arguably insane case of the caller feeding the same commit twice to it. Noticed and test written by Sverre Hvammen Johansen Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/commit.c b/commit.c
index 03e73f3..5148ec5 100644
--- a/commit.c
+++ b/commit.c
@@ -745,15 +745,22 @@ struct commit_list *reduce_heads(struct commit_list *heads)
for (p = heads; p; p = p->next) {
struct commit_list *q, *base;
+ /* Do we already have this in the result? */
+ for (q = result; q; q = q->next)
+ if (p->item == q->item)
+ break;
+ if (q)
+ continue;
+
num_other = 0;
for (q = heads; q; q = q->next) {
if (p->item == q->item)
continue;
other[num_other++] = q->item;
}
- if (num_other) {
+ if (num_other)
base = get_merge_bases_many(p->item, num_other, other, 1);
- } else
+ else
base = NULL;
/*
* If p->item does not have anything common with other