Skip to content

Commit

Permalink
Merge branch 'jk/pull-into-empty'
Browse files Browse the repository at this point in the history
* jk/pull-into-empty:
  pull: do not clobber untracked files on initial pull
  merge: merge unborn index before setting ref
  • Loading branch information
Junio C Hamano committed Apr 2, 2011
2 parents 82d861f + 4b3ffe5 commit 84dd63e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion builtin/merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion git-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions t/t5520-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
4 changes: 4 additions & 0 deletions t/t7607-merge-overwrite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down

0 comments on commit 84dd63e

Please sign in to comment.