threads / patch / 14442

patchFix reduce_heads

Subject: [PATCH] Fix reduce_heads

## tl;dr

4 messages between Jul 14, 2008 and Jul 14, 2008. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Sverre Hvammen Johansen· Jul 14, 2008, 04:07 UTC · lore

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(-)
Show changes to 2 files +29 −1

commit.c, t/t7600-merge.sh

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
Johannes Schindelin· Jul 14, 2008, 09:30 UTC · re: Sverre Hvammen Johansen · lore

Re: [PATCH] Fix reduce_heads

Hi,
On Sun, 13 Jul 2008, Sverre Hvammen Johansen wrote:
> Reduce_heads used by build in merge failed to find the correct
> heads in cases where duplicate heads are specified.
I liked Junio's explanation better.
> 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'd rather not have it squashed in. Miklos is a GSoC student, and at the end I want to show the shortlog to tell Google how he fared.

Unfortunately, Miklos is on holiday this week, so he cannot send a mail of his own. Junio, could you fake a commit message with a sign-off for Miklos, or do you want me to do it?

Ciao, Dscho

Miklos Vajna· Jul 14, 2008, 11:44 UTC · re: Johannes Schindelin · lore

Re: [PATCH] Fix reduce_heads

On Mon, Jul 14, 2008 at 11:30:24AM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> Unfortunately, Miklos is on holiday this week, so he cannot send a mail of 
> his own.  Junio, could you fake a commit message with a sign-off for 
> Miklos, or do you want me to do it?

I'll go out tomorrow, so I can send that it today. Sorry for not sending a proper patch for the first time. ;-)

Miklos Vajna· Jul 14, 2008, 11:57 UTC · re: Miklos Vajna · lore

Re: [PATCH] Fix reduce_heads

On Mon, Jul 14, 2008 at 01:44:53PM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> I'll go out tomorrow, so I can send that it today. Sorry for not sending
> a proper patch for the first time. ;-)
Ah, It's already in 'pu', so never mind.

← back to recent threads