[PATCH] Fix reduce_heads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reduce_heads used by build in merge failed to find the correct
heads in cases where duplicate heads are specified.
---
This should fix the last breakage I found. ([PATCH/Test] Build in
merge is broken)
I have squashed in Miklos's fix and the two tests cases to protect this.

I have several other test cases that were used for the --ff-only patch
I worked on.
Many of the cases for that patch gives protection not currently in any of the
existing tests.  If there is interest for it I can squash them in as well.

 commit.c         |    8 +++++++-
 t/t7600-merge.sh |   22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/commit.c b/commit.c
index d20b14e..4cacf4c 100644
--- a/commit.c
+++ b/commit.c
@@ -746,8 +746,14 @@ struct commit_list *reduce_heads(struct commit_list *heads)
                struct commit_list *q, *base;

                num_other = 0;
+               for (q = heads; q != p; q = q->next) {
+                       if (p->item == q->item)
+                               break;
+               }
+               if (q != p)
+                       continue;
                for (q = heads; q; q = q->next) {
-                       if (p == q)
+                       if (p->item == q->item)
                                continue;
                        other[num_other++] = q->item;
                }
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 16f4608..80cfee6 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -465,4 +465,26 @@ test_expect_success 'merge log message' '

 test_debug 'gitk --all'

+test_expect_success 'merge c1 with c0, c2, c0, and c1' '
+       git reset --hard c1 &&
+       git config branch.master.mergeoptions "" &&
+       test_tick &&
+       git merge c0 c2 c0 c1 &&
+       verify_merge file result.1-5 &&
+       verify_parents $c1 $c2
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c1 with c1 and c2' '
+       git reset --hard c1 &&
+       git config branch.master.mergeoptions "" &&
+       test_tick &&
+       git merge c1 c2 &&
+       verify_merge file result.1-5 &&
+       verify_parents $c1 $c2
+'
+
+test_debug 'gitk --all'
+
 test_done
-- 
Sverre Hvammen Johansen
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux