mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-12 12:20:06 +00:00
clone: store the realpath when given a relative one
A call like git_clone("./foo", "./foo1") writes origin's url as './foo', which makes it unusable, as they're relative to different things. Go with git's behaviour and store the realpath as the url.
This commit is contained in:
parent
4386d80be1
commit
a0b5f7854c
11
src/clone.c
11
src/clone.c
@ -242,6 +242,15 @@ static int create_and_configure_origin(
|
|||||||
int error;
|
int error;
|
||||||
git_remote *origin = NULL;
|
git_remote *origin = NULL;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
char buf[GIT_PATH_MAX];
|
||||||
|
|
||||||
|
/* If the path exists and is a dir, the url should be the absolute path */
|
||||||
|
if (git_path_root(url) < 0 && git_path_exists(url) && git_path_isdir(url)) {
|
||||||
|
if (p_realpath(url, buf) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
url = buf;
|
||||||
|
}
|
||||||
|
|
||||||
name = options->remote_name ? options->remote_name : "origin";
|
name = options->remote_name ? options->remote_name : "origin";
|
||||||
if ((error = git_remote_create(&origin, repo, name, url)) < 0)
|
if ((error = git_remote_create(&origin, repo, name, url)) < 0)
|
||||||
@ -372,7 +381,7 @@ int git_clone(
|
|||||||
return error;
|
return error;
|
||||||
|
|
||||||
if (!(error = create_and_configure_origin(&origin, repo, url, &options))) {
|
if (!(error = create_and_configure_origin(&origin, repo, url, &options))) {
|
||||||
if (git__prefixcmp(url, "file://")) {
|
if (git_path_exists(url) && git_path_isdir(url)) {
|
||||||
error = git_clone_local_into(
|
error = git_clone_local_into(
|
||||||
repo, origin, &options.checkout_opts,
|
repo, origin, &options.checkout_opts,
|
||||||
options.checkout_branch, options.signature);
|
options.checkout_branch, options.signature);
|
||||||
|
Loading…
Reference in New Issue
Block a user