Merge branch 'jk/pull-into-empty' into next

* jk/pull-into-empty:
  pull: do not clobber untracked files on initial pull
  merge: merge unborn index before setting ref

Conflicts:
	builtin/merge.c
This commit is contained in:
Junio C Hamano
2011-03-31 13:13:58 -07:00
4 changed files with 17 additions and 2 deletions

View File

@@ -1101,9 +1101,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
if (!remote_head)
die(_("%s - not something we can merge"), argv[0]);
read_empty(remote_head->sha1, 0);
update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
DIE_ON_ERR);
read_empty(remote_head->sha1, 0);
return 0;
} else {
struct strbuf merge_names = STRBUF_INIT;

View File

@@ -253,7 +253,7 @@ esac
if test -z "$orig_head"
then
git update-ref -m "initial pull" HEAD $merge_head "$curr_head" &&
git read-tree --reset -u HEAD || exit 1
git read-tree -m -u HEAD || exit 1
exit
fi

View File

@@ -46,6 +46,17 @@ test_expect_success 'pulling into void using master:master' '
test_cmp file cloned-uho/file
'
test_expect_success 'pulling into void does not overwrite untracked files' '
git init cloned-untracked &&
(
cd cloned-untracked &&
echo untracked >file &&
test_must_fail git pull .. master &&
echo untracked >expect &&
test_cmp expect file
)
'
test_expect_success 'test . as a remote' '
git branch copy master &&

View File

@@ -163,6 +163,10 @@ test_expect_success 'will not overwrite untracked file on unborn branch .git/MER
test_cmp important c0.c
'
test_expect_success 'failed merge leaves unborn branch in the womb' '
test_must_fail git rev-parse --verify HEAD
'
test_expect_success 'set up unborn branch and content' '
git symbolic-ref HEAD refs/heads/unborn &&
rm -f .git/index &&