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
3313a05a
Commit
3313a05a
authored
Sep 18, 2011
by
Carlos Martín Nieto
Committed by
Vicent Marti
Oct 12, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: move stuff out of negotiate_fetch
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent
1636ba5a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
37 deletions
+55
-37
src/transport-http.c
+55
-37
No files found.
src/transport-http.c
View file @
3313a05a
...
...
@@ -341,6 +341,51 @@ static int http_ls(git_transport *transport, git_headarray *array)
return
GIT_SUCCESS
;
}
static
int
setup_walk
(
git_revwalk
**
out
,
git_repository
*
repo
)
{
git_revwalk
*
walk
;
git_strarray
refs
;
unsigned
int
i
;
git_reference
*
ref
;
int
error
;
error
=
git_reference_listall
(
&
refs
,
repo
,
GIT_REF_LISTALL
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to list references"
);
error
=
git_revwalk_new
(
&
walk
,
repo
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to setup walk"
);
git_revwalk_sorting
(
walk
,
GIT_SORT_TIME
);
for
(
i
=
0
;
i
<
refs
.
count
;
++
i
)
{
/* No tags */
if
(
!
git__prefixcmp
(
refs
.
strings
[
i
],
GIT_REFS_TAGS_DIR
))
continue
;
error
=
git_reference_lookup
(
&
ref
,
repo
,
refs
.
strings
[
i
]);
if
(
error
<
GIT_ERROR
)
{
error
=
git__rethrow
(
error
,
"Failed to lookup %s"
,
refs
.
strings
[
i
]);
goto
cleanup
;
}
if
(
git_reference_type
(
ref
)
==
GIT_REF_SYMBOLIC
)
continue
;
error
=
git_revwalk_push
(
walk
,
git_reference_oid
(
ref
));
if
(
error
<
GIT_ERROR
)
{
error
=
git__rethrow
(
error
,
"Failed to push %s"
,
refs
.
strings
[
i
]);
goto
cleanup
;
}
}
*
out
=
walk
;
cleanup:
git_strarray_free
(
&
refs
);
return
error
;
}
static
int
http_negotiate_fetch
(
git_transport
*
transport
,
git_repository
*
repo
,
git_headarray
*
wants
)
{
transport_http
*
t
=
(
transport_http
*
)
transport
;
...
...
@@ -349,20 +394,24 @@ static int http_negotiate_fetch(git_transport *transport, git_repository *repo,
unsigned
int
i
;
char
buff
[
128
];
gitno_buffer
buf
;
git_strarray
refs
;
git_revwalk
*
walk
;
git_reference
*
ref
;
git_oid
oid
;
const
char
*
prefix
=
"http://"
,
*
url
=
t
->
parent
.
url
;
git_buf
request
=
GIT_BUF_INIT
;
gitno_buffer_setup
(
&
buf
,
buff
,
sizeof
(
buff
),
t
->
socket
);
/* TODO: Store url in the transport */
if
(
!
git__prefixcmp
(
url
,
prefix
))
url
+=
strlen
(
prefix
);
error
=
setup_walk
(
&
walk
,
repo
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to setup walk"
);
do
{
error
=
do_connect
(
t
,
t
->
host
,
t
->
port
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Faile
to connect to host"
);
return
git__rethrow
(
error
,
"Failed
to connect to host"
);
error
=
gen_request
(
&
request
,
url
,
t
->
host
,
"POST"
,
"upload-pack"
);
if
(
error
<
GIT_SUCCESS
)
...
...
@@ -376,39 +425,6 @@ static int http_negotiate_fetch(git_transport *transport, git_repository *repo,
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send wants"
);
gitno_buffer_setup
(
&
buf
,
buff
,
sizeof
(
buff
),
t
->
socket
);
error
=
git_reference_listall
(
&
refs
,
repo
,
GIT_REF_LISTALL
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to list references"
);
error
=
git_revwalk_new
(
&
walk
,
repo
);
if
(
error
<
GIT_ERROR
)
{
error
=
git__rethrow
(
error
,
"Failed to list all references"
);
goto
cleanup
;
}
git_revwalk_sorting
(
walk
,
GIT_SORT_TIME
);
for
(
i
=
0
;
i
<
refs
.
count
;
++
i
)
{
/* No tags */
if
(
!
git__prefixcmp
(
refs
.
strings
[
i
],
GIT_REFS_TAGS_DIR
))
continue
;
error
=
git_reference_lookup
(
&
ref
,
repo
,
refs
.
strings
[
i
]);
if
(
error
<
GIT_ERROR
)
{
error
=
git__rethrow
(
error
,
"Failed to lookup %s"
,
refs
.
strings
[
i
]);
goto
cleanup
;
}
if
(
git_reference_type
(
ref
)
==
GIT_REF_SYMBOLIC
)
continue
;
error
=
git_revwalk_push
(
walk
,
git_reference_oid
(
ref
));
if
(
error
<
GIT_ERROR
)
{
error
=
git__rethrow
(
error
,
"Failed to push %s"
,
refs
.
strings
[
i
]);
goto
cleanup
;
}
}
git_strarray_free
(
&
refs
);
i
=
0
;
while
((
error
=
git_revwalk_next
(
&
oid
,
walk
))
==
GIT_SUCCESS
)
{
...
...
@@ -417,8 +433,10 @@ static int http_negotiate_fetch(git_transport *transport, git_repository *repo,
return
git__rethrow
(
error
,
"Failed to send have"
);
i
++
;
}
if
(
error
<
GIT_SUCCESS
||
i
>=
256
)
break
;
}
while
(
1
);
cleanup:
git_revwalk_free
(
walk
);
return
error
;
}
...
...
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