git-clone: use wildcard specification for tracking branches
This stops enumerating the set of branches found on the remote side when a clone was made in the configuration file. Instead, a single entry that maps each remote branch to the local tracking branch for the remote under the same name is created. Doing it this way not only shortens the configuration file, but automatically adjusts to a new branch added on the remote side after the clone is made. Unfortunately this cannot be done for the traditional layout, where we always need to special case the 'master' to 'origin' mapping within the local branch namespace. But that is Ok; it will be going away before v1.5.0. We could also lose the "primary branch" mapping at the beginning, but that has to wait until we implement the "forbid 'git pull' when we do not have branch.$current.merge for the current branch" policy we earlier discussed. That should also be in v1.5.0 Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
b1bfcae438
commit
61dde8f916
47
git-clone.sh
47
git-clone.sh
@ -366,41 +366,54 @@ then
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Write out remotes/$origin file, and update our "$head_points_at".
|
# Write out remote.$origin config, and update our "$head_points_at".
|
||||||
case "$head_points_at" in
|
case "$head_points_at" in
|
||||||
?*)
|
?*)
|
||||||
mkdir -p "$GIT_DIR/remotes" &&
|
# Local default branch
|
||||||
git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
|
git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
|
||||||
|
|
||||||
|
# Tracking branch for the primary branch at the remote.
|
||||||
case "$use_separate_remote" in
|
case "$use_separate_remote" in
|
||||||
t) origin_track="$remote_top/$head_points_at"
|
t) origin_track="$remote_top/$head_points_at"
|
||||||
git-update-ref HEAD "$head_sha1" ;;
|
git-update-ref HEAD "$head_sha1" ;;
|
||||||
*) origin_track="$remote_top/$origin"
|
*) origin_track="$remote_top/$origin"
|
||||||
git-update-ref "refs/heads/$origin" "$head_sha1" ;;
|
git-update-ref "refs/heads/$origin" "$head_sha1" ;;
|
||||||
esac &&
|
esac &&
|
||||||
|
|
||||||
|
# Upstream URL and the primary branch tracking
|
||||||
git-repo-config remote."$origin".url "$repo" &&
|
git-repo-config remote."$origin".url "$repo" &&
|
||||||
git-repo-config remote."$origin".fetch \
|
git-repo-config remote."$origin".fetch \
|
||||||
"refs/heads/$head_points_at:$origin_track" &&
|
"refs/heads/$head_points_at:$origin_track" &&
|
||||||
(cd "$GIT_DIR/$remote_top" && find . -type f -print) |
|
|
||||||
while read dotslref
|
# Set up the mappings to track the remaining branches.
|
||||||
do
|
case "$use_separate_remote" in
|
||||||
name=`expr "$dotslref" : './\(.*\)'`
|
t)
|
||||||
if test "z$head_points_at" = "z$name"
|
git-repo-config remote."$origin".fetch \
|
||||||
then
|
"refs/heads/*:$remote_top/*" '^$'
|
||||||
continue
|
;;
|
||||||
fi
|
*)
|
||||||
if test "$use_separate_remote" = '' &&
|
(cd "$GIT_DIR/$remote_top" && find . -type f -print) |
|
||||||
test "z$origin" = "z$name"
|
while read dotslref
|
||||||
then
|
do
|
||||||
continue
|
name=`expr "$dotslref" : './\(.*\)'`
|
||||||
fi
|
if test "z$head_points_at" = "z$name" ||
|
||||||
git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" '^$'
|
test "z$origin" = "z$name"
|
||||||
done &&
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
git-repo-config remote."$origin".fetch \
|
||||||
|
"refs/heads/${name}:$remote_top/${name}" '^$'
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac &&
|
||||||
|
|
||||||
case "$use_separate_remote" in
|
case "$use_separate_remote" in
|
||||||
t)
|
t)
|
||||||
rm -f "refs/remotes/$origin/HEAD"
|
rm -f "refs/remotes/$origin/HEAD"
|
||||||
git-symbolic-ref "refs/remotes/$origin/HEAD" \
|
git-symbolic-ref "refs/remotes/$origin/HEAD" \
|
||||||
"refs/remotes/$origin/$head_points_at"
|
"refs/remotes/$origin/$head_points_at"
|
||||||
esac &&
|
esac &&
|
||||||
|
|
||||||
git-repo-config branch."$head_points_at".remote "$origin" &&
|
git-repo-config branch."$head_points_at".remote "$origin" &&
|
||||||
git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
|
git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user