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>
Junio C Hamano committed
Dec 16, 2006 at 01:53 UTC
63085fabbdeaad9eb8b29d39d0998c704e6cd232
2 files changed
+13
-60
Documentation/git-clone.txt
+1
-14
@@ -11,8 +11,7 @@ SYNOPSIS
11
[verse]
12
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
13
[-o <name>] [-u <upload-pack>] [--reference <repository>]
14
- [--use-separate-remote | --no-separate-remote] <repository>
15
- [<directory>]
14
+ <repository> [<directory>]
15
16
DESCRIPTION
17
-----------
@@ -99,18 +98,6 @@ OPTIONS
98
if unset the templates are taken from the installation
99
defined default, typically `/usr/share/git-core/templates`.
100
102
---use-separate-remote::
103
- Save remotes heads under `$GIT_DIR/refs/remotes/origin/` instead
104
- of `$GIT_DIR/refs/heads/`. Only the local master branch is
105
- saved in the latter. This is the default.
106
-
107
---no-separate-remote::
108
- Save remotes heads in the same namespace as the local
109
- heads, `$GIT_DIR/refs/heads/'. In regular repositories,
110
- this is a legacy setup git-clone created by default in
111
- older Git versions, and will be removed before the next
112
- major release.
113
-
101
<repository>::
102
The (possibly remote) repository to clone from. It can
103
be any URL git-fetch supports.
git-clone.sh
+12
-46
@@ -14,7 +14,7 @@ die() {
14
}
15
16
usage() {
17
- die "Usage: $0 [--template=<template_directory>] [--no-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
17
+ die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
18
}
19
20
get_repo_base() {
@@ -137,11 +137,9 @@ while
137
*,--template=*)
138
template="$1" ;;
139
*,-q|*,--quiet) quiet=-q ;;
140
- *,--use-separate-remote)
141
- # default
142
- use_separate_remote=t ;;
140
+ *,--use-separate-remote) ;;
141
*,--no-separate-remote)
144
- use_separate_remote= ;;
142
+ die "clones are always made with separate-remote layout" ;;
143
1,--reference) usage ;;
144
*,--reference)
145
shift; reference="$1" ;;
@@ -327,12 +325,8 @@ cd "$D" || exit
325
326
if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
327
then
330
- # Figure out which remote branch HEAD points at.
331
- case "$use_separate_remote" in
332
- '') remote_top=refs/heads ;;
333
- *) remote_top="refs/remotes/$origin" ;;
334
- esac
335
-
328
+ # a non-bare repository is always in separate-remote layout
329
+ remote_top="refs/remotes/$origin"
330
head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
331
case "$head_sha1" in
332
'ref: refs/'*)
@@ -373,46 +367,18 @@ then
367
git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
368
369
# Tracking branch for the primary branch at the remote.
376
- case "$use_separate_remote" in
377
- t) origin_track="$remote_top/$head_points_at"
378
- git-update-ref HEAD "$head_sha1" ;;
379
- *) origin_track="$remote_top/$origin"
380
- git-update-ref "refs/heads/$origin" "$head_sha1" ;;
381
- esac &&
370
+ origin_track="$remote_top/$head_points_at" &&
371
+ git-update-ref HEAD "$head_sha1" &&
372
373
# Upstream URL
374
git-repo-config remote."$origin".url "$repo" &&
375
376
# Set up the mappings to track the remote branches.
387
- case "$use_separate_remote" in
388
- t)
389
- git-repo-config remote."$origin".fetch \
390
- "refs/heads/*:$remote_top/*" '^$'
391
- ;;
392
- *)
393
- git-repo-config remote."$origin".fetch \
394
- "refs/heads/$head_points_at:$origin_track" &&
395
- (cd "$GIT_DIR/$remote_top" && find . -type f -print) |
396
- while read dotslref
397
- do
398
- name=`expr "$dotslref" : './\(.*\)'`
399
- if test "z$head_points_at" = "z$name" ||
400
- test "z$origin" = "z$name"
401
- then
402
- continue
403
- fi
404
- git-repo-config remote."$origin".fetch \
405
- "refs/heads/${name}:$remote_top/${name}" '^$'
406
- done
407
- ;;
408
- esac &&
409
-
410
- case "$use_separate_remote" in
411
- t)
412
- rm -f "refs/remotes/$origin/HEAD"
413
- git-symbolic-ref "refs/remotes/$origin/HEAD" \
414
- "refs/remotes/$origin/$head_points_at"
415
- esac &&
377
+ git-repo-config remote."$origin".fetch \
378
+ "refs/heads/*:$remote_top/*" '^$' &&
379
+ rm -f "refs/remotes/$origin/HEAD"
380
+ git-symbolic-ref "refs/remotes/$origin/HEAD" \
381
+ "refs/remotes/$origin/$head_points_at" &&
382
383
git-repo-config branch."$head_points_at".remote "$origin" &&
384
git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"