|
22 | 22 | #include "fs_path.h"
|
23 | 23 | #include "repository.h"
|
24 | 24 | #include "odb.h"
|
| 25 | +#include "net.h" |
25 | 26 |
|
26 | 27 | static int clone_local_into(git_repository *repo, git_remote *remote, const git_fetch_options *fetch_opts, const git_checkout_options *co_opts, const char *branch, int link);
|
27 | 28 |
|
@@ -336,8 +337,9 @@ static int create_and_configure_origin(
|
336 | 337 | git_remote_create_cb remote_create = options->remote_cb;
|
337 | 338 | void *payload = options->remote_cb_payload;
|
338 | 339 |
|
339 |
| - /* If the path exists and is a dir, the url should be the absolute path */ |
340 |
| - if (git_fs_path_root(url) < 0 && git_fs_path_exists(url) && git_fs_path_isdir(url)) { |
| 340 | + /* If the path is local and exists it should be the absolute path. */ |
| 341 | + if (!git_net_str_is_url(url) && git_fs_path_root(url) < 0 && |
| 342 | + git_fs_path_exists(url)) { |
341 | 343 | if (p_realpath(url, buf) == NULL)
|
342 | 344 | return -1;
|
343 | 345 |
|
@@ -458,26 +460,25 @@ static int clone_into(
|
458 | 460 | int git_clone__should_clone_local(const char *url_or_path, git_clone_local_t local)
|
459 | 461 | {
|
460 | 462 | git_str fromurl = GIT_STR_INIT;
|
461 |
| - const char *path = url_or_path; |
462 |
| - bool is_url, is_local; |
| 463 | + bool is_local; |
463 | 464 |
|
464 | 465 | if (local == GIT_CLONE_NO_LOCAL)
|
465 | 466 | return 0;
|
466 | 467 |
|
467 |
| - if ((is_url = git_fs_path_is_local_file_url(url_or_path)) != 0) { |
468 |
| - if (git_fs_path_fromurl(&fromurl, url_or_path) < 0) { |
469 |
| - is_local = -1; |
470 |
| - goto done; |
471 |
| - } |
| 468 | + if (git_net_str_is_url(url_or_path)) { |
| 469 | + /* If GIT_CLONE_LOCAL_AUTO is specified, any url should be treated as remote */ |
| 470 | + if (local == GIT_CLONE_LOCAL_AUTO || |
| 471 | + !git_fs_path_is_local_file_url(url_or_path)) |
| 472 | + return 0; |
472 | 473 |
|
473 |
| - path = fromurl.ptr; |
| 474 | + if (git_fs_path_fromurl(&fromurl, url_or_path) == 0) |
| 475 | + is_local = git_fs_path_isdir(git_str_cstr(&fromurl)); |
| 476 | + else |
| 477 | + is_local = -1; |
| 478 | + git_str_dispose(&fromurl); |
| 479 | + } else { |
| 480 | + is_local = git_fs_path_isdir(url_or_path); |
474 | 481 | }
|
475 |
| - |
476 |
| - is_local = (!is_url || local != GIT_CLONE_LOCAL_AUTO) && |
477 |
| - git_fs_path_isdir(path); |
478 |
| - |
479 |
| -done: |
480 |
| - git_str_dispose(&fromurl); |
481 | 482 | return is_local;
|
482 | 483 | }
|
483 | 484 |
|
|
0 commit comments