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
10711769
Commit
10711769
authored
Nov 29, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploy versioned git_transport structure
parent
79cfa20d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
3 deletions
+38
-3
src/remote.c
+15
-0
src/transports/local.c
+2
-3
src/transports/smart.c
+1
-0
tests-clar/network/remotes.c
+20
-0
No files found.
src/remote.c
View file @
10711769
...
...
@@ -1024,10 +1024,25 @@ void git_remote_set_cred_acquire_cb(
remote
->
cred_acquire_cb
=
cred_acquire_cb
;
}
static
bool
transport_has_valid_version
(
const
git_transport
*
transport
)
{
if
(
!
transport
)
return
true
;
if
(
transport
->
version
>
0
&&
transport
->
version
<=
GIT_TRANSPORT_VERSION
)
return
true
;
giterr_set
(
GITERR_INVALID
,
"Invalid version %d on git_transport"
,
transport
->
version
);
return
false
;
}
int
git_remote_set_transport
(
git_remote
*
remote
,
git_transport
*
transport
)
{
assert
(
remote
&&
transport
);
if
(
!
transport_has_valid_version
(
transport
))
return
-
1
;
if
(
remote
->
transport
)
{
giterr_set
(
GITERR_NET
,
"A transport is already bound to this remote"
);
return
-
1
;
...
...
src/transports/local.c
View file @
10711769
...
...
@@ -403,11 +403,10 @@ int git_transport_local(git_transport **out, git_remote *owner, void *param)
GIT_UNUSED
(
param
);
t
=
git__
malloc
(
sizeof
(
transport_local
));
t
=
git__
calloc
(
1
,
sizeof
(
transport_local
));
GITERR_CHECK_ALLOC
(
t
);
memset
(
t
,
0x0
,
sizeof
(
transport_local
));
t
->
parent
.
version
=
GIT_TRANSPORT_VERSION
;
t
->
parent
.
connect
=
local_connect
;
t
->
parent
.
negotiate_fetch
=
local_negotiate_fetch
;
t
->
parent
.
download_pack
=
local_download_pack
;
...
...
src/transports/smart.c
View file @
10711769
...
...
@@ -303,6 +303,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
t
=
git__calloc
(
sizeof
(
transport_smart
),
1
);
GITERR_CHECK_ALLOC
(
t
);
t
->
parent
.
version
=
GIT_TRANSPORT_VERSION
;
t
->
parent
.
set_callbacks
=
git_smart__set_callbacks
;
t
->
parent
.
connect
=
git_smart__connect
;
t
->
parent
.
close
=
git_smart__close
;
...
...
tests-clar/network/remotes.c
View file @
10711769
...
...
@@ -279,3 +279,23 @@ void test_network_remotes__cannot_load_with_an_empty_url(void)
cl_git_fail
(
git_remote_load
(
&
remote
,
_repo
,
"empty-remote-url"
));
cl_assert
(
giterr_last
()
->
klass
==
GITERR_INVALID
);
}
void
test_network_remotes__check_structure_version
(
void
)
{
git_transport
transport
=
GIT_TRANSPORT_INIT
;
const
git_error
*
err
;
git_remote_free
(
_remote
);
cl_git_pass
(
git_remote_new
(
&
_remote
,
_repo
,
NULL
,
"test-protocol://localhost"
,
NULL
));
transport
.
version
=
0
;
cl_git_fail
(
git_remote_set_transport
(
_remote
,
&
transport
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
giterr_clear
();
transport
.
version
=
1024
;
cl_git_fail
(
git_remote_set_transport
(
_remote
,
&
transport
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
}
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