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
8c8674fc954d8c4bc46f303a141f510ecf264fcd
2 files changed
+12
-1
git-pull.sh
+1
-1
@@ -272,7 +272,7 @@ esac
272
if test -z "$orig_head"
273
then
274
git update-ref -m "initial pull" HEAD $merge_head "$curr_head" &&
275
- git read-tree --reset -u HEAD || exit 1
275
+ git read-tree -m -u HEAD || exit 1
276
exit
277
fi
278
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 &&