Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-04-02 04:50:54 +0400
committerJunio C Hamano <gitster@pobox.com>2011-04-02 04:50:54 +0400
commit84dd63ee1d6ce08d7b85e4f1c4d7e77ef27a1578 (patch)
tree418f125d2547504da61041af79d2ae94b6cb6f07
parent82d861f9d65080f5c66a5f3c956627af6ded78d9 (diff)
parent4b3ffe5184bd550dddacdd0b32b18ad0e73c7908 (diff)
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
-rw-r--r--builtin/merge.c2
-rwxr-xr-xgit-pull.sh2
-rwxr-xr-xt/t5520-pull.sh11
-rwxr-xr-xt/t7607-merge-overwrite.sh4
4 files changed, 17 insertions, 2 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index aa3453c5e1..c8d028cbcc 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -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;
diff --git a/git-pull.sh b/git-pull.sh
index 63b063a7b2..e31226b62f 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -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
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 0470a81be0..0e5eb678ce 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -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 &&
diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh
index c86e298d08..b54e840ee2 100755
--- a/t/t7607-merge-overwrite.sh
+++ b/t/t7607-merge-overwrite.sh
@@ -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 &&