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
53a8f463
Unverified
Commit
53a8f463
authored
Jun 03, 2020
by
Patrick Steinhardt
Committed by
GitHub
Jun 03, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5536 from libgit2/ethomson/http
httpclient: support googlesource
parents
6de8aa7f
04c7bdb4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
src/transports/httpclient.c
+16
-4
tests/online/clone.c
+8
-0
No files found.
src/transports/httpclient.c
View file @
53a8f463
...
...
@@ -1038,6 +1038,7 @@ on_error:
GIT_INLINE
(
int
)
client_read
(
git_http_client
*
client
)
{
http_parser_context
*
parser_context
=
client
->
parser
.
data
;
git_stream
*
stream
;
char
*
buf
=
client
->
read_buf
.
ptr
+
client
->
read_buf
.
size
;
size_t
max_len
;
...
...
@@ -1054,6 +1055,9 @@ GIT_INLINE(int) client_read(git_http_client *client)
max_len
=
client
->
read_buf
.
asize
-
client
->
read_buf
.
size
;
max_len
=
min
(
max_len
,
INT_MAX
);
if
(
parser_context
->
output_size
)
max_len
=
min
(
max_len
,
parser_context
->
output_size
);
if
(
max_len
==
0
)
{
git_error_set
(
GIT_ERROR_HTTP
,
"no room in output buffer"
);
return
-
1
;
...
...
@@ -1191,7 +1195,7 @@ static void complete_response_body(git_http_client *client)
/* If we're not keeping alive, don't bother. */
if
(
!
client
->
keepalive
)
{
client
->
connected
=
0
;
return
;
goto
done
;
}
parser_context
.
client
=
client
;
...
...
@@ -1205,6 +1209,9 @@ static void complete_response_body(git_http_client *client)
git_error_clear
();
client
->
connected
=
0
;
}
done
:
git_buf_clear
(
&
client
->
read_buf
);
}
int
git_http_client_send_request
(
...
...
@@ -1419,15 +1426,20 @@ int git_http_client_read_body(
client
->
parser
.
data
=
&
parser_context
;
/*
* Clients expect to get a non-zero amount of data from us.
* With a sufficiently small buffer, one might only read a chunk
* length. Loop until we actually have data to return.
* Clients expect to get a non-zero amount of data from us,
* so we either block until we have data to return, until we
* hit EOF or there's an error. Do this in a loop, since we
* may end up reading only some stream metadata (like chunk
* information).
*/
while
(
!
parser_context
.
output_written
)
{
error
=
client_read_and_parse
(
client
);
if
(
error
<=
0
)
goto
done
;
if
(
client
->
state
==
DONE
)
break
;
}
assert
(
parser_context
.
output_written
<=
INT_MAX
);
...
...
tests/online/clone.c
View file @
53a8f463
...
...
@@ -11,6 +11,7 @@
#define BB_REPO_URL "https://libgit3@bitbucket.org/libgit2/testgitrepository.git"
#define BB_REPO_URL_WITH_PASS "https://libgit3:libgit3@bitbucket.org/libgit2/testgitrepository.git"
#define BB_REPO_URL_WITH_WRONG_PASS "https://libgit3:wrong@bitbucket.org/libgit2/testgitrepository.git"
#define GOOGLESOURCE_REPO_URL "https://chromium.googlesource.com/external/github.com/sergi/go-diff"
#define SSH_REPO_URL "ssh://github.com/libgit2/TestGitRepository"
...
...
@@ -463,6 +464,13 @@ void test_online_clone__bitbucket_falls_back_to_specified_creds(void)
cl_fixture_cleanup
(
"./foo"
);
}
void
test_online_clone__googlesource
(
void
)
{
cl_git_pass
(
git_clone
(
&
g_repo
,
GOOGLESOURCE_REPO_URL
,
"./foo"
,
&
g_options
));
git_repository_free
(
g_repo
);
g_repo
=
NULL
;
cl_fixture_cleanup
(
"./foo"
);
}
static
int
cancel_at_half
(
const
git_indexer_progress
*
stats
,
void
*
payload
)
{
GIT_UNUSED
(
payload
);
...
...
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