Merge branch 'jk/pull-into-empty'
* jk/pull-into-empty: pull: do not clobber untracked files on initial pull merge: merge unborn index before setting ref
This commit is contained in:
commit
84dd63ee1d
@ -1063,9 +1063,9 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
|
|||||||
remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
|
remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT);
|
||||||
if (!remote_head)
|
if (!remote_head)
|
||||||
die("%s - not something we can merge", argv[0]);
|
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,
|
update_ref("initial pull", "HEAD", remote_head->sha1, NULL, 0,
|
||||||
DIE_ON_ERR);
|
DIE_ON_ERR);
|
||||||
read_empty(remote_head->sha1, 0);
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
struct strbuf merge_names = STRBUF_INIT;
|
struct strbuf merge_names = STRBUF_INIT;
|
||||||
|
@ -274,7 +274,7 @@ esac
|
|||||||
if test -z "$orig_head"
|
if test -z "$orig_head"
|
||||||
then
|
then
|
||||||
git update-ref -m "initial pull" HEAD $merge_head "$curr_head" &&
|
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
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -46,6 +46,17 @@ test_expect_success 'pulling into void using master:master' '
|
|||||||
test_cmp file cloned-uho/file
|
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' '
|
test_expect_success 'test . as a remote' '
|
||||||
|
|
||||||
git branch copy master &&
|
git branch copy master &&
|
||||||
|
@ -157,6 +157,10 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
|
|||||||
test_cmp important c0.c
|
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' '
|
test_expect_success 'set up unborn branch and content' '
|
||||||
git symbolic-ref HEAD refs/heads/unborn &&
|
git symbolic-ref HEAD refs/heads/unborn &&
|
||||||
rm -f .git/index &&
|
rm -f .git/index &&
|
||||||
|
Loading…
Reference in New Issue
Block a user