From 983d2ee284936e8bf14823863d3945b4d8740b94 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 24 Nov 2006 19:07:24 -0800 Subject: git-clone: stop dumb protocol from copying refs outside heads/ and tags/. Most notably, the original code first copied refs/remotes/ that remote side had to local, and overwrote them by mapping refs/heads/ from the remote when a dumb protocol transport was used. This makes the clone behaviour by dumb protocol in line with the git native and rsync transports. Signed-off-by: Junio C Hamano --- git-clone.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 9ed4135544..d4ee93f75b 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -48,6 +48,10 @@ Perhaps git-update-server-info needs to be run there?" case "$name" in *^*) continue;; esac + case "$bare,$name" in + yes,* | ,heads/* | ,tags/*) ;; + *) continue ;; + esac if test -n "$use_separate_remote" && branch_name=`expr "z$name" : 'zheads/\(.*\)'` then -- cgit v1.2.1 From 255cae88bcc8fcb0088459df13b55fa3d311b9e2 Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Sun, 26 Nov 2006 12:10:52 +0000 Subject: Use .git/config for storing "origin" shortcut repository Rather than use a separate config .git/remotes/ for remote shortcuts, this patch adds the analagous definitions to .git/config using git-repo-config calls. For example what was previously .git/remotes/origin URL: proto://host/path Pull: refs/heads/master:refs/heads/origin Is now added to .git/config as [remote "origin"] url = proto://host/path fetch = refs/heads/master:refs/heads/origin Signed-off-by: Andy Parkins Signed-off-by: Junio C Hamano --- git-clone.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index d4ee93f75b..b2d0f08e67 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -377,9 +377,9 @@ then *) origin_track="$remote_top/$origin" git-update-ref "refs/heads/$origin" "$head_sha1" ;; esac && - echo >"$GIT_DIR/remotes/$origin" \ - "URL: $repo -Pull: refs/heads/$head_points_at:$origin_track" && + git-repo-config remote."$origin".url "$repo" && + 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 @@ -393,8 +393,8 @@ Pull: refs/heads/$head_points_at:$origin_track" && then continue fi - echo "Pull: refs/heads/${name}:$remote_top/${name}" - done >>"$GIT_DIR/remotes/$origin" && + git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" '^$' + done && case "$use_separate_remote" in t) rm -f "refs/remotes/$origin/HEAD" -- cgit v1.2.1 From b360cca0b100e14abffa4cae78521b493c783738 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Mon, 4 Dec 2006 14:29:09 +0100 Subject: git-clone: Rename --use-immingled-remote option to --no-separate-remote With making --use-separate-remote default when creating non-bare clone, there was need for the flag which would turn off this behavior. It was called --use-immingled-remote. Immingle means to blend, to combine into one, to intermingle, but it is a bit obscure word. I think it would be better to use simply --no-separate-remote as the opposite to --use-separate-remote option to git clone. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- git-clone.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index d4ee93f75b..89640396e9 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -14,7 +14,7 @@ die() { } usage() { - die "Usage: $0 [--template=] [--use-immingled-remote] [--reference ] [--bare] [-l [-s]] [-q] [-u ] [--origin ] [-n] []" + die "Usage: $0 [--template=] [--no-separate-remote] [--reference ] [--bare] [-l [-s]] [-q] [-u ] [--origin ] [-n] []" } get_repo_base() { @@ -140,7 +140,7 @@ while *,--use-separate-remote) # default use_separate_remote=t ;; - *,--use-immingled-remote) + *,--no-separate-remote) use_separate_remote= ;; 1,--reference) usage ;; *,--reference) @@ -176,7 +176,7 @@ repo="$1" test -n "$repo" || die 'you must specify a repository to clone.' -# --bare implies --no-checkout and --use-immingled-remote +# --bare implies --no-checkout and --no-separate-remote if test yes = "$bare" then if test yes = "$origin_override" -- cgit v1.2.1 From 955289bf92f0513377763c9aacfe426d5151b05a Mon Sep 17 00:00:00 2001 From: Andy Parkins Date: Wed, 6 Dec 2006 12:07:23 +0000 Subject: Explicitly add the default "git pull" behaviour to .git/config on clone Without any specification in the .git/config file, git-pull will execute "git-pull origin"; which in turn defaults to pull from the first "pull" definition for the remote, "origin". This is a difficult set of defaults to track for a new user, and it's difficult to see what tells git to do this (especially when it is actually hard-coded behaviour). To ameliorate this slightly, this patch explicitly specifies the default behaviour during a clone using the "branch" section of the config. For example, a clone of a typical repository would create a .git/config containing: [remote "origin"] url = proto://host/repo.git fetch = refs/heads/master:refs/remotes/origin/master [branch "master"] remote = origin merge = refs/heads/master The [branch "master"] section is such that there is no change to the functionality of git-pull, but that functionality is now explicitly documented. Signed-off-by: Andy Parkins --- git-clone.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 0ace989fde..1f5d07a057 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -400,7 +400,9 @@ then rm -f "refs/remotes/$origin/HEAD" git-symbolic-ref "refs/remotes/$origin/HEAD" \ "refs/remotes/$origin/$head_points_at" - esac + esac && + git-repo-config branch."$head_points_at".remote "$origin" && + git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at" esac case "$no_checkout" in -- cgit v1.2.1 From 61dde8f91672ab362f3cfd3af8d6d09d448d4ffe Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 16 Dec 2006 01:14:39 -0800 Subject: 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 --- git-clone.sh | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 1f5d07a057..422499a537 100755 --- a/git-clone.sh +++ b/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 ?*) - mkdir -p "$GIT_DIR/remotes" && + # Local default branch git-symbolic-ref HEAD "refs/heads/$head_points_at" && + + # Tracking branch for the primary branch at the remote. case "$use_separate_remote" in t) origin_track="$remote_top/$head_points_at" git-update-ref HEAD "$head_sha1" ;; *) origin_track="$remote_top/$origin" git-update-ref "refs/heads/$origin" "$head_sha1" ;; esac && + + # Upstream URL and the primary branch tracking git-repo-config remote."$origin".url "$repo" && 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" - then - continue - fi - if test "$use_separate_remote" = '' && - test "z$origin" = "z$name" - then - continue - fi - git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" '^$' - done && + + # Set up the mappings to track the remaining branches. + case "$use_separate_remote" in + t) + git-repo-config remote."$origin".fetch \ + "refs/heads/*:$remote_top/*" '^$' + ;; + *) + (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".merge "refs/heads/$head_points_at" esac -- cgit v1.2.1 From 3dd3d5b0e20a74a82a7e684d63d9af86a983fbf6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 16 Dec 2006 01:41:51 -0800 Subject: git-clone: lose the artificial "first" fetch refspec Now we lost the "first refspec is the one that is merged by default" rule, there is no reason for clone to list the remote primary branch in the config file explicitly anymore. We still need it for the traditional layout for other reasons, though. Signed-off-by: Junio C Hamano --- git-clone.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 422499a537..68dc4f200a 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -380,18 +380,18 @@ then git-update-ref "refs/heads/$origin" "$head_sha1" ;; esac && - # Upstream URL and the primary branch tracking + # Upstream URL git-repo-config remote."$origin".url "$repo" && - git-repo-config remote."$origin".fetch \ - "refs/heads/$head_points_at:$origin_track" && - # Set up the mappings to track the remaining branches. + # Set up the mappings to track the remote branches. case "$use_separate_remote" in t) git-repo-config remote."$origin".fetch \ "refs/heads/*:$remote_top/*" '^$' ;; *) + 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 -- cgit v1.2.1 From 63085fabbdeaad9eb8b29d39d0998c704e6cd232 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 16 Dec 2006 01:53:10 -0800 Subject: 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 --- git-clone.sh | 58 ++++++++++++---------------------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-) (limited to 'git-clone.sh') diff --git a/git-clone.sh b/git-clone.sh index 68dc4f200a..490f3e48db 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -14,7 +14,7 @@ die() { } usage() { - die "Usage: $0 [--template=] [--no-separate-remote] [--reference ] [--bare] [-l [-s]] [-q] [-u ] [--origin ] [-n] []" + die "Usage: $0 [--template=] [--reference ] [--bare] [-l [-s]] [-q] [-u ] [--origin ] [-n] []" } get_repo_base() { @@ -137,11 +137,9 @@ while *,--template=*) template="$1" ;; *,-q|*,--quiet) quiet=-q ;; - *,--use-separate-remote) - # default - use_separate_remote=t ;; + *,--use-separate-remote) ;; *,--no-separate-remote) - use_separate_remote= ;; + die "clones are always made with separate-remote layout" ;; 1,--reference) usage ;; *,--reference) shift; reference="$1" ;; @@ -327,12 +325,8 @@ cd "$D" || exit if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD" then - # Figure out which remote branch HEAD points at. - case "$use_separate_remote" in - '') remote_top=refs/heads ;; - *) remote_top="refs/remotes/$origin" ;; - esac - + # a non-bare repository is always in separate-remote layout + remote_top="refs/remotes/$origin" head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"` case "$head_sha1" in 'ref: refs/'*) @@ -373,46 +367,18 @@ then git-symbolic-ref HEAD "refs/heads/$head_points_at" && # Tracking branch for the primary branch at the remote. - case "$use_separate_remote" in - t) origin_track="$remote_top/$head_points_at" - git-update-ref HEAD "$head_sha1" ;; - *) origin_track="$remote_top/$origin" - git-update-ref "refs/heads/$origin" "$head_sha1" ;; - esac && + origin_track="$remote_top/$head_points_at" && + git-update-ref HEAD "$head_sha1" && # Upstream URL git-repo-config remote."$origin".url "$repo" && # Set up the mappings to track the remote branches. - case "$use_separate_remote" in - t) - git-repo-config remote."$origin".fetch \ - "refs/heads/*:$remote_top/*" '^$' - ;; - *) - 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 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-repo-config branch."$head_points_at".remote "$origin" && git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at" -- cgit v1.2.1