pull: do not clobber untracked files on initial pull
For a pull into an unborn branch, we do not use "git merge" at all. Instead, we call read-tree directly. However, we used the --reset parameter instead of "-m", which turns off the safety features. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 25, 2011 at 14:13 UTC
4b3ffe5184bd550dddacdd0b32b18ad0e73c7908
2 files changed
+12
-1
git-pull.sh
+1
-1
@@ -274,7 +274,7 @@ esac
274
if test -z "$orig_head"
275
then
276
git update-ref -m "initial pull" HEAD $merge_head "$curr_head" &&
277
- git read-tree --reset -u HEAD || exit 1
277
+ git read-tree -m -u HEAD || exit 1
278
exit
279
fi
280
t/t5520-pull.sh
+11
@@ -46,6 +46,17 @@ test_expect_success 'pulling into void using master:master' '
46
test_cmp file cloned-uho/file
47
'
48
49
+test_expect_success 'pulling into void does not overwrite untracked files' '
50
+ git init cloned-untracked &&
51
+ (
52
+ cd cloned-untracked &&
53
+ echo untracked >file &&
54
+ test_must_fail git pull .. master &&
55
+ echo untracked >expect &&
56
+ test_cmp expect file
57
+ )
58
+'
59
+
60
test_expect_success 'test . as a remote' '
61
62
git branch copy master &&