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
2869f404
Commit
2869f404
authored
Nov 22, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transport: Add `git_transport_valid_url`
parent
6616e207
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
15 deletions
+29
-15
include/git2/transport.h
+8
-0
src/transport.c
+21
-15
No files found.
include/git2/transport.h
View file @
2869f404
...
@@ -27,6 +27,14 @@ GIT_BEGIN_DECL
...
@@ -27,6 +27,14 @@ GIT_BEGIN_DECL
*/
*/
GIT_EXTERN
(
int
)
git_transport_new
(
git_transport
**
transport
,
const
char
*
url
);
GIT_EXTERN
(
int
)
git_transport_new
(
git_transport
**
transport
,
const
char
*
url
);
/**
* Return whether a string is a valid transport URL
*
* @param tranport the url to check
* @param 1 if the url is valid, 0 otherwise
*/
GIT_EXTERN
(
int
)
git_transport_valid_url
(
const
char
*
url
);
/** @} */
/** @} */
GIT_END_DECL
GIT_END_DECL
#endif
#endif
src/transport.c
View file @
2869f404
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include "git2/net.h"
#include "git2/net.h"
#include "transport.h"
#include "transport.h"
struct
{
st
atic
st
ruct
{
char
*
prefix
;
char
*
prefix
;
git_transport_cb
fn
;
git_transport_cb
fn
;
}
transports
[]
=
{
}
transports
[]
=
{
...
@@ -23,26 +23,20 @@ struct {
...
@@ -23,26 +23,20 @@ struct {
{
NULL
,
0
}
{
NULL
,
0
}
};
};
static
git_transport_cb
transport_new_fn
(
const
char
*
url
)
#define GIT_TRANSPORT_COUNT (sizeof(transports)/sizeof(transports[0]))
static
git_transport_cb
transport_find_fn
(
const
char
*
url
)
{
{
in
t
i
=
0
;
size_
t
i
=
0
;
while
(
1
)
{
/* TODO: Parse "example.com:project.git" as an SSH URL */
if
(
transports
[
i
].
prefix
==
NULL
)
break
;
for
(
i
=
0
;
i
<
GIT_TRANSPORT_COUNT
;
++
i
)
{
if
(
!
strncasecmp
(
url
,
transports
[
i
].
prefix
,
strlen
(
transports
[
i
].
prefix
)))
if
(
!
strncasecmp
(
url
,
transports
[
i
].
prefix
,
strlen
(
transports
[
i
].
prefix
)))
return
transports
[
i
].
fn
;
return
transports
[
i
].
fn
;
++
i
;
}
}
/*
return
NULL
;
* If we still haven't found the transport, we assume we mean a
* local file.
* TODO: Parse "example.com:project.git" as an SSH URL
*/
return
git_transport_local
;
}
}
/**************
/**************
...
@@ -55,13 +49,25 @@ int git_transport_dummy(git_transport **GIT_UNUSED(transport))
...
@@ -55,13 +49,25 @@ int git_transport_dummy(git_transport **GIT_UNUSED(transport))
return
git__throw
(
GIT_ENOTIMPLEMENTED
,
"This protocol isn't implemented. Sorry"
);
return
git__throw
(
GIT_ENOTIMPLEMENTED
,
"This protocol isn't implemented. Sorry"
);
}
}
int
git_transport_valid_url
(
const
char
*
url
)
{
return
transport_find_fn
(
url
)
!=
NULL
;
}
int
git_transport_new
(
git_transport
**
out
,
const
char
*
url
)
int
git_transport_new
(
git_transport
**
out
,
const
char
*
url
)
{
{
git_transport_cb
fn
;
git_transport_cb
fn
;
git_transport
*
transport
;
git_transport
*
transport
;
int
error
;
int
error
;
fn
=
transport_new_fn
(
url
);
fn
=
transport_find_fn
(
url
);
/*
* If we haven't found the transport, we assume we mean a
* local file.
*/
if
(
fn
==
NULL
)
fn
=
&
git_transport_local
;
error
=
fn
(
&
transport
);
error
=
fn
(
&
transport
);
if
(
error
<
GIT_SUCCESS
)
if
(
error
<
GIT_SUCCESS
)
...
...
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