diff options
Diffstat (limited to 'src/path.c')
-rw-r--r-- | src/path.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c index 0c1013fa0..377f396d3 100644 --- a/src/path.c +++ b/src/path.c @@ -1135,3 +1135,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; +} |