Skip to content

Commit

Permalink
Cloning from a repo without "current branch"
Browse files Browse the repository at this point in the history
If the remote repository does not have a "current branch", git-clone
was confused and did not set up the resulting new repository
correctly.  It did not reset HEAD from the default 'master', and did
not write the SHA1 to the master branch.

Signed-off-by: Nanako Shiraishi <nanako3@bluebottle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nanako Shiraishi authored and Junio C Hamano committed Jun 20, 2007
1 parent 45fd8bd commit 6762079
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions git-clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,28 +377,34 @@ then
)
)

# Upstream URL
git-config remote."$origin".url "$repo" &&

# Set up the mappings to track the remote branches.
git-config remote."$origin".fetch \
"+refs/heads/*:$remote_top/*" '^$' &&

# Write out remote.$origin config, and update our "$head_points_at".
case "$head_points_at" in
?*)
# Local default branch
git-symbolic-ref HEAD "refs/heads/$head_points_at" &&

# Tracking branch for the primary branch at the remote.
origin_track="$remote_top/$head_points_at" &&
git-update-ref HEAD "$head_sha1" &&

# Upstream URL
git-config remote."$origin".url "$repo" &&

# Set up the mappings to track the remote branches.
git-config remote."$origin".fetch \
"+refs/heads/*:$remote_top/*" '^$' &&
rm -f "refs/remotes/$origin/HEAD"
git-symbolic-ref "refs/remotes/$origin/HEAD" \
"refs/remotes/$origin/$head_points_at" &&

git-config branch."$head_points_at".remote "$origin" &&
git-config branch."$head_points_at".merge "refs/heads/$head_points_at"
;;
'')
# Source had detached HEAD pointing nowhere
git-update-ref --no-deref HEAD "$head_sha1" &&
rm -f "refs/remotes/$origin/HEAD"
;;
esac

case "$no_checkout" in
Expand Down

0 comments on commit 6762079

Please sign in to comment.