diff options
author | Patrick Steinhardt <ps@pks.im> | 2020-03-31 15:42:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 15:42:14 +0200 |
commit | 7a2b969d559b83798d93728f24d1729ffc97b717 (patch) | |
tree | c4c6c9c0710c47a1da978d625ff2cf066eeff4c4 /src/netops.c | |
parent | 1e5b139509073e9209c34466de10d51baa821df5 (diff) | |
parent | bb52d9fa598ce74f82c4294e0aa98b4bdbfdbc7e (diff) | |
download | libgit2-maint/v0.28.tar.gz |
Merge pull request #5473 from libgit2/ethomson/v0.28.5v0.28.5maint/v0.28
fetchhead: strip credentials from remote URL
Diffstat (limited to 'src/netops.c')
-rw-r--r-- | src/netops.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/netops.c b/src/netops.c index ecbc2aebe..f63ff380a 100644 --- a/src/netops.c +++ b/src/netops.c @@ -206,6 +206,35 @@ cleanup: return error; } +int gitno_connection_data_fmt(git_buf *buf, gitno_connection_data *d) +{ + if (d->host) { + git_buf_puts(buf, d->use_ssl ? prefix_https : prefix_http); + + if (d->user) { + git_buf_puts(buf, d->user); + + if (d->pass) { + git_buf_puts(buf, ":"); + git_buf_puts(buf, d->pass); + } + + git_buf_putc(buf, '@'); + } + + git_buf_puts(buf, d->host); + + if (d->port && strcmp(d->port, gitno__default_port(d))) { + git_buf_putc(buf, ':'); + git_buf_puts(buf, d->port); + } + } + + git_buf_puts(buf, d->path ? d->path : "/"); + + return git_buf_oom(buf) ? -1 : 0; +} + void gitno_connection_data_free_ptrs(gitno_connection_data *d) { git__free(d->host); d->host = NULL; |