Commit Graph

24 Commits

Author SHA1 Message Date
Carlos Martín Nieto
f7310540ae indexer: use mmap for writing
Some OSs cannot keep their ideas about file content straight when mixing
standard IO with file mapping. As we use mmap for reading from the
packfile, let's make writing to the pack file use mmap.
2014-05-17 01:39:43 +02:00
Vicent Marti
6a1ca96e41 Temporary fix for Travis CI builds
See https://github.com/libgit2/libgit2/pull/2321#issuecomment-42039673
We may rollback once we found something more reliable
2014-05-02 17:14:33 +02:00
brian m. carlson
0197d4107a
Check for EWOULDBLOCK as well as EAGAIN on write.
On some systems, notably HP PA-RISC systems running Linux or HP-UX,
EWOULDBLOCK and EAGAIN are not the same value.  POSIX (and these OSes) allow
EWOULDBLOCK to occur on write(2) (and send(2), etc.), so check explicitly
for this case as well as EAGAIN by defining and using a macro GIT_ISBLOCKED
that considers both.

The macro is necessary because MSYS does not provide EWOULDBLOCK and
compilation fails if an attempt is made to use it unconditionally.  On most
systems, where the two values are the same, the compiler will simply
optimize this check out and it will have no effect.
2014-02-16 16:56:37 +00:00
Russell Belfer
7697e54176 Test cancel from indexer progress callback
This adds tests that try canceling an indexer operation from
within the progress callback.

After writing the tests, I wanted to run this under valgrind and
had a number of errors in that situation because mmap wasn't
working.  I added a CMake option to force emulation of mmap and
consolidated the Amiga-specific code into that new place (so we
don't actually need separate Amiga code now, just have to turn on
-DNO_MMAP).

Additionally, I made the indexer code propagate error codes more
reliably than it used to.
2013-12-11 15:02:20 -08:00
Russell Belfer
3d3ea4dc56 Add O_CLOEXEC to open calls 2013-06-22 20:58:32 -07:00
Russell Belfer
71d62d3905 Fix memory leak in p_getaddrinfo on Amiga
If gethostbyname() fails on platforms with NO_ADDRINFO, the code
leaks the struct addrinfo that was allocated.  This fixes that
(and a number of code formatting issues in that area of code in
src/posix.c).
2013-02-15 16:01:31 -08:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Eduardo Bart
345eef2374 Move inet_pton to posix platform-compatibility layer 2012-11-07 16:15:09 -02:00
Vicent Marti
798e4d53dc amigaos: Cleanup 2012-06-22 21:25:17 +02:00
Russell Belfer
19579847f6 Clean up warnings and tests 2012-05-08 13:23:00 -07:00
nulltoken
3191ae89c6 compat: make p_open able to accept optional mode when passing the O_CREAT flag
This has the nice side effect of making test_attr_repo__staging_properly_normalizes_line_endings_according_to_gitattributes_directives() test pass again on Windows. This test started to fail after commit 674a198 was applied.
2012-05-07 12:18:54 +02:00
Russell Belfer
44ef8b1b30 Fix warnings on 64-bit windows builds
This fixes all the warnings on win64 except those in deps, which
come from the regex code.
2012-04-17 10:47:39 -07:00
Russell Belfer
deafee7bd7 Continue error conversion
This converts blob.c, fileops.c, and all of the win32 files.
Also, various minor cleanups throughout the code.  Plus, in
testing the win32 build, I cleaned up a bunch (although not
all) of the warnings with the 64-bit build.
2012-03-14 17:36:15 -07:00
Vicent Martí
dda708e78f error-handling: On-disk config file backend
Includes:

	- Proper error reporting when encountering syntax errors in a
	config file (file, line number, column).

	- Rewritten `config_write`, now with 99% less goto-spaghetti

	- Error state in `git_filebuf`: filebuf write functions no longer
	need to be checked for error returns. If any of the writes performed
	on a buffer fail, the last call to `git_filebuf_commit` or
	`git_filebuf_hash` will fail accordingly and set the appropiate error
	message. Baller!
2012-03-09 20:09:22 +01:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Russell Belfer
97769280ba Use git_buf for path storage instead of stack-based buffers
This converts virtually all of the places that allocate GIT_PATH_MAX
buffers on the stack for manipulating paths to use git_buf objects
instead.  The patch is pretty careful not to touch the public API
for libgit2, so there are a few places that still use GIT_PATH_MAX.

This extends and changes some details of the git_buf implementation
to add a couple of extra functions and to make error handling easier.

This includes serious alterations to all the path.c functions, and
several of the fileops.c ones, too.  Also, there are a number of new
functions that parallel existing ones except that use a git_buf
instead of a stack-based buffer (such as git_config_find_global_r
that exists alongsize git_config_find_global).

This also modifies the win32 version of p_realpath to allocate whatever
buffer size is needed to accommodate the realpath instead of hardcoding
a GIT_PATH_MAX limit, but that change needs to be tested still.
2011-12-07 23:08:15 -08:00
Carlos Martín Nieto
0c49ec2d3b Implement p_rename
Move the callers of git_futils_mv_atomic to use p_rename.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-07 20:34:27 +01:00
Brodie Rao
33127043b3 fileops/posix: replace usage of "int mode" with "mode_t mode"
Note: Functions exported from fileops take const mode_t, while the
underlying POSIX wrappers take mode_t.
2011-10-14 15:57:15 -07:00
Vicent Marti
01d7fded1b Revert "Rewrite getenv to use Win32 version on Windows"
This reverts commit e1b8644467.
2011-09-27 14:33:18 +02:00
Paul Betts
e1b8644467 Rewrite getenv to use Win32 version on Windows 2011-09-21 12:00:34 -07:00
Paul Betts
7998ae5ab1 Rewrite p_* functions to use Unicode and marshal to UTF8 internally 2011-09-19 13:14:04 -07: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
Kirill A. Shutemov
2ba222c5c5 posix: declare 'buf' argument of p_write() as const
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-25 21:12:46 +02:00
Vicent Marti
f79026b491 fileops: Cleanup
Cleaned up the structure of the whole OS-abstraction layer.

fileops.c now contains a set of utility methods for file management used
by the library. These are abstractions on top of the original POSIX
calls.

There's a new file called `posix.c` that contains
emulations/reimplementations of all the POSIX calls the library uses.
These are prefixed with `p_`. There's a specific posix file for each
platform (win32 and unix).

All the path-related methods have been moved from `utils.c` to `path.c`
and have their own prefix.
2011-07-05 02:04:03 +02:00