Skip to content

Commit

Permalink
Bring local clone's origin URL in line with that of a remote clone
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johan Herland authored and Junio C Hamano committed Sep 2, 2008
1 parent f733c70 commit 86521ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion builtin-clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)

path = get_repo_path(repo_name, &is_bundle);
if (path)
repo = path;
repo = xstrdup(make_nonrelative_path(repo_name));
else if (!strchr(repo_name, ':'))
repo = xstrdup(make_absolute_path(repo_name));
else
Expand Down
6 changes: 3 additions & 3 deletions t/t5505-remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test_expect_success 'remove remote' '

cat > test/expect << EOF
* remote origin
URL: $(pwd)/one/.git
URL: $(pwd)/one
Remote branch merged with 'git pull' while on branch master
master
New remote branch (next fetch will store in remotes/origin)
Expand Down Expand Up @@ -140,7 +140,7 @@ test_expect_success 'show' '

cat > test/expect << EOF
* remote origin
URL: $(pwd)/one/.git
URL: $(pwd)/one
Remote branch merged with 'git pull' while on branch master
master
Tracked remote branches
Expand Down Expand Up @@ -169,7 +169,7 @@ test_expect_success 'prune' '

cat > test/expect << EOF
Pruning origin
URL: $(pwd)/one/.git
URL: $(pwd)/one
* [would prune] origin/side2
EOF

Expand Down

0 comments on commit 86521ac

Please sign in to comment.