summaryrefslogtreecommitdiff
path: root/src/path.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-06-03 21:47:53 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-06-03 21:47:53 +0200
commit18d7896cb00b9a4abe55cb461e12db4813e6a59e (patch)
treee701c6bfee7bc851280a0130463ee98c44dc8faf /src/path.c
parentbccb36ebf9d950f7562153d9e9ef9a3678e72516 (diff)
downloadlibgit2-cmn/path-to-path.tar.gz
clone: re-use the local transport's path resolutioncmn/path-to-path
Whe already worked out the kinks with the function used in the local transport. Expose it and make use of it in the local clone method instead of trying to work it out again.
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c
index e0b00a086..5beab97ed 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1127,3 +1127,21 @@ int git_path_dirload_with_stat(
return error;
}
+
+int git_path_from_url_or_path(git_buf *local_path_out, const char *url_or_path)
+{
+ int error;
+
+ /* If url_or_path begins with file:// treat it as a URL */
+ if (!git__prefixcmp(url_or_path, "file://")) {
+ if ((error = git_path_fromurl(local_path_out, url_or_path)) < 0) {
+ return error;
+ }
+ } else { /* We assume url_or_path is already a path */
+ if ((error = git_buf_sets(local_path_out, url_or_path)) < 0) {
+ return error;
+ }
+ }
+
+ return 0;
+}