git-clone: lose the traditional 'no-separate-remote' layout
Finally. The separate-remote layout is so much more organized than traditional and easier to work with especially when you need to deal with remote repositories with multiple branches and/or you need to deal with more than one remote repositories, and using traditional layout for new repositories simply does not make much sense. Internally we still have code for 1:1 mappings to create a bare clone; that is a good thing and will not go away. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
@ -11,8 +11,7 @@ SYNOPSIS
|
|||||||
[verse]
|
[verse]
|
||||||
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
|
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
|
||||||
[-o <name>] [-u <upload-pack>] [--reference <repository>]
|
[-o <name>] [-u <upload-pack>] [--reference <repository>]
|
||||||
[--use-separate-remote | --no-separate-remote] <repository>
|
<repository> [<directory>]
|
||||||
[<directory>]
|
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -99,18 +98,6 @@ OPTIONS
|
|||||||
if unset the templates are taken from the installation
|
if unset the templates are taken from the installation
|
||||||
defined default, typically `/usr/share/git-core/templates`.
|
defined default, typically `/usr/share/git-core/templates`.
|
||||||
|
|
||||||
--use-separate-remote::
|
|
||||||
Save remotes heads under `$GIT_DIR/refs/remotes/origin/` instead
|
|
||||||
of `$GIT_DIR/refs/heads/`. Only the local master branch is
|
|
||||||
saved in the latter. This is the default.
|
|
||||||
|
|
||||||
--no-separate-remote::
|
|
||||||
Save remotes heads in the same namespace as the local
|
|
||||||
heads, `$GIT_DIR/refs/heads/'. In regular repositories,
|
|
||||||
this is a legacy setup git-clone created by default in
|
|
||||||
older Git versions, and will be removed before the next
|
|
||||||
major release.
|
|
||||||
|
|
||||||
<repository>::
|
<repository>::
|
||||||
The (possibly remote) repository to clone from. It can
|
The (possibly remote) repository to clone from. It can
|
||||||
be any URL git-fetch supports.
|
be any URL git-fetch supports.
|
||||||
|
58
git-clone.sh
58
git-clone.sh
@ -14,7 +14,7 @@ die() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
die "Usage: $0 [--template=<template_directory>] [--no-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
|
die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_repo_base() {
|
get_repo_base() {
|
||||||
@ -137,11 +137,9 @@ while
|
|||||||
*,--template=*)
|
*,--template=*)
|
||||||
template="$1" ;;
|
template="$1" ;;
|
||||||
*,-q|*,--quiet) quiet=-q ;;
|
*,-q|*,--quiet) quiet=-q ;;
|
||||||
*,--use-separate-remote)
|
*,--use-separate-remote) ;;
|
||||||
# default
|
|
||||||
use_separate_remote=t ;;
|
|
||||||
*,--no-separate-remote)
|
*,--no-separate-remote)
|
||||||
use_separate_remote= ;;
|
die "clones are always made with separate-remote layout" ;;
|
||||||
1,--reference) usage ;;
|
1,--reference) usage ;;
|
||||||
*,--reference)
|
*,--reference)
|
||||||
shift; reference="$1" ;;
|
shift; reference="$1" ;;
|
||||||
@ -327,12 +325,8 @@ cd "$D" || exit
|
|||||||
|
|
||||||
if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
|
if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
|
||||||
then
|
then
|
||||||
# Figure out which remote branch HEAD points at.
|
# a non-bare repository is always in separate-remote layout
|
||||||
case "$use_separate_remote" in
|
remote_top="refs/remotes/$origin"
|
||||||
'') remote_top=refs/heads ;;
|
|
||||||
*) remote_top="refs/remotes/$origin" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
|
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
|
||||||
case "$head_sha1" in
|
case "$head_sha1" in
|
||||||
'ref: refs/'*)
|
'ref: refs/'*)
|
||||||
@ -373,46 +367,18 @@ then
|
|||||||
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.
|
# Tracking branch for the primary branch at the remote.
|
||||||
case "$use_separate_remote" in
|
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"
|
|
||||||
git-update-ref "refs/heads/$origin" "$head_sha1" ;;
|
|
||||||
esac &&
|
|
||||||
|
|
||||||
# Upstream URL
|
# Upstream URL
|
||||||
git-repo-config remote."$origin".url "$repo" &&
|
git-repo-config remote."$origin".url "$repo" &&
|
||||||
|
|
||||||
# Set up the mappings to track the remote branches.
|
# Set up the mappings to track the remote branches.
|
||||||
case "$use_separate_remote" in
|
git-repo-config remote."$origin".fetch \
|
||||||
t)
|
"refs/heads/*:$remote_top/*" '^$' &&
|
||||||
git-repo-config remote."$origin".fetch \
|
rm -f "refs/remotes/$origin/HEAD"
|
||||||
"refs/heads/*:$remote_top/*" '^$'
|
git-symbolic-ref "refs/remotes/$origin/HEAD" \
|
||||||
;;
|
"refs/remotes/$origin/$head_points_at" &&
|
||||||
*)
|
|
||||||
git-repo-config remote."$origin".fetch \
|
|
||||||
"refs/heads/$head_points_at:$origin_track" &&
|
|
||||||
(cd "$GIT_DIR/$remote_top" && find . -type f -print) |
|
|
||||||
while read dotslref
|
|
||||||
do
|
|
||||||
name=`expr "$dotslref" : './\(.*\)'`
|
|
||||||
if test "z$head_points_at" = "z$name" ||
|
|
||||||
test "z$origin" = "z$name"
|
|
||||||
then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
git-repo-config remote."$origin".fetch \
|
|
||||||
"refs/heads/${name}:$remote_top/${name}" '^$'
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
esac &&
|
|
||||||
|
|
||||||
case "$use_separate_remote" in
|
|
||||||
t)
|
|
||||||
rm -f "refs/remotes/$origin/HEAD"
|
|
||||||
git-symbolic-ref "refs/remotes/$origin/HEAD" \
|
|
||||||
"refs/remotes/$origin/$head_points_at"
|
|
||||||
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"
|
||||||
|
Reference in New Issue
Block a user