summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-03-03 20:09:09 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-03-19 16:08:01 -0700
commit6f57790657c447051986ec95b3ba474134d71386 (patch)
tree40f9ce029afb4b03efa745fcb5203769ca3426f0
parent8070a357fb6e1dc60a65a2281c932f71bbbd65d6 (diff)
downloadlibgit2-6f57790657c447051986ec95b3ba474134d71386.tar.gz
ssh urls: use `git_buf_decode_percent`
Use `git_buf_decode_percent` so that we can avoid allocating a temporary buffer.
-rw-r--r--src/transports/ssh.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index 42f9bff6f..dcd9b5e27 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -64,7 +64,7 @@ static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg)
*/
static int gen_proto(git_buf *request, const char *cmd, const char *url)
{
- char *repo;
+ const char *repo;
int len;
size_t i;
@@ -89,19 +89,17 @@ done:
return -1;
}
- repo = gitno_unescape(git__strdup(repo));
-
len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1;
git_buf_grow(request, len);
- git_buf_printf(request, "%s '%s'", cmd, repo);
- git_buf_putc(request, '\0');
-
- git__free(repo);
+ git_buf_puts(request, cmd);
+ git_buf_puts(request, " '");
+ git_buf_decode_percent(request, repo, strlen(repo));
+ git_buf_puts(request, "'");
if (git_buf_oom(request))
return -1;
-
+
return 0;
}