All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre Habouzit <madcoder@debian.org>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Pierre Habouzit <madcoder@debian.org>
Subject: [PATCH] builtin-merge: missing structure bzero.
Date: Mon, 21 Jul 2008 19:03:50 +0200	[thread overview]
Message-ID: <1216659830-22063-1-git-send-email-madcoder@debian.org> (raw)

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

             reply	other threads:[~2008-07-21 17:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-21 17:03 Pierre Habouzit [this message]
2008-07-21 17:21 ` [PATCH] builtin-merge: missing structure bzero Miklos Vajna
2008-07-21 18:18   ` Pierre Habouzit
2008-07-21 21:49     ` Pierre Habouzit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1216659830-22063-1-git-send-email-madcoder@debian.org \
    --to=madcoder@debian.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.