@matheusbsbs / matheus-bagliano / commits / 86521acaca
Fork 0

Bring local clone's origin URL in line with that of a remote clone

On a local clone, "git clone" would use the fully DWIMmed path as the origin URL in the resulting repo. This was slightly inconsistent with the case of a remote clone where the _given_ URL was used as the origin URL (because the DWIMming was done remotely, and was therefore not available to "git clone"). This behaviour caused problems when cloning a local non-bare repo with relative submodule URLs, because these submodule URLs would then be resolved against the DWIMmed URL (e.g. "/repo/.git") instead of the given URL (e.g. "/repo"). This patch teaches "git clone" to use the _given_ URL - instead of the DWIMmed path - as the origin URL. This causes relative submodule URLs to be resolved correctly, as long the _given_ URL indicates the correct directory against which the submodule URLs should be resolved. The patch also updates a testcase that contained the old-style origin URLs. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Herland committed Sep 1, 2008 at 21:07 UTC 86521acaca0cb9951d9ff5ac4bc2c736035267a0
2 files changed +4 -4
builtin-clone.c
+1 -1
@@ -387,7 +387,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
387
388 path = get_repo_path(repo_name, &is_bundle);
389 if (path)
390 - repo = path;
390 + repo = xstrdup(make_nonrelative_path(repo_name));
391 else if (!strchr(repo_name, ':'))
392 repo = xstrdup(make_absolute_path(repo_name));
393 else
t/t5505-remote.sh
+3 -3
@@ -109,7 +109,7 @@ test_expect_success 'remove remote' '
109
110 cat > test/expect << EOF
111 * remote origin
112 - URL: $(pwd)/one/.git
112 + URL: $(pwd)/one
113 Remote branch merged with 'git pull' while on branch master
114 master
115 New remote branch (next fetch will store in remotes/origin)
@@ -140,7 +140,7 @@ test_expect_success 'show' '
140
141 cat > test/expect << EOF
142 * remote origin
143 - URL: $(pwd)/one/.git
143 + URL: $(pwd)/one
144 Remote branch merged with 'git pull' while on branch master
145 master
146 Tracked remote branches
@@ -169,7 +169,7 @@ test_expect_success 'prune' '
169
170 cat > test/expect << EOF
171 Pruning origin
172 -URL: $(pwd)/one/.git
172 +URL: $(pwd)/one
173 * [would prune] origin/side2
174 EOF
175