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
51760bc1
Commit
51760bc1
authored
Oct 05, 2011
by
Carlos Martín Nieto
Committed by
Vicent Marti
Oct 12, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkt: get rid of the chunked support
It was a bad idea. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent
e5e92c1f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
54 deletions
+17
-54
src/netops.c
+0
-14
src/pkt.c
+5
-28
src/pkt.h
+4
-4
src/transport_git.c
+8
-8
No files found.
src/netops.c
View file @
51760bc1
...
...
@@ -152,20 +152,6 @@ int gitno_close(GIT_SOCKET s)
}
#endif
int
gitno_send_chunk_size
(
int
s
,
size_t
len
)
{
char
str
[
8
]
=
{
0
};
int
ret
;
ret
=
p_snprintf
(
str
,
sizeof
(
str
),
"%zx
\r\n
"
,
len
);
if
(
ret
>=
(
int
)
sizeof
(
str
))
{
return
git__throw
(
GIT_ESHORTBUFFER
,
"Your number is too big"
);
}
return
gitno_send
(
s
,
str
,
ret
,
0
/* TODO: MSG_MORE */
);
}
int
gitno_select_in
(
gitno_buffer
*
buf
,
long
int
sec
,
long
int
usec
)
{
fd_set
fds
;
...
...
src/pkt.c
View file @
51760bc1
...
...
@@ -268,16 +268,10 @@ int git_pkt_buffer_flush(git_buf *buf)
return
git_buf_oom
(
buf
)
?
GIT_ENOMEM
:
GIT_SUCCESS
;
}
int
git_pkt_send_flush
(
int
s
,
int
chunked
)
int
git_pkt_send_flush
(
int
s
)
{
char
flush
[]
=
"0000"
;
int
error
;
if
(
chunked
)
{
error
=
gitno_send_chunk_size
(
s
,
strlen
(
flush
));
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send chunk size"
);
}
return
gitno_send
(
s
,
flush
,
strlen
(
flush
),
0
);
}
...
...
@@ -356,7 +350,7 @@ int git_pkt_buffer_wants(git_headarray *refs, git_transport_caps *caps, git_buf
return
git_pkt_buffer_flush
(
buf
);
}
int
git_pkt_send_wants
(
git_headarray
*
refs
,
git_transport_caps
*
caps
,
int
fd
,
int
chunked
)
int
git_pkt_send_wants
(
git_headarray
*
refs
,
git_transport_caps
*
caps
,
int
fd
)
{
unsigned
int
i
=
0
;
int
error
=
GIT_SUCCESS
;
...
...
@@ -391,17 +385,12 @@ int git_pkt_send_wants(git_headarray *refs, git_transport_caps *caps, int fd, in
continue
;
git_oid_fmt
(
buf
+
strlen
(
WANT_PREFIX
),
&
head
->
oid
);
if
(
chunked
)
{
error
=
gitno_send_chunk_size
(
fd
,
strlen
(
buf
));
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send want chunk size"
);
}
error
=
gitno_send
(
fd
,
buf
,
strlen
(
buf
),
0
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send want pkt"
);
}
return
git_pkt_send_flush
(
fd
,
chunked
);
return
git_pkt_send_flush
(
fd
);
}
#define HAVE_PREFIX "0032have "
...
...
@@ -416,16 +405,10 @@ int git_pkt_buffer_have(git_oid *oid, git_buf *buf)
return
git_buf_oom
(
buf
)
?
GIT_ENOMEM
:
GIT_SUCCESS
;
}
int
git_pkt_send_have
(
git_oid
*
oid
,
int
fd
,
int
chunked
)
int
git_pkt_send_have
(
git_oid
*
oid
,
int
fd
)
{
char
buf
[]
=
"0032have 0000000000000000000000000000000000000000
\n
"
;
int
error
;
if
(
chunked
)
{
error
=
gitno_send_chunk_size
(
fd
,
strlen
(
buf
));
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send chunk size"
);
}
git_oid_fmt
(
buf
+
strlen
(
HAVE_PREFIX
),
oid
);
return
gitno_send
(
fd
,
buf
,
strlen
(
buf
),
0
);
}
...
...
@@ -438,15 +421,9 @@ int git_pkt_buffer_done(git_buf *buf)
return
git_buf_oom
(
buf
)
?
GIT_ENOMEM
:
GIT_SUCCESS
;
}
int
git_pkt_send_done
(
int
fd
,
int
chunked
)
int
git_pkt_send_done
(
int
fd
)
{
char
buf
[]
=
"0009done
\n
"
;
int
error
;
if
(
chunked
)
{
error
=
gitno_send_chunk_size
(
fd
,
strlen
(
buf
));
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send chunk size"
);
}
return
gitno_send
(
fd
,
buf
,
strlen
(
buf
),
0
);
}
src/pkt.h
View file @
51760bc1
...
...
@@ -65,13 +65,13 @@ typedef struct {
int
git_pkt_parse_line
(
git_pkt
**
head
,
const
char
*
line
,
const
char
**
out
,
size_t
len
);
int
git_pkt_buffer_flush
(
git_buf
*
buf
);
int
git_pkt_send_flush
(
int
s
,
int
chunked
);
int
git_pkt_send_flush
(
int
s
);
int
git_pkt_buffer_done
(
git_buf
*
buf
);
int
git_pkt_send_done
(
int
s
,
int
chunked
);
int
git_pkt_send_done
(
int
s
);
int
git_pkt_buffer_wants
(
git_headarray
*
refs
,
git_transport_caps
*
caps
,
git_buf
*
buf
);
int
git_pkt_send_wants
(
git_headarray
*
refs
,
git_transport_caps
*
caps
,
int
fd
,
int
chunked
);
int
git_pkt_send_wants
(
git_headarray
*
refs
,
git_transport_caps
*
caps
,
int
fd
);
int
git_pkt_buffer_have
(
git_oid
*
oid
,
git_buf
*
buf
);
int
git_pkt_send_have
(
git_oid
*
oid
,
int
fd
,
int
chunked
);
int
git_pkt_send_have
(
git_oid
*
oid
,
int
fd
);
void
git_pkt_free
(
git_pkt
*
pkt
);
#endif
src/transport_git.c
View file @
51760bc1
...
...
@@ -277,7 +277,7 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
char
buff
[
128
];
gitno_buffer
buf
;
error
=
git_pkt_send_wants
(
wants
,
&
t
->
caps
,
t
->
socket
,
0
);
error
=
git_pkt_send_wants
(
wants
,
&
t
->
caps
,
t
->
socket
);
if
(
error
<
GIT_SUCCESS
)
return
git__rethrow
(
error
,
"Failed to send wants list"
);
...
...
@@ -322,12 +322,12 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
*/
i
=
0
;
while
((
error
=
git_revwalk_next
(
&
oid
,
walk
))
==
GIT_SUCCESS
)
{
error
=
git_pkt_send_have
(
&
oid
,
t
->
socket
,
1
);
error
=
git_pkt_send_have
(
&
oid
,
t
->
socket
);
i
++
;
if
(
i
%
20
==
0
)
{
const
char
*
ptr
=
buf
.
data
,
*
line_end
;
git_pkt
*
pkt
;
git_pkt_send_flush
(
t
->
socket
,
0
);
git_pkt_send_flush
(
t
->
socket
);
while
(
1
)
{
/* Wait for max. 1 second */
error
=
gitno_select_in
(
&
buf
,
1
,
0
);
...
...
@@ -373,8 +373,8 @@ static int git_negotiate_fetch(git_transport *transport, git_repository *repo, g
error
=
GIT_SUCCESS
;
done:
git_pkt_send_flush
(
t
->
socket
,
0
);
git_pkt_send_done
(
t
->
socket
,
0
);
git_pkt_send_flush
(
t
->
socket
);
git_pkt_send_done
(
t
->
socket
);
cleanup:
git_revwalk_free
(
walk
);
...
...
@@ -385,14 +385,14 @@ static int git_send_flush(git_transport *transport)
{
transport_git
*
t
=
(
transport_git
*
)
transport
;
return
git_pkt_send_flush
(
t
->
socket
,
1
);
return
git_pkt_send_flush
(
t
->
socket
);
}
static
int
git_send_done
(
git_transport
*
transport
)
{
transport_git
*
t
=
(
transport_git
*
)
transport
;
return
git_pkt_send_done
(
t
->
socket
,
1
);
return
git_pkt_send_done
(
t
->
socket
);
}
static
int
store_pack
(
char
**
out
,
gitno_buffer
*
buf
,
git_repository
*
repo
)
...
...
@@ -492,7 +492,7 @@ static int git_close(git_transport *transport)
int
error
;
/* Can't do anything if there's an error, so don't bother checking */
git_pkt_send_flush
(
t
->
socket
,
0
);
git_pkt_send_flush
(
t
->
socket
);
error
=
gitno_close
(
t
->
socket
);
if
(
error
<
0
)
...
...
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