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
ed21fd74
Commit
ed21fd74
authored
Dec 22, 2015
by
Chris Bargren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle git+ssh:// and ssh+git:// protocols support
parent
d900cec9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
17 deletions
+35
-17
src/transport.c
+2
-0
src/transports/ssh.c
+33
-17
No files found.
src/transport.c
View file @
ed21fd74
...
...
@@ -35,6 +35,8 @@ static transport_definition transports[] = {
{
"file://"
,
git_transport_local
,
NULL
},
#ifdef GIT_SSH
{
"ssh://"
,
git_transport_smart
,
&
ssh_subtransport_definition
},
{
"ssh+git://"
,
git_transport_smart
,
&
ssh_subtransport_definition
},
{
"git+ssh://"
,
git_transport_smart
,
&
ssh_subtransport_definition
},
#endif
{
NULL
,
0
,
0
}
};
...
...
src/transports/ssh.c
View file @
ed21fd74
...
...
@@ -20,7 +20,9 @@
#define OWNING_SUBTRANSPORT(s) ((ssh_subtransport *)(s)->parent.subtransport)
static
const
char
prefix_ssh
[]
=
"ssh://"
;
static
const
char
*
ssh_prefixes
[]
=
{
"ssh://"
,
"ssh+git://"
,
"git+ssh://"
};
#define SSH_PREFIX_COUNT (sizeof(ssh_prefixes) / sizeof(ssh_prefixes[0]))
static
const
char
cmd_uploadpack
[]
=
"git-upload-pack"
;
static
const
char
cmd_receivepack
[]
=
"git-receive-pack"
;
...
...
@@ -63,16 +65,23 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url)
char
*
repo
;
int
len
;
if
(
!
git__prefixcmp
(
url
,
prefix_ssh
))
{
url
=
url
+
strlen
(
prefix_ssh
);
repo
=
strchr
(
url
,
'/'
);
if
(
repo
&&
repo
[
1
]
==
'~'
)
++
repo
;
}
else
{
repo
=
strchr
(
url
,
':'
);
if
(
repo
)
repo
++
;
size_t
i
=
0
;
for
(
i
=
0
;
i
<
SSH_PREFIX_COUNT
;
++
i
)
{
const
char
*
p
=
ssh_prefixes
[
i
];
if
(
!
git__prefixcmp
(
url
,
p
))
{
url
=
url
+
strlen
(
p
);
repo
=
strchr
(
url
,
'/'
);
if
(
repo
&&
repo
[
1
]
==
'~'
)
++
repo
;
goto
done
;
}
}
repo
=
strchr
(
url
,
':'
);
if
(
repo
)
repo
++
;
done:
if
(
!
repo
)
{
giterr_set
(
GITERR_NET
,
"Malformed git protocol URL"
);
return
-
1
;
...
...
@@ -509,16 +518,23 @@ static int _git_ssh_setup_conn(
s
->
session
=
NULL
;
s
->
channel
=
NULL
;
if
(
!
git__prefixcmp
(
url
,
prefix_ssh
))
{
if
((
error
=
gitno_extract_url_parts
(
&
host
,
&
port
,
&
path
,
&
user
,
&
pass
,
url
,
default_port
))
<
0
)
goto
done
;
}
else
{
if
((
error
=
git_ssh_extract_url_parts
(
&
host
,
&
user
,
url
))
<
0
)
goto
done
;
port
=
git__strdup
(
default_port
);
GITERR_CHECK_ALLOC
(
port
);
size_t
i
=
0
;
for
(
i
=
0
;
i
<
SSH_PREFIX_COUNT
;
++
i
)
{
const
char
*
p
=
ssh_prefixes
[
i
];
if
(
!
git__prefixcmp
(
url
,
p
))
{
if
((
error
=
gitno_extract_url_parts
(
&
host
,
&
port
,
&
path
,
&
user
,
&
pass
,
url
,
default_port
))
<
0
)
goto
done
;
goto
post_extract
;
}
}
if
((
error
=
git_ssh_extract_url_parts
(
&
host
,
&
user
,
url
))
<
0
)
goto
done
;
port
=
git__strdup
(
default_port
);
GITERR_CHECK_ALLOC
(
port
);
post_extract:
if
((
error
=
git_socket_stream_new
(
&
s
->
io
,
host
,
port
))
<
0
||
(
error
=
git_stream_connect
(
s
->
io
))
<
0
)
goto
done
;
...
...
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