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
c2bdef6f
Commit
c2bdef6f
authored
Feb 24, 2023
by
Edward Thomson
Committed by
Edward Thomson
Feb 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: parse urls or scp style paths in the same function
parent
cfc3b379
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
src/libgit2/transports/ssh.c
+7
-11
src/util/net.c
+7
-0
src/util/net.h
+6
-0
No files found.
src/libgit2/transports/ssh.c
View file @
c2bdef6f
...
@@ -788,15 +788,8 @@ static int _git_ssh_setup_conn(
...
@@ -788,15 +788,8 @@ static int _git_ssh_setup_conn(
s
->
session
=
NULL
;
s
->
session
=
NULL
;
s
->
channel
=
NULL
;
s
->
channel
=
NULL
;
if
(
git_net_str_is_url
(
url
))
if
((
error
=
git_net_url_parse_standard_or_scp
(
&
s
->
url
,
url
))
<
0
||
error
=
git_net_url_parse
(
&
s
->
url
,
url
);
(
error
=
git_socket_stream_new
(
&
s
->
io
,
s
->
url
.
host
,
s
->
url
.
port
))
<
0
||
else
error
=
git_net_url_parse_scp
(
&
s
->
url
,
url
);
if
(
error
<
0
)
goto
done
;
if
((
error
=
git_socket_stream_new
(
&
s
->
io
,
s
->
url
.
host
,
s
->
url
.
port
))
<
0
||
(
error
=
git_stream_connect
(
s
->
io
))
<
0
)
(
error
=
git_stream_connect
(
s
->
io
))
<
0
)
goto
done
;
goto
done
;
...
@@ -806,8 +799,11 @@ static int _git_ssh_setup_conn(
...
@@ -806,8 +799,11 @@ static int _git_ssh_setup_conn(
* as part of the stream connection, but that's not something that's
* as part of the stream connection, but that's not something that's
* exposed.
* exposed.
*/
*/
if
(
git__strntol32
(
&
port
,
s
->
url
.
port
,
strlen
(
s
->
url
.
port
),
NULL
,
10
)
<
0
)
if
(
git__strntol32
(
&
port
,
s
->
url
.
port
,
strlen
(
s
->
url
.
port
),
NULL
,
10
)
<
0
)
{
port
=
-
1
;
git_error_set
(
GIT_ERROR_NET
,
"invalid port to ssh: %s"
,
s
->
url
.
port
);
error
=
-
1
;
goto
done
;
}
if
((
error
=
_git_ssh_session_create
(
&
session
,
&
known_hosts
,
s
->
url
.
host
,
port
,
s
->
io
))
<
0
)
if
((
error
=
_git_ssh_session_create
(
&
session
,
&
known_hosts
,
s
->
url
.
host
,
port
,
s
->
io
))
<
0
)
goto
done
;
goto
done
;
...
...
src/util/net.c
View file @
c2bdef6f
...
@@ -646,6 +646,13 @@ int git_net_url_parse_scp(git_net_url *url, const char *given)
...
@@ -646,6 +646,13 @@ int git_net_url_parse_scp(git_net_url *url, const char *given)
return
0
;
return
0
;
}
}
int
git_net_url_parse_standard_or_scp
(
git_net_url
*
url
,
const
char
*
given
)
{
return
git_net_str_is_url
(
given
)
?
git_net_url_parse
(
url
,
given
)
:
git_net_url_parse_scp
(
url
,
given
);
}
int
git_net_url_joinpath
(
int
git_net_url_joinpath
(
git_net_url
*
out
,
git_net_url
*
out
,
git_net_url
*
one
,
git_net_url
*
one
,
...
...
src/util/net.h
View file @
c2bdef6f
...
@@ -34,6 +34,12 @@ extern int git_net_url_parse(git_net_url *url, const char *str);
...
@@ -34,6 +34,12 @@ extern int git_net_url_parse(git_net_url *url, const char *str);
/** Parses a string containing an SCP style path into a URL structure. */
/** Parses a string containing an SCP style path into a URL structure. */
extern
int
git_net_url_parse_scp
(
git_net_url
*
url
,
const
char
*
str
);
extern
int
git_net_url_parse_scp
(
git_net_url
*
url
,
const
char
*
str
);
/**
* Parses a string containing a standard URL or an SCP style path into
* a URL structure.
*/
extern
int
git_net_url_parse_standard_or_scp
(
git_net_url
*
url
,
const
char
*
str
);
/** Appends a path and/or query string to the given URL */
/** Appends a path and/or query string to the given URL */
extern
int
git_net_url_joinpath
(
extern
int
git_net_url_joinpath
(
git_net_url
*
out
,
git_net_url
*
out
,
...
...
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