summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8ee5d73)
raw | patch | inline | side by side (parent: 8ee5d73)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 14 Oct 2008 22:32:20 +0000 (15:32 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 17 Oct 2008 18:26:20 +0000 (11:26 -0700) |
Some misguided documents floating on the Net suggest this sequence:
mkdir newdir && cd newdir
git init
git remote add origin $url
git pull origin master:master
"git pull" has known about misguided "pull" that lets the underlying fetch
update the current branch for a long time. It also has known about
"git pull origin master" into a branch yet to be born.
These two workarounds however were not aware of the existence of each
other and did not work well together. This fixes it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mkdir newdir && cd newdir
git init
git remote add origin $url
git pull origin master:master
"git pull" has known about misguided "pull" that lets the underlying fetch
update the current branch for a long time. It also has known about
"git pull origin master" into a branch yet to be born.
These two workarounds however were not aware of the existence of each
other and did not work well together. This fixes it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-pull.sh | patch | blob | history | |
t/t5520-pull.sh | patch | blob | history |
diff --git a/git-pull.sh b/git-pull.sh
index 75c36100a2f858bcf2663d2b4560654787963175..664fe34419e9aeef1af8fac820cc423a641f5525 100755 (executable)
--- a/git-pull.sh
+++ b/git-pull.sh
git fetch --update-head-ok "$@" || exit 1
curr_head=$(git rev-parse --verify HEAD 2>/dev/null)
-if test "$curr_head" != "$orig_head"
+if test -n "$orig_head" && test "$curr_head" != "$orig_head"
then
# The fetch involved updating the current branch.
if test -z "$orig_head"
then
- git update-ref -m "initial pull" HEAD $merge_head "" &&
+ git update-ref -m "initial pull" HEAD $merge_head "$curr_head" &&
git read-tree --reset -u HEAD || exit 1
exit
fi
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 997b2db827c4f37512c6b5d2f861e12105e2a32d..725771fac167ea5aac8cf65b916c96918b0f5e0d 100755 (executable)
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
diff file cloned/file
'
+test_expect_success 'pulling into void using master:master' '
+ mkdir cloned-uho &&
+ (
+ cd cloned-uho &&
+ git init &&
+ git pull .. master:master
+ ) &&
+ test -f file &&
+ test -f cloned-uho/file &&
+ test_cmp file cloned-uho/file
+'
+
test_expect_success 'test . as a remote' '
git branch copy master &&