git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix for incorrect index update
@ 2009-05-09 21:49 Dave O
  2009-05-10  4:22 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Dave O @ 2009-05-09 21:49 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin

call_depth > 0 requires trees to be constructed from the files with
conflicts, therefore the stages thusly must not be updated

Signed-off-by: Dave Olszewski <cxreg@pobox.com>
---
  merge-recursive.c          |   11 +++--
  t/t3031-merge-criscross.sh |   95 ++++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 101 insertions(+), 5 deletions(-)
  create mode 100644 t/t3031-merge-criscross.sh

diff --git a/merge-recursive.c b/merge-recursive.c
index a3721ef..f5df9b9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -933,11 +933,12 @@ static int process_renames(struct merge_options *o,
  				       ren1_src, ren1_dst, branch1,
  				       branch2);
  				update_file(o, 0, ren1->pair->two->sha1, ren1->pair->two->mode, ren1_dst);
-				update_stages(ren1_dst, NULL,
-						branch1 == o->branch1 ?
-						ren1->pair->two : NULL,
-						branch1 == o->branch1 ?
-						NULL : ren1->pair->two, 1);
+				if (!o->call_depth)
+					update_stages(ren1_dst, NULL,
+							branch1 == o->branch1 ?
+							ren1->pair->two : NULL,
+							branch1 == o->branch1 ?
+							NULL : ren1->pair->two, 1);
  			} else if (!sha_eq(dst_other.sha1, null_sha1)) {
  				const char *new_path;
  				clean_merge = 0;
diff --git a/t/t3031-merge-criscross.sh b/t/t3031-merge-criscross.sh
new file mode 100644
index 0000000..cbfd95b
--- /dev/null
+++ b/t/t3031-merge-criscross.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='merge-recursive backend test'
+
+. ./test-lib.sh
+
+#         A      <- create some files
+#        / \
+#       B   C    <- cause rename/delete conflicts between B and C
+#      /     \
+#     |\     /|
+#     | D   E |
+#     |  \ /  |
+#     |   X   |
+#     |  / \  |
+#     | /   \ |
+#     |/     \|
+#     F       G  <- merge E into B, D into C
+#      \     /
+#       \   /
+#        \ /
+#         H      <- recursive merge crashes
+#
+
+# initialize
+test_expect_success 'setup repo with criss-cross history' '
+	mkdir data &&
+
+	test_debug create a bunch of files &&
+	n=1 &&
+	while test $n -le 10
+	do
+		echo $n > data/$n &&
+		n=$(($n+1)) ||
+		break
+	done &&
+
+	test_debug check them in &&
+	git add data &&
+	git commit -m A &&
+	git branch A &&
+
+	test_debug a file in one branch &&
+	git checkout -b B A &&
+	git rm data/9 &&
+	git add data &&
+	git commit -m B &&
+
+	test_debug with a branch off of it &&
+	git branch D &&
+
+	test_debug put some commits on D &&
+	git checkout D &&
+	echo testD > data/testD &&
+	git add data &&
+	git commit -m D &&
+
+	test_debug back up to the top, create another branch and cause a rename  &&
+	test_debug conflict with the file we deleted earlier &&
+	git checkout -b C A &&
+	git mv data/9 data/new-9 &&
+	git add data &&
+	git commit -m C &&
+
+	test_debug with a branch off of it &&
+	git branch E &&
+
+	test_debug put a commit on E &&
+	git checkout E &&
+	echo testE > data/testE &&
+	git add data &&
+	git commit -m E &&
+
+	test_debug now, merge E into B &&
+	git checkout B &&
+	test_must_fail git merge E &&
+	test_debug force-resolve &&
+	git add data &&
+	git commit -m F &&
+	git branch F &&
+
+	test_debug and merge D into C &&
+	git checkout C &&
+	test_must_fail git merge D &&
+	test_debug force-resolve &&
+	git add data &&
+	git commit -m G &&
+	git branch G
+'
+
+test_expect_failure 'recursive merge between F and G, causes segfault' '
+	git merge F
+'
+
+test_done
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix for incorrect index update
  2009-05-09 21:49 [PATCH] fix for incorrect index update Dave O
@ 2009-05-10  4:22 ` Junio C Hamano
  2009-05-10  4:46   ` Dave Olszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2009-05-10  4:22 UTC (permalink / raw)
  To: Dave O; +Cc: git, Johannes Schindelin

Dave O <cxreg@pobox.com> writes:

> call_depth > 0 requires trees to be constructed from the files with
> conflicts, therefore the stages thusly must not be updated
>
> Signed-off-by: Dave Olszewski <cxreg@pobox.com>
> ---

Thanks.  I'd add:

	From: Dave Olszewski <cxreg@pobox.com>

at the beginning, so you would not be shown as "Dave O" in "git shortlog"
and friends.

>  merge-recursive.c          |   11 +++--
>  t/t3031-merge-criscross.sh |   95 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 101 insertions(+), 5 deletions(-)
>  create mode 100644 t/t3031-merge-criscross.sh

> diff --git a/t/t3031-merge-criscross.sh b/t/t3031-merge-criscross.sh
> new file mode 100644

That should have been 100755 (I'll fix-up myself; no need to resend).

> index 0000000..cbfd95b
> --- /dev/null
> +++ b/t/t3031-merge-criscross.sh
> @@ -0,0 +1,95 @@
> +#!/bin/sh
> +
> +test_description='merge-recursive backend test'
> +
> +. ./test-lib.sh
> +
> +#         A      <- create some files
> +#        / \
> +#       B   C    <- cause rename/delete conflicts between B and C
> +#      /     \
> +#     |\     /|
> +#     | D   E |
> +#     |  \ /  |
> +#     |   X   |
> +#     |  / \  |
> +#     | /   \ |
> +#     |/     \|
> +#     F       G  <- merge E into B, D into C
> +#      \     /
> +#       \   /
> +#        \ /
> +#         H      <- recursive merge crashes
> +#

Much nicer than Dscho's ;-)

> +# initialize
> +test_expect_success 'setup repo with criss-cross history' '
> +	mkdir data &&
> +
> +	test_debug create a bunch of files &&

You inherited a bug from Dscho's patch, it seems.  Have you tried running
the test with debug option?

This could have been

	test_debug "echo create a bunch of files" &&

but I'd say we just make them into comments.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fix for incorrect index update
  2009-05-10  4:22 ` Junio C Hamano
@ 2009-05-10  4:46   ` Dave Olszewski
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Olszewski @ 2009-05-10  4:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Sat, 9 May 2009, Junio C Hamano wrote:

> Thanks.  I'd add:
>
> 	From: Dave Olszewski <cxreg@pobox.com>
>
> at the beginning, so you would not be shown as "Dave O" in "git shortlog"
> and friends.

Ok, sounds good.  Thanks for the explanation of the issue.  Much of the
git internals are still mysterious but that's slowly changing :-)

> Much nicer than Dscho's ;-)

Well, it was mine first, can't fault him for that!

> You inherited a bug from Dscho's patch, it seems.  Have you tried running
> the test with debug option?
>
> This could have been
>
> 	test_debug "echo create a bunch of files" &&
>
> but I'd say we just make them into comments.

I didn't, sorry for that.  Making them comments seems ok to me.

Thanks once again.

     Dave Olszewski

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-05-10  4:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-09 21:49 [PATCH] fix for incorrect index update Dave O
2009-05-10  4:22 ` Junio C Hamano
2009-05-10  4:46   ` Dave Olszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).