git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Cloning from a repo without "current branch"
@ 2007-06-16 22:26 Nanako Shiraishi
  2007-06-17  3:41 ` Junio C Hamano
       [not found] ` <7vk5tx5333.fsf@assigned-by-dhcp.pobox.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Nanako Shiraishi @ 2007-06-16 22:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

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>


diff --git a/git-clone.sh b/git-clone.sh
index 3a41062..bd44ce1 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -377,6 +377,13 @@ 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
 	?*)
@@ -384,21 +391,20 @@ then
 		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
-- 
1.5.2

----------------------------------------------------------------------
Get a free email address with REAL anti-spam protection.
http://www.bluebottle.com

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-06-22  3:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-16 22:26 [PATCH] Cloning from a repo without "current branch" Nanako Shiraishi
2007-06-17  3:41 ` Junio C Hamano
2007-06-20 21:50   ` Nanako Shiraishi
2007-06-20 22:29     ` Junio C Hamano
     [not found] ` <7vk5tx5333.fsf@assigned-by-dhcp.pobox.com>
2007-06-21  5:01   ` [PATCH] git-gui: use "blame -w -C -C" for "where did it come from, originally?" Shawn O. Pearce
2007-06-21 19:39     ` Linus Torvalds
2007-06-21 19:47       ` Linus Torvalds
2007-06-22  3:34         ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).