Skip to content

Commit 6f57790

Browse files
committed
ssh urls: use git_buf_decode_percent
Use `git_buf_decode_percent` so that we can avoid allocating a temporary buffer.
1 parent 8070a35 commit 6f57790

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/transports/ssh.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg)
6464
*/
6565
static int gen_proto(git_buf *request, const char *cmd, const char *url)
6666
{
67-
char *repo;
67+
const char *repo;
6868
int len;
6969
size_t i;
7070

@@ -89,19 +89,17 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
8989
return -1;
9090
}
9191

92-
repo = gitno_unescape(git__strdup(repo));
93-
9492
len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1;
9593

9694
git_buf_grow(request, len);
97-
git_buf_printf(request, "%s '%s'", cmd, repo);
98-
git_buf_putc(request, '\0');
99-
100-
git__free(repo);
95+
git_buf_puts(request, cmd);
96+
git_buf_puts(request, " '");
97+
git_buf_decode_percent(request, repo, strlen(repo));
98+
git_buf_puts(request, "'");
10199

102100
if (git_buf_oom(request))
103101
return -1;
104-
102+
105103
return 0;
106104
}
107105

0 commit comments

Comments
 (0)