summaryrefslogtreecommitdiff
path: root/git-pull.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-10-14 22:32:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-10-17 18:26:20 (GMT)
commitb0ad11ea165e07308fc02a5091efbe2e2d22237c (patch)
treef5c94bd5fe1e1af1afc472c1123e3aa2f9ee70a0 /git-pull.sh
parent8ee5d73137f355c21e8d4db365ae8d301e067395 (diff)
downloadgit-b0ad11ea165e07308fc02a5091efbe2e2d22237c.zip
git-b0ad11ea165e07308fc02a5091efbe2e2d22237c.tar.gz
git-b0ad11ea165e07308fc02a5091efbe2e2d22237c.tar.bz2
pull: allow "git pull origin $something:$current_branch" into an unborn branch
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>
Diffstat (limited to 'git-pull.sh')
-rwxr-xr-xgit-pull.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/git-pull.sh b/git-pull.sh
index 75c3610..664fe34 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -124,7 +124,7 @@ orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
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.
@@ -172,7 +172,7 @@ esac
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