Commit Graph

40 Commits

Author SHA1 Message Date
Carlos Martín Nieto
34bfb4b0d4 net,pkt: add chunked support
As we don't know the length of the message we want to send to the
other end, we send a chunk size before each message. In later
versions, sending the wants might benefit from batching the lines
together.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-12 21:33:18 +02:00
Carlos Martín Nieto
7ad994bb60 transport-git: fix git request length calculation
There was an off-by-one error that was uncovered when we used the
right length from git_buf.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 13:46:35 +02:00
Vicent Marti
10063aeb41 transport-git: Encapsulation ist gut 2011-10-01 13:10:29 +02:00
Carlos Martín Nieto
bad53552e5 netops: abstract away socket closing
Winsock wants us to use closesocket() instead of close(), so introduce
the gitno_close function, which does the right thing.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 00:41:09 +02:00
Carlos Martín Nieto
ccc9872d4d Initialise the winsock DLL
Windows wants us to initialise the networking DLL before we're allowed
to send data through a socket. Call WSASetup and WSACleanup if
GIT_WIN32 is defined.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 00:41:08 +02:00
Carlos Martín Nieto
a95aeb489f Use git_buf in the git request
This is clearer and sidesteps the issue of what the return value of
snprintf is on the particular OS we're running on.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 00:41:08 +02:00
Vicent Martí
8114ee4c95 Merge pull request #405 from carlosmn/http-ls
Implement ls-remote over HTTP
2011-09-22 10:17:43 -07:00
Vicent Marti
87d9869fc3 Tabify everything
There were quite a few places were spaces were being used instead of
tabs. Try to catch them all. This should hopefully not break anything.
Except for `git blame`. Oh well.
2011-09-19 03:34:49 +03:00
Vicent Marti
bb742ede3d Cleanup legal data
1. The license header is technically not valid if it doesn't have a
copyright signature.

2. The COPYING file has been updated with the different licenses used in
the project.

3. The full GPLv2 header in each file annoys me.
2011-09-19 01:54:32 +03:00
Carlos Martín Nieto
db84b7988b Move extract_host_and_port to netops and add default port argument
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-04 16:07:52 +02:00
Carlos Martín Nieto
74bd343ae8 Fix Windows compilation
Sockets on Windows are unsigned, so define a type GIT_SOCKET which is
signed or unsigned depending on the platform.

Thanks to Em for his patience with this.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-30 19:37:14 +02:00
Vicent Marti
3ef7d06302 network: <select.h> is not available in MinGW 2011-08-30 13:10:47 +02:00
Vicent Martí
aa2f68d807 Merge pull request #378 from kiryl/Wuninitialized
Wuninitialized
2011-08-30 03:39:28 -07:00
Kirill A. Shutemov
932669b865 Drop STRLEN() macros
There is no need in STRLEN macros. Compilers can do this trivial
optimization on its own.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-08-25 16:41:15 +03:00
Kirill A. Shutemov
c75a890b60 transport_git: add missed error handling
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-08-24 20:11:15 +03:00
Carlos Martín Nieto
7adba5f49c Keep sending want lines if the server doesn't anwer a flush
Some servers take a long time to answer and expect us to keep sending
want lines; otherwise they close the connection. Avoid this by waiting
for one second for the server to answer. If the timeout runs out,
treat is as a NAK and keep sending want lines.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:10 +02:00
Carlos Martín Nieto
427ca3d3c5 Actually implement object negotiation
Only signal that we need a pack if we do need it and don't send a want
just because it's the first. If we don't need to download the pack,
then we can skip all of the negotiation and just return success.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:10 +02:00
Carlos Martín Nieto
22f65b9e73 Move negotiation to the transport
There are many ways how a transport might negotiate with the server,
so instead of making it fit into the smart protocol model, let the
transport do its thing. For now, the git protocol limits itself to
send only 160 "have" lines so we don't flood the server.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:10 +02:00
Carlos Martín Nieto
7284c1059f Don't try to download the packfile too early
Make sure we only try to download the pack if we find the pack header
in the stream, and not if the server takes a bit longer to send us the
last NAK.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
2f512ff81e Use strcpy+strcat as memcpy was overlapping
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
0437d991bf Use common capabilities
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
48a65a071d Only wait for pack if we need it
Provide the git_remote_download function to instruct the library to
downlad the packfile and let the user know the temporary location.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
9cf0f287bb Tell the user where the downloaded packfile is stored
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
da2902204b Download pack
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:07 +02:00
Carlos Martín Nieto
7e1a94db11 Move have sending
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:07 +02:00
Carlos Martín Nieto
b4c9063040 Implement sending haves
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:07 +02:00
Carlos Martín Nieto
0e20ba6066 Add a generic send_wants
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:07 +02:00
Vicent Marti
bdd18829ad Cleanup external API
Some of the WIP API calls have been hidden in preparation for the next
minor release.
2011-07-11 02:59:18 +02:00
Carlos Martín Nieto
39cdf27280 Fix network MSYS compilation
MSYS/MinGW uses winsock but obviously doesn't set _MSC_VER. Use _WIN32
to decide whether to use winsock or BSD headers. Also remove these
headers from src/transport_git.c altogether, as they are not needed.

MSYS is very conservative, so we have to tell it that we don't care
about versions of Windows lower than WindowsXP. We also need to tell
CMake to add ws2_32 to the libraries list and we shouldn't add the
-fPIC option, to MSYS because it complains that it does it anyway.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-06 12:48:23 +02:00
Carlos Martín Nieto
0ac2726fdf Slim down git_transport
Remove the unused repo and private pointers and make the direction a
flag, as it can only have two states. Change the connect signature to
use an int instead of git_net_direction and remove that enum.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 20:23:47 +02:00
Carlos Martín Nieto
5da5321d17 Initialize memory in git transport
At the same time, do mark the transport as connected.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 20:02:05 +02:00
Carlos Martín Nieto
c7c787ce0c Use gitno_buffer in the git transport
This allows us to leave out the buffer handling logic.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 02:09:49 +02:00
Carlos Martín Nieto
4e913309b9 Move transports to an inheritance model
Rather than an 'private' pointer, make the private structures inherit
from the generic git_transport struct. This way, we only have to worry
about one memory allocation instead of two. The structures are so
simple that this may even make the code use less memory overall.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:45 +02:00
Carlos Martín Nieto
fd6790210f Move git_pkt_{gen_proto,send_request} to transport_git.c
This is where they really belong. Remvoe the prefix and make them
static.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
c4d0fa85b1 Implement and use git_pkt_send_request
This makes it easier to send a requqest for an URL. It assumes there
is a socket where the string should go out to.

Make git_pkt_gen_proto accept a command parameter, which defaults to
git-upload-pack

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
4e95ef0268 Implement and use gitno_send 2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
1b4f814025 Create netops and start moving git:// to it
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
7632e2494a Correctly handle network input
Add a parameter to git_pkt_parse_line to tell it how much data you
have in your buffer. If the buffer is too short, it returns an error
saying so. Adapt the git transport to use this and fix the offset
calculation.

Add the GIT_ESHORTBUFFER error code.
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
be9fe679fc Implement and use git_pkt_free
A git_pkt object can be one of several structs. Add this function for
convenience and clarity.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:13 +02:00
Carlos Martín Nieto
ecb6ca0e1f Implement the git TCP transport up to ls-remote
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:13 +02:00