From: Thomas Rast Date: Sun, 22 Aug 2010 21:06:29 +0000 (+0200) Subject: Exhibit merge bug that clobbers index&WT X-Git-Tag: v1.7.5-rc0~138^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b3270817712e8eedb468e906cb1042a5a311ad4;p=git.git Exhibit merge bug that clobbers index&WT Running git-merge on an unborn branch is supposed to do an index-level merge with the other side, and then update the branch name there. In the common case where the index was empty at the start, this makes 'git pull otherrepo branch' a convenient way to populate the history after 'git init'. However, if the index was *not* empty, git-merge silently discards *both index and worktree* copies of all files that were tracked, leading to data loss. Exhibit this bug. Reported-by: Johannes Schindelin Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh index 49f4e1599..50b6b33ef 100755 --- a/t/t7607-merge-overwrite.sh +++ b/t/t7607-merge-overwrite.sh @@ -84,4 +84,20 @@ test_expect_success 'will not overwrite removed file with staged changes' ' test_cmp important c1.c ' +test_expect_success 'set up unborn branch and content' ' + git symbolic-ref HEAD refs/heads/unborn && + rm -f .git/index && + echo foo > tracked-file && + git add tracked-file && + echo bar > untracked-file +' + +test_expect_failure 'will not clobber WT/index when merging into unborn' ' + git merge master && + grep foo tracked-file && + git show :tracked-file >expect && + grep foo expect && + grep bar untracked-file +' + test_done