Git development
 help / color / mirror / Atom feed
* [PATCH] builtin-merge: missing structure bzero.
@ 2008-07-21 17:03 Pierre Habouzit
  2008-07-21 17:21 ` Miklos Vajna
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Habouzit @ 2008-07-21 17:03 UTC (permalink / raw)
  To: git; +Cc: gitster, Pierre Habouzit

This cause segfaults when replacing a directory with a submodule in a
fast-forward.

Adds tests that revealed the issue, even if the second one isn't yet fixed for
another reason.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---

    In the process of writing a test for a problem with submodules that quite
    bugs me so that I can fix it, I found a segfault that this patch fix.

    The problem I tried to fix (hence I first wrote a test) is what happens
    when you have in your repository a "dir/file.c" and that you replace
    "dir/" witha submodule that also has a "file.c". git-merge pretends the
    submodule checkout would clobber unversionned files, probably due to a too
    late removal. anyways, that's for a next patch when I will understand the
    root of this issue ;)

 builtin-merge.c            |    1 +
 t/t7403-submodule-merge.sh |   62 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 0 deletions(-)
 create mode 100755 t/t7403-submodule-merge.sh

diff --git a/builtin-merge.c b/builtin-merge.c
index e97c79e..0ed1acf 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -580,6 +580,7 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
 	memset(&trees, 0, sizeof(trees));
 	memset(&opts, 0, sizeof(opts));
 	memset(&t, 0, sizeof(t));
+	memset(&dir, 0, sizeof(dir));
 	dir.show_ignored = 1;
 	dir.exclude_per_dir = ".gitignore";
 	opts.dir = &dir;
diff --git a/t/t7403-submodule-merge.sh b/t/t7403-submodule-merge.sh
new file mode 100755
index 0000000..a803829
--- /dev/null
+++ b/t/t7403-submodule-merge.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Pierre Habouzit
+#
+
+test_description='Test merging with submodules'
+
+. ./test-lib.sh
+
+test_expect_success 'Setup a repository used as a submodule for other tests' '
+	mkdir submodule &&
+	cd submodule &&
+	git init &&
+	echo a > a &&
+	git add a &&
+	git commit -asm"submodule init" &&
+	cd ..
+'
+
+test_expect_success 'Replace a directory with a submodule, no file conflict' '
+	mkdir test &&
+	cd test &&
+	: create our repository with a sub/b file &&
+	git init &&
+	mkdir sub && echo b > sub/b &&
+	git add sub && git commit -asm"initial repository" &&
+	: save this state in a new branch &&
+	git branch temp &&
+	: then replace sub with it &&
+	git rm -rf sub &&
+        git submodule add -- "$(pwd)/../submodule/.git/" sub &&
+	git commit -asm "replace sub/ with a submodule" &&
+	: then try to update the "temp" branch &&
+	git checkout temp &&
+	git merge master &&
+	: and finally cleanse the mess &&
+	cd .. &&
+	rm -rf test
+'
+
+test_expect_failure 'Replace a directory with a submodule, with a file conflict' '
+	mkdir test &&
+	cd test &&
+	: create our repository with a sub/a file &&
+	git init &&
+	mkdir sub && echo a > sub/a &&
+	git add sub && git commit -asm"initial repository" &&
+	: save this state in a new branch &&
+	git branch temp &&
+	: then replace sub with it &&
+	git rm -rf sub &&
+        git submodule add -- "$(pwd)/../submodule/.git/" sub &&
+	git commit -asm "replace sub/ with a submodule" &&
+	: then try to update the "temp" branch &&
+	git checkout temp &&
+	git merge master &&
+	: and finally cleanse the mess &&
+	cd .. &&
+	rm -rf test
+'
+
+test_done
-- 
1.5.6.3

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

end of thread, other threads:[~2008-07-21 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-21 17:03 [PATCH] builtin-merge: missing structure bzero Pierre Habouzit
2008-07-21 17:21 ` Miklos Vajna
2008-07-21 18:18   ` Pierre Habouzit
2008-07-21 21:49     ` Pierre Habouzit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox