summaryrefslogtreecommitdiff
path: root/src/transports/local.c
diff options
context:
space:
mode:
authorGraham Dennis <graham.dennis@gmail.com>2014-01-18 08:02:58 +1100
committerGraham Dennis <graham.dennis@gmail.com>2014-01-18 08:02:58 +1100
commit4e974c971f39ac5e72bf656b49e43f208146d29e (patch)
tree5c1a9928b802a693d6e7704ae3d3495c94c4f950 /src/transports/local.c
parentb6815fe0d5a9abc80b4f91b0f57fdc9e5a8bbcf1 (diff)
downloadlibgit2-4e974c971f39ac5e72bf656b49e43f208146d29e.tar.gz
Fix local push to file:// URL.
Diffstat (limited to 'src/transports/local.c')
-rw-r--r--src/transports/local.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/transports/local.c b/src/transports/local.c
index 253aca30a..bd756c48a 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -344,11 +344,29 @@ static int local_push(
git_repository *remote_repo = NULL;
push_spec *spec;
char *url = NULL;
+ const char *path;
+ git_buf buf = GIT_BUF_INIT;
int error;
unsigned int i;
size_t j;
- if ((error = git_repository_open(&remote_repo, push->remote->url)) < 0)
+ /* The repo layer doesn't want the prefix */
+ if (!git__prefixcmp(push->remote->url, "file://")) {
+ if (git_path_fromurl(&buf, push->remote->url) < 0) {
+ git_buf_free(&buf);
+ return -1;
+ }
+ path = git_buf_cstr(&buf);
+
+ } else { /* We assume push->remote->url is already a path */
+ path = push->remote->url;
+ }
+
+ error = git_repository_open(&remote_repo, path);
+
+ git_buf_free(&buf);
+
+ if (error < 0)
return error;
/* We don't currently support pushing locally to non-bare repos. Proper