Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
a591f362
Commit
a591f362
authored
Dec 09, 2019
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: introduce url formatting function
parent
d68f2b1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
src/net.c
+33
-0
src/net.h
+3
-0
No files found.
src/net.c
View file @
a591f362
...
...
@@ -348,6 +348,39 @@ void git_net_url_swap(git_net_url *a, git_net_url *b)
memcpy
(
b
,
&
tmp
,
sizeof
(
git_net_url
));
}
int
git_net_url_fmt
(
git_buf
*
buf
,
git_net_url
*
url
)
{
git_buf_puts
(
buf
,
url
->
scheme
);
git_buf_puts
(
buf
,
"://"
);
if
(
url
->
username
)
{
git_buf_puts
(
buf
,
url
->
username
);
if
(
url
->
password
)
{
git_buf_puts
(
buf
,
":"
);
git_buf_puts
(
buf
,
url
->
password
);
}
git_buf_putc
(
buf
,
'@'
);
}
git_buf_puts
(
buf
,
url
->
host
);
if
(
url
->
port
&&
!
git_net_url_is_default_port
(
url
))
{
git_buf_putc
(
buf
,
':'
);
git_buf_puts
(
buf
,
url
->
port
);
}
git_buf_puts
(
buf
,
url
->
path
?
url
->
path
:
"/"
);
if
(
url
->
query
)
{
git_buf_putc
(
buf
,
'?'
);
git_buf_puts
(
buf
,
url
->
query
);
}
return
git_buf_oom
(
buf
)
?
-
1
:
0
;
}
void
git_net_url_dispose
(
git_net_url
*
url
)
{
if
(
url
->
username
)
...
...
src/net.h
View file @
a591f362
...
...
@@ -45,6 +45,9 @@ extern int git_net_url_apply_redirect(
/** Swaps the contents of one URL for another. */
extern
void
git_net_url_swap
(
git_net_url
*
a
,
git_net_url
*
b
);
/** Places the URL into the given buffer. */
extern
int
git_net_url_fmt
(
git_buf
*
out
,
git_net_url
*
url
);
/** Disposes the contents of the structure. */
extern
void
git_net_url_dispose
(
git_net_url
*
url
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment