Re: [PATCH] git-clone: fix handling of upsteram whose HEAD does not point at master.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <junkio@xxxxxxx> writes:

> When cloning from a remote repository that has master, main, and
> origin branches _and_ with the HEAD pointing at main branch, we
> did quite confused things during clone.  So this cleans things
> up.  The behaviour is a bit different between separate remotes/
> layout and the mixed branches layout.
>
> The newer layout with $GIT_DIR/refs/remotes/$origin/, things are
> simpler and more transparent:
>
>  - remote branches are copied to refs/remotes/$origin/.
>  - HEAD points at refs/heads/master, which starts at where the
>    remote HEAD points at.
>  - $GIT_DIR/remotes/$origin file is set up to fetch all remote
>    branches, and merge the branch HEAD pointed at at the time of
>    the cloning.

BTW, the behaviour under --use-separate-remote may be made more
consistent with the traditional layout case by using the same
branch name as the original repository even in that case.

On top of the previous patch, something like the attached one.
I'll put this in "next" and see how it goes, unless anybody
complains.

---

diff --git a/git-clone.sh b/git-clone.sh
index 9cc374e..c013e48 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -376,15 +376,11 @@ then
 	case "$head_points_at" in
 	?*)
 		mkdir -p "$GIT_DIR/remotes" &&
+		git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
 		case "$use_separate_remote" in
-		# With separete-remote, our primary branch is always
-		# at 'master'
 		t)	origin_track="$remote_top/$head_points_at"
 			git-update-ref HEAD "$head_sha1" ;;
-		# Otherwise our primary branch is the same as the remote;
-		# we track upstream with $origin.
 		*)	origin_track="$remote_top/$origin"
-			git-symbolic-ref HEAD "refs/heads/$head_points_at"
 			git-update-ref "refs/heads/$origin" "$head_sha1" ;;
 		esac &&
 		echo >"$GIT_DIR/remotes/$origin" \


-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]