diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-01-13 00:00:50 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-01-19 09:45:08 +0200 |
commit | 5a767ce9644b12e2eab5ef928ebb9673f36fcff8 (patch) | |
tree | 3a70beeca69e3f8264536e98af3cbbc2264dd329 /core | |
parent | cec642b4d21c55cdddbb57067565f69ca080bf1e (diff) | |
download | subsurface-5a767ce9644b12e2eab5ef928ebb9673f36fcff8.tar.gz |
Support non-https:// repositories for saving
On saving to a remote git repository, the transport was set to https://,
which broke saving to ssh:// repositories. Instead determine the
transport from the remote url.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/git-access.c | 17 | ||||
-rw-r--r-- | core/git-access.h | 1 | ||||
-rw-r--r-- | core/save-git.c | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/core/git-access.c b/core/git-access.c index bb5acbec6..ac8778f73 100644 --- a/core/git-access.c +++ b/core/git-access.c @@ -766,18 +766,21 @@ static git_repository *create_local_repo(const char *localdir, const char *remot return cloned_repo; } -static struct git_repository *get_remote_repo(const char *localdir, const char *remote, const char *branch) +enum remote_transport url_to_remote_transport(const char *remote) { - struct stat st; - enum remote_transport rt; - /* figure out the remote transport */ if (strncmp(remote, "ssh://", 6) == 0) - rt = RT_SSH; + return RT_SSH; else if (strncmp(remote, "https://", 8) == 0) - rt = RT_HTTPS; + return RT_HTTPS; else - rt = RT_OTHER; + return RT_OTHER; +} + +static struct git_repository *get_remote_repo(const char *localdir, const char *remote, const char *branch) +{ + struct stat st; + enum remote_transport rt = url_to_remote_transport(remote); if (verbose > 1) { fprintf(stderr, "git_remote_repo: accessing %s\n", remote); diff --git a/core/git-access.h b/core/git-access.h index 6dec7a56b..77ff106a0 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -25,6 +25,7 @@ extern int do_git_save(git_repository *repo, const char *branch, const char *rem extern const char *saved_git_id; extern void clear_git_id(void); extern void set_git_id(const struct git_oid *); +extern enum remote_transport url_to_remote_transport(const char *remote); void set_git_update_cb(int(*)(const char *)); int git_storage_update_progress(const char *text); char *get_local_dir(const char *remote, const char *branch); diff --git a/core/save-git.c b/core/save-git.c index 287a8bab9..c8c9f06a4 100644 --- a/core/save-git.c +++ b/core/save-git.c @@ -1274,7 +1274,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo /* now sync the tree with the remote server */ if (remote && !prefs.git_local_only) - return sync_with_remote(repo, remote, branch, RT_HTTPS); + return sync_with_remote(repo, remote, branch, url_to_remote_transport(remote)); return 0; } |