[PATCH] builtin-merge: missing structure bzero.
From: Pierre Habouzit <hidden>
Date: 2016-06-15 22:44:59
Subsystem:
the rest · Maintainer:
Linus Torvalds
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 <redacted>
---
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