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
9ee498e8
Commit
9ee498e8
authored
Mar 08, 2016
by
Chris Hescock
Committed by
Edward Thomson
Apr 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only buffer if necessary.
parent
eb09ead2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
18 deletions
+39
-18
src/transports/smart_protocol.c
+39
-18
No files found.
src/transports/smart_protocol.c
View file @
9ee498e8
...
...
@@ -721,30 +721,58 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
return
0
;
}
static
int
add_push_report_sideband_pkt
(
git_push
*
push
,
git_buf
*
data_pkt_buf
)
static
int
add_push_report_sideband_pkt
(
git_push
*
push
,
git_
pkt_data
*
data_pkt
,
git_
buf
*
data_pkt_buf
)
{
git_pkt
*
pkt
;
const
char
*
line_end
;
const
char
*
line
,
*
line_end
;
size_t
line_len
;
int
error
;
int
reading_from_buf
=
data_pkt_buf
->
size
>
0
;
if
(
reading_from_buf
)
{
/* We had an existing partial packet, so add the new
* packet to the buffer and parse the whole thing */
git_buf_put
(
data_pkt_buf
,
data_pkt
->
data
,
data_pkt
->
len
);
line
=
data_pkt_buf
->
ptr
;
line_len
=
data_pkt_buf
->
size
;
}
else
{
line
=
data_pkt
->
data
;
line_len
=
data_pkt
->
len
;
}
while
(
data_pkt_buf
->
size
>
0
)
{
error
=
git_pkt_parse_line
(
&
pkt
,
data_pkt_buf
->
ptr
,
&
line_end
,
data_pkt_buf
->
size
);
while
(
line_len
>
0
)
{
error
=
git_pkt_parse_line
(
&
pkt
,
line
,
&
line_end
,
line_len
);
if
(
error
<
0
)
return
error
;
if
(
error
==
GIT_EBUFS
)
{
/* Buffer the data when the inner packet is split
* across multiple sideband packets */
if
(
!
reading_from_buf
)
git_buf_put
(
data_pkt_buf
,
line
,
line_len
);
error
=
0
;
goto
done
;
}
else
if
(
error
<
0
)
goto
done
;
/* Advance in the buffer */
git_buf_consume
(
data_pkt_buf
,
line_end
);
line_len
-=
(
line_end
-
line
);
line
=
line_end
;
error
=
add_push_report_pkt
(
push
,
pkt
);
git_pkt_free
(
pkt
);
if
(
error
<
0
&&
error
!=
GIT_ITEROVER
)
return
error
;
goto
done
;
}
return
0
;
error
=
0
;
done:
if
(
reading_from_buf
)
git_buf_consume
(
data_pkt_buf
,
line_end
);
return
error
;
}
static
int
parse_report
(
transport_smart
*
transport
,
git_push
*
push
)
...
...
@@ -754,7 +782,6 @@ static int parse_report(transport_smart *transport, git_push *push)
gitno_buffer
*
buf
=
&
transport
->
buffer
;
int
error
,
recvd
;
git_buf
data_pkt_buf
=
GIT_BUF_INIT
;
git_pkt_data
*
data_pkt
;
for
(;;)
{
if
(
buf
->
offset
>
0
)
...
...
@@ -788,14 +815,8 @@ static int parse_report(transport_smart *transport, git_push *push)
switch
(
pkt
->
type
)
{
case
GIT_PKT_DATA
:
/* This is a sideband packet which contains other packets
* Buffer the data in case the inner packet is split
* across multiple sideband packets */
data_pkt
=
(
git_pkt_data
*
)
pkt
;
git_buf_put
(
&
data_pkt_buf
,
data_pkt
->
data
,
data_pkt
->
len
);
error
=
add_push_report_sideband_pkt
(
push
,
&
data_pkt_buf
);
if
(
error
==
GIT_EBUFS
)
error
=
0
;
/* This is a sideband packet which contains other packets */
error
=
add_push_report_sideband_pkt
(
push
,
(
git_pkt_data
*
)
pkt
,
&
data_pkt_buf
);
break
;
case
GIT_PKT_ERR
:
giterr_set
(
GITERR_NET
,
"report-status: Error reported: %s"
,
...
...
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