mirror of
https://github.com/git/git.git
synced 2024-11-26 03:14:50 +08:00
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);
|
||||
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;
|
||||
|
@ -274,7 +274,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
|
||||
|
||||
|
@ -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 &&
|
||||
|
@ -157,6 +157,10 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
|
||||
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 &&
|
||||
|
Loading…
Reference in New Issue
Block a user