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
4bef3565
Commit
4bef3565
authored
Nov 22, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remote: Assert things that should be asserted
parent
bec92f78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
src/remote.c
+23
-7
No files found.
src/remote.c
View file @
4bef3565
...
@@ -60,8 +60,8 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons
...
@@ -60,8 +60,8 @@ int git_remote_new(git_remote **out, git_repository *repo, const char *url, cons
{
{
git_remote
*
remote
;
git_remote
*
remote
;
if
(
url
==
NULL
)
/* name is optional */
return
git__throw
(
GIT_EINVALIDARGS
,
"No URL was given"
);
assert
(
out
&&
repo
&&
url
);
remote
=
git__malloc
(
sizeof
(
git_remote
));
remote
=
git__malloc
(
sizeof
(
git_remote
));
if
(
remote
==
NULL
)
if
(
remote
==
NULL
)
...
@@ -95,6 +95,8 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
...
@@ -95,6 +95,8 @@ int git_remote_get(git_remote **out, git_config *cfg, const char *name)
const
char
*
val
;
const
char
*
val
;
int
ret
,
error
,
buf_len
;
int
ret
,
error
,
buf_len
;
assert
(
out
&&
cfg
&&
name
);
remote
=
git__malloc
(
sizeof
(
git_remote
));
remote
=
git__malloc
(
sizeof
(
git_remote
));
if
(
remote
==
NULL
)
if
(
remote
==
NULL
)
return
GIT_ENOMEM
;
return
GIT_ENOMEM
;
...
@@ -169,23 +171,27 @@ cleanup:
...
@@ -169,23 +171,27 @@ cleanup:
return
error
;
return
error
;
}
}
const
char
*
git_remote_name
(
struct
git_remote
*
remote
)
const
char
*
git_remote_name
(
git_remote
*
remote
)
{
{
assert
(
remote
);
return
remote
->
name
;
return
remote
->
name
;
}
}
const
char
*
git_remote_url
(
struct
git_remote
*
remote
)
const
char
*
git_remote_url
(
git_remote
*
remote
)
{
{
assert
(
remote
);
return
remote
->
url
;
return
remote
->
url
;
}
}
const
git_refspec
*
git_remote_fetchspec
(
struct
git_remote
*
remote
)
const
git_refspec
*
git_remote_fetchspec
(
git_remote
*
remote
)
{
{
assert
(
remote
);
return
&
remote
->
fetch
;
return
&
remote
->
fetch
;
}
}
const
git_refspec
*
git_remote_pushspec
(
struct
git_remote
*
remote
)
const
git_refspec
*
git_remote_pushspec
(
git_remote
*
remote
)
{
{
assert
(
remote
);
return
&
remote
->
push
;
return
&
remote
->
push
;
}
}
...
@@ -194,6 +200,8 @@ int git_remote_connect(git_remote *remote, int direction)
...
@@ -194,6 +200,8 @@ int git_remote_connect(git_remote *remote, int direction)
int
error
;
int
error
;
git_transport
*
t
;
git_transport
*
t
;
assert
(
remote
);
error
=
git_transport_new
(
&
t
,
remote
->
url
);
error
=
git_transport_new
(
&
t
,
remote
->
url
);
if
(
error
<
GIT_SUCCESS
)
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to create transport"
);
return
git__rethrow
(
error
,
"Failed to create transport"
);
...
@@ -215,6 +223,7 @@ cleanup:
...
@@ -215,6 +223,7 @@ cleanup:
int
git_remote_ls
(
git_remote
*
remote
,
git_headarray
*
refs
)
int
git_remote_ls
(
git_remote
*
remote
,
git_headarray
*
refs
)
{
{
assert
(
remote
&&
refs
);
return
remote
->
transport
->
ls
(
remote
->
transport
,
refs
);
return
remote
->
transport
->
ls
(
remote
->
transport
,
refs
);
}
}
...
@@ -222,13 +231,15 @@ int git_remote_download(char **filename, git_remote *remote)
...
@@ -222,13 +231,15 @@ int git_remote_download(char **filename, git_remote *remote)
{
{
int
error
;
int
error
;
assert
(
filename
&&
remote
);
if
((
error
=
git_fetch_negotiate
(
remote
))
<
0
)
if
((
error
=
git_fetch_negotiate
(
remote
))
<
0
)
return
git__rethrow
(
error
,
"Error negotiating"
);
return
git__rethrow
(
error
,
"Error negotiating"
);
return
git_fetch_download_pack
(
filename
,
remote
);
return
git_fetch_download_pack
(
filename
,
remote
);
}
}
int
git_remote_update_tips
(
struct
git_remote
*
remote
)
int
git_remote_update_tips
(
git_remote
*
remote
)
{
{
int
error
=
GIT_SUCCESS
;
int
error
=
GIT_SUCCESS
;
unsigned
int
i
=
0
;
unsigned
int
i
=
0
;
...
@@ -238,6 +249,8 @@ int git_remote_update_tips(struct git_remote *remote)
...
@@ -238,6 +249,8 @@ int git_remote_update_tips(struct git_remote *remote)
git_reference
*
ref
;
git_reference
*
ref
;
struct
git_refspec
*
spec
=
&
remote
->
fetch
;
struct
git_refspec
*
spec
=
&
remote
->
fetch
;
assert
(
remote
);
memset
(
refname
,
0x0
,
sizeof
(
refname
));
memset
(
refname
,
0x0
,
sizeof
(
refname
));
if
(
refs
->
len
==
0
)
if
(
refs
->
len
==
0
)
...
@@ -269,11 +282,14 @@ int git_remote_update_tips(struct git_remote *remote)
...
@@ -269,11 +282,14 @@ int git_remote_update_tips(struct git_remote *remote)
int
git_remote_connected
(
git_remote
*
remote
)
int
git_remote_connected
(
git_remote
*
remote
)
{
{
assert
(
remote
);
return
remote
->
transport
==
NULL
?
0
:
remote
->
transport
->
connected
;
return
remote
->
transport
==
NULL
?
0
:
remote
->
transport
->
connected
;
}
}
void
git_remote_disconnect
(
git_remote
*
remote
)
void
git_remote_disconnect
(
git_remote
*
remote
)
{
{
assert
(
remote
);
if
(
remote
->
transport
!=
NULL
)
{
if
(
remote
->
transport
!=
NULL
)
{
if
(
remote
->
transport
->
connected
)
if
(
remote
->
transport
->
connected
)
remote
->
transport
->
close
(
remote
->
transport
);
remote
->
transport
->
close
(
remote
->
transport
);
...
...
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