|
859ed5dd
|
2016-02-23T09:54:26
|
|
common: introduce GITERR_CHECK_ALLOC_BUF
We commonly have to check if a git_buf has been allocated
correctly or if we ran out of memory. Introduce a new macro
similar to `GITERR_CHECK_ALLOC` which checks if we ran OOM and if
so returns an error. Provide a `#nodef` for Coverity to mark the
error case as an abort path.
|
|
9447b9e5
|
2016-02-09T10:40:33
|
|
xplat: use st_mtimespec everywhere on mac
|
|
75a0ccf5
|
2015-11-12T19:53:09
|
|
Merge pull request #3170 from CmdrMoozy/nsec_fix
git_index_entry__init_from_stat: set nsec fields in entry stats
|
|
4bc9b74c
|
2015-09-28T16:24:50
|
|
GITERR_CHECK_ALLOC_ADDn: multi-arg adders
|
|
360dd4da
|
2015-06-23T10:02:48
|
|
win32: define our own POSIX struct stat, and support USE_NSEC
|
|
ef4857c2
|
2015-08-03T16:50:27
|
|
errors: tighten up git_error_state OOMs a bit more
When an error state is an OOM, make sure that we treat is specially
and do not try to free it.
|
|
93b42728
|
2015-06-09T14:38:30
|
|
Include stacktrace summary in memory leak output.
|
|
7dd22538
|
2015-05-11T10:19:25
|
|
centralizing all IO buffer size values
|
|
45df2237
|
2015-02-27T10:53:39
|
|
Include ws2tcpip.h in order to get in6_addr
It's currently required in src/openssl_stream.c only.
|
|
16942c6f
|
2015-02-12T17:36:48
|
|
integer overflow: use compiler intrinsics if supported
gcc and clang support __builtin_add_overflow, use it whenever
possible, falling back to our naive routines.
|
|
f1453c59
|
2015-02-12T12:19:37
|
|
Make our overflow check look more like gcc/clang's
Make our overflow checking look more like gcc and clang's, so that
we can substitute it out with the compiler instrinsics on platforms
that support it. This means dropping the ability to pass `NULL` as
an out parameter.
As a result, the macros also get updated to reflect this as well.
|
|
190b76a6
|
2015-02-11T14:52:08
|
|
Introduce git__add_sizet_overflow and friends
Add some helper functions to check for overflow in a type-specific
manner.
|
|
2884cc42
|
2015-02-11T09:39:38
|
|
overflow checking: don't make callers set oom
Have the ALLOC_OVERFLOW testing macros also simply set_oom in the
case where a computation would overflow, so that callers don't
need to.
|
|
392702ee
|
2015-02-09T23:41:13
|
|
allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic
and set error message appropriately.
|
|
710f66af
|
2015-02-03T18:41:15
|
|
bswap: remove unused bswap
|
|
b874629b
|
2014-12-04T21:06:59
|
|
Spelling fixes
|
|
702efc89
|
2014-04-30T10:57:42
|
|
Make init_options fns use unsigned ints and macro
Use an unsigned int for the version and add a helper macro so the
code is simplified (and so the error message is a common string).
|
|
6b05240c
|
2014-04-27T19:44:20
|
|
strcasecmp is in <strings.h>
|
|
8a2834d3
|
2014-03-14T13:20:51
|
|
Index locking and entry allocation changes
This makes the lock management on the index a little bit broader,
having a number of routines hold the lock across looking up the
item to be modified and actually making the modification. Still
not true thread safety, but more pure index modifications are now
safe which allows the simple cases (such as starting up a diff
while index modifications are underway) safe enough to get the
snapshot without hitting allocation problems.
As part of this, I simplified the allocation of index entries to
use a flex array and just put the path at the end of the index
entry. This makes every entry self-contained and makes it a
little easier to feel sure that pointers to strings aren't
being accidentally copied and freed while other references are
still being held.
|
|
72556cc6
|
2014-02-20T14:27:10
|
|
Address PR comments
* Make GIT_INLINE an internal definition so it cannot be used in
public headers
* Fix language in CONTRIBUTING
* Make index caps API use signed instead of unsigned values
|
|
26c1cb91
|
2013-12-09T09:44:03
|
|
One more rename/cleanup for callback err functions
|
|
60058018
|
2013-12-06T15:20:41
|
|
Fix C99 __func__ for MSVC
|
|
25e0b157
|
2013-12-06T15:07:57
|
|
Remove converting user error to GIT_EUSER
This changes the behavior of callbacks so that the callback error
code is not converted into GIT_EUSER and instead we propagate the
return value through to the caller. Instead of using the
giterr_capture and giterr_restore functions, we now rely on all
functions to pass back the return value from a callback.
To avoid having a return value with no error message, the user
can call the public giterr_set_str or some such function to set
an error message. There is a new helper 'giterr_set_callback'
that functions can invoke after making a callback which ensures
that some error message was set in case the callback did not set
one.
In places where the sign of the callback return value is
meaningful (e.g. positive to skip, negative to abort), only the
negative values are returned back to the caller, obviously, since
the other values allow for continuing the loop.
The hardest parts of this were in the checkout code where positive
return values were overloaded as meaningful values for checkout.
I fixed this by adding an output parameter to many of the internal
checkout functions and removing the overload. This added some
code, but it is probably a better implementation.
There is some funkiness in the network code where user provided
callbacks could be returning a positive or a negative value and
we want to rely on that to cancel the loop. There are still a
couple places where an user error might get turned into GIT_EUSER
there, I think, though none exercised by the tests.
|
|
96869a4e
|
2013-12-03T16:45:39
|
|
Improve GIT_EUSER handling
This adds giterr_user_cancel to return GIT_EUSER and clear any
error message that is sitting around. As a result of using that
in places, we need to be more thorough with capturing errors that
happen inside a callback when used internally. To help with that,
this also adds giterr_capture and giterr_restore so that when we
internally use a foreach-type function that clears errors and
converts them to GIT_EUSER, it is easier to restore not just the
return value, but the actual error message text.
|
|
5588f073
|
2013-12-09T10:25:36
|
|
Clean up warnings
|
|
c2408a69
|
2013-11-01T17:03:01
|
|
preserve windows error numbers as well
|
|
5c5eeba6
|
2013-03-31T22:22:33
|
|
Add git_has_win32_version helper
|
|
5540d947
|
2013-03-15T16:39:00
|
|
Implement global/system file search paths
The goal of this work is to expose the search logic for "global",
"system", and "xdg" files through the git_libgit2_opts() interface.
Behind the scenes, I changed the logic for finding files to have a
notion of a git_strarray that represents a search path and to store
a separate search path for each of the three tiers of config file.
For each tier, I implemented a function to initialize it to default
values (generally based on environment variables), and then general
interfaces to get it, set it, reset it, and prepend new directories
to it.
Next, I exposed these interfaces through the git_libgit2_opts
interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants
for the user to control which search path they were modifying.
There are alternative designs for the opts interface / argument
ordering, so I'm putting this phase out for discussion.
Additionally, I ended up doing a little bit of clean up regarding
attr.h and attr_file.h, adding a new attrcache.h so the other two
files wouldn't have to be included in so many places.
|
|
f443a72d
|
2013-02-28T14:41:26
|
|
Fix some deprecation warnings on Windows
This fixes some snprintf and vsnprintf related deprecation
warnings we've been having on Windows with recent compilers.
|
|
97b71374
|
2013-02-28T14:14:45
|
|
Add GIT_STDLIB_CALL
This removes the one-off GIT_CDECL and adds a new standard way of
doing this named GIT_STDLIB_CALL with a src/win32 specific def
when on the Windows platform.
|
|
c70455c7
|
2013-02-01T22:53:51
|
|
Deduplicate FormatMessage UTF-16 to UTF-8 conversion code
Signed-off-by: Sven Strickroth <email@cs-ware.de>
|
|
359fc2d2
|
2013-01-08T17:07:25
|
|
update copyrights
|
|
bf192cdb
|
2012-12-05T20:56:27
|
|
versions: MSVC build fixes
|
|
43efaabd
|
2012-12-05T20:54:03
|
|
common: Silly vmg.
|
|
8ff66112
|
2012-12-05T20:50:19
|
|
common: Silly MSVC
|
|
e05ca13f
|
2012-12-05T11:47:19
|
|
Merge pull request #1115 from ben/struct-versions
Version info for public structs
|
|
ee1c33b1
|
2012-12-03T12:45:15
|
|
Don't unconstify when casting
|
|
cc146626
|
2012-11-19T19:00:46
|
|
revparse: Deploy EINVALIDSPEC usage
|
|
0ab3a2ab
|
2012-11-30T20:34:50
|
|
Deploy GIT_INIT_STRUCTURE
|
|
c7231c45
|
2012-11-30T16:31:42
|
|
Deploy GITERR_CHECK_VERSION
|
|
41fb1ca0
|
2012-10-29T13:41:14
|
|
Reorganize transport architecture (squashed 3)
|
|
1a628100
|
2012-09-21T15:04:39
|
|
Make giterr_set_str public
There has been discussion for a while about making some set of
the `giterr_set` type functions part of the public API for code
that is implementing new backends to libgit2. This makes the
`giterr_set_str()` and `giterr_set_oom()` functions public.
|
|
64d01de8
|
2012-07-24T14:23:16
|
|
remote: start moving the protocol to a common area
For the transition, http is going to keep its own logic until the
git/common code catches up with the implied multi_ack that http
has. This also has the side-effect of making the code cleaner and more
correct regardingt he protocol.
|
|
6fc0bdc5
|
2012-07-17T10:52:16
|
|
Remove old error handling code
|
|
ac8eac2f
|
2012-06-15T11:25:52
|
|
Fix compile errors when building on windows
Errors were due to not including winsock2 early enough.
|
|
d3e1367f
|
2012-05-17T21:40:20
|
|
ssl: remove GnuTLS support
It's too much work for now to redo everything.
Move the ssl context struct to transport.h
|
|
66024c7c
|
2012-05-01T00:05:25
|
|
http: add https support when GnuTLS is available
If it's not available, an error saying so will be returned when trying
to use a https:// URL.
This also unifies a lot of the network code to use git_transport in
many places instead of an socket descriptor.
|
|
a6f24a5b
|
2012-05-01T01:50:26
|
|
https: make it work with OpenSSL as well
Add specific functions that use OpenSSL instead of GnuTLS
|
|
dda708e7
|
2012-03-09T19:55:50
|
|
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!
|
|
5e0de328
|
2012-02-13T17:10:24
|
|
Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
|
|
a53420e4
|
2012-01-26T17:53:46
|
|
msvc: Move `ssize_t` typedef to MSVC-only
This is a MSVC-only issue. All other compilers we support work properly.
|
|
9462c471
|
2011-11-25T08:16:26
|
|
repository: Change ownership semantics
The ownership semantics have been changed all over the library to be
consistent. There are no more "borrowed" or duplicated references.
Main changes:
- `git_repository_open2` and `3` have been dropped.
- Added setters and getters to hotswap all the repository owned
objects:
`git_repository_index`
`git_repository_set_index`
`git_repository_odb`
`git_repository_set_odb`
`git_repository_config`
`git_repository_set_config`
`git_repository_workdir`
`git_repository_set_workdir`
Now working directories/index files/ODBs and so on can be
hot-swapped after creating a repository and between operations.
- All these objects now have proper ownership semantics with
refcounting: they all require freeing after they are no longer
needed (the repository always keeps its internal reference).
- Repository open and initialization has been updated to keep in
mind the configuration files. Bare repositories are now always
detected, and a default config file is created on init.
- All the tests affected by these changes have been dropped from the
old test suite and ported to the new one.
|
|
a15c550d
|
2011-11-16T14:09:44
|
|
threads: Fix the shared global state with TLS
See `global.c` for a description of what we're doing.
When libgit2 is built with GIT_THREADS support, the threading system
must be explicitly initialized with `git_threads_init()`.
|
|
c060854e
|
2011-10-04T21:11:51
|
|
msvc: Properly handle inttypes.h/stdint.h
|
|
a8076074
|
2011-09-18T20:00:19
|
|
Merge pull request #397 from lambourg/development
Fix compilation issues with mingw64 headers
|
|
87d9869f
|
2011-09-19T03:34:49
|
|
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.
|
|
bb742ede
|
2011-09-19T01:54:32
|
|
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.
|
|
22c30464
|
2011-09-12T11:06:54
|
|
Fix compilation issues with ming64 headers
|
|
d7f0abab
|
2011-08-24T20:10:50
|
|
Fix false positive -Wuninitialized warnings
GCC produces several -Wuninitialized warnings. Most of them can be fixed
if we make visible for gcc that git__throw() and git__rethrow() always
return first argument.
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
|
|
678e9e04
|
2011-07-03T13:33:43
|
|
build: Move OS-specific compat to their own folders
|
|
b2cef77c
|
2011-06-30T21:29:42
|
|
common: Force 64 bit fileops at compile time
|
|
ef9a6f4c
|
2011-06-15T13:47:41
|
|
Merge pull request #261 from Romain-Geissler/discovery-path-v2
Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
|
|
0657e46d
|
2011-06-15T12:36:08
|
|
Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
GIT_PATH_LIST_SEPARATOR and GIT_PATH_MAX are made public so
that it's can be used by a client.
|
|
2e18e29b
|
2011-06-14T16:35:57
|
|
Remove uneeded arpa/inet.h include
This header isn't needed at all and it shows a lot of warnings on
OpenBSD.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
|
|
ee4912bf
|
2011-06-07T11:15:23
|
|
Revert "common: Include stat.h in include/git2/common.h instead of src/common.h"
This reverts commit df1c98ab6d6171ed63729195bd190b54b67fe530.
As 8a27b6b reverts the exposition of struct stat to the external API, we
do not need - indeed, do not want - struct stat to be in the outer
include layer.
|
|
cbf4f9f4
|
2011-05-25T16:31:14
|
|
common: Include stat.h in include/git2/common.h instead of src/common.h
00582bcb introduced a change to git_blob_create_fromfile() that required
the caller to pass a stat struct. This means that we need to include
stat.h higher in the hierarchy of includes.
|
|
6810bf28
|
2011-05-11T00:40:07
|
|
Move all error-related defines to `git2/errors.h`
|
|
3f53c971
|
2011-05-05T01:20:27
|
|
errors: Set error messages on memory allocation
|
|
fa59f18d
|
2011-05-09T20:54:04
|
|
Change error handling mechanism once again
Ok, this is the real deal. Hopefully. Here's how it's going to work:
- One main method, called `git__throw`, that sets the error
code and error message when an error happens.
This method must be called in every single place where an error
code was being returned previously, setting an error message
instead.
Example, instead of:
return GIT_EOBJCORRUPTED;
Use:
return git__throw(GIT_EOBJCORRUPTED,
"The object is missing a finalizing line feed");
And instead of:
[...] {
error = GIT_EOBJCORRUPTED;
goto cleanup;
}
Use:
[...] {
error = git__throw(GIT_EOBJCORRUPTED, "What an error!");
goto cleanup;
}
The **only** exception to this are the allocation methods, which
return NULL on failure but already set the message manually.
/* only place where an error code can be returned directly,
because the error message has already been set by the wrapper */
if (foo == NULL)
return GIT_ENOMEM;
- One secondary method, called `git__rethrow`, which can be used to
fine-grain an error message and build an error stack.
Example, instead of:
if ((error = foobar(baz)) < GIT_SUCCESS)
return error;
You can now do:
if ((error = foobar(baz)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to do a major operation");
The return of the `git_lasterror` method will be a string in the
shape of:
"Failed to do a major operation. (Failed to do an internal
operation)"
E.g.
"Failed to open the index. (Not enough permissions to access
'/path/to/index')."
NOTE: do not abuse this method. Try to write all `git__throw`
messages in a descriptive manner, to avoid having to rethrow them to
clarify their meaning.
This method should only be used in the places where the original
error message set by a subroutine is not specific enough.
It is encouraged to continue using this style as much possible to
enforce error propagation:
if ((error = foobar(baz)) < GIT_SUCCESS)
return error; /* `foobar` has set an error message, and
we are just propagating it */
The error handling revamp will take place in two phases:
- Phase 1: Replace all pieces of code that return direct error codes
with calls to `git__throw`. This can be done semi-automatically
using `ack` to locate all the error codes that must be replaced.
- Phase 2: Add some `git__rethrow` calls in those cases where the
original error messages are not specific enough.
Phase 1 is the main goal. A minor libgit2 release will be shipped once
Phase 1 is ready, and the work will start on gradually improving the
error handling mechanism by refining specific error messages.
OTHER NOTES:
- When writing error messages, please refrain from using weasel
words. They add verbosity to the message without giving any real
information. (<3 Emeric)
E.g.
"The reference file appears to be missing a carriage return"
Nope.
"The reference file is missing a carriage return"
Yes.
- When calling `git__throw`, please try to use more generic error
codes so we can eventually reduce the list of error codes to
something more reasonable. Feel free to add new, more generic error
codes if these are going to replace several of the old ones.
E.g.
return GIT_EREFCORRUPTED;
Can be turned into:
return git__throw(GIT_EOBJCORRUPTED,
"The reference is corrupted");
|
|
02f9e637
|
2011-05-05T01:12:17
|
|
errors: Add error handling function
|
|
bb3de0c4
|
2011-03-16T21:35:51
|
|
Thread safe cache
|
|
bbcc7ffc
|
2011-03-15T21:04:41
|
|
Add proper threading support to libgit2
We now depend on libpthread on all Unix platforms (should be installed
by default) and use a simple wrapper for Windows threads under Win32.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
86194b24
|
2011-02-18T21:57:53
|
|
Split packed from unpacked references
These two reference types are now stored separately to eventually allow
the removal/renaming of loose references and rewriting of the refs
packfile.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
aa2120e9
|
2011-02-10T15:08:00
|
|
Added git_reference__normalize_name() along with tests.
|
|
e52e38d3
|
2011-01-12T01:42:07
|
|
Move the compat definitions to types.h
Don't need a brand new header for two typedefs when we already have a
types.h header.
Change comment style to ANSI C.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
f0bde7fa
|
2011-01-11T16:07:45
|
|
Revised platform types to use 'best supported' size.
This will allow graceful migration to 64 bit file sizes and timestamps should
git's binary interface be extended to allow this.
|
|
9f54fe48
|
2010-12-23T00:15:09
|
|
Remove git_errno
It was not being used by any methods (only by malloc and calloc), and
since it needs to be TLS, it cannot be exported on DLLs on Windows.
Burn it with fire. The API always returns error codes!
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
44908fe7
|
2010-12-06T23:03:16
|
|
Change the library include file
Libgit2 is now officially include as
#include "<git2.h>"
or indidividual files may be included as
#include <git2/index.h>
Signed-off-by: Vicent Marti <tanoku@gmail.com>
|
|
fb799dfe
|
2010-04-23T09:59:22
|
|
Merge remote branch 'ramsay/dev'
* ramsay/dev:
Add a pack index 'virtual function' to fetch an index entry
Add a pack index 'virtual function' to search by file offset
Change the interface of the pack index search function
Add an 64-bit offset table index bounds check for v2 pack index
Add a minimum size check when opening an v2 pack index file
win32: Add separate MinGW and MSVC compatability header files
Makefile: Add support for custom build options in config.mak file
Fix some coding style issues
|
|
5dddf7c8
|
2010-04-14T20:41:57
|
|
Add block-sha1 in favour of the mozilla routines
Since block-sha1 from git.git has such excellent performance, we
can also get rid of the openssl dependency. It's rather simple
to add it back later as an optional extra, but we really needn't
bother to pull in the entire ssl library and have to deal with
linking issues now that we have the portable and, performance-wise,
truly excellent block-sha1 code to fall back on.
Since this requires a slight revamp of the build rules anyway, we
take the opportunity to fix including EXTRA_OBJS in the final build
as well.
The block-sha1 code was originally implemented for git.git by
Linus Torvalds <torvalds@linux-foundation.org> and was later
polished by Nicolas Pitre <nico@cam.org>.
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
e8cc449f
|
2010-02-19T21:49:22
|
|
win32: Add separate MinGW and MSVC compatability header files
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
90d4d2f0
|
2010-01-11T19:27:50
|
|
win32: Use an 64-bit file offset type
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
a1c0728d
|
2009-12-21T15:54:50
|
|
Add support for the MinGW platform
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
cfe3a027
|
2010-01-15T22:07:44
|
|
Use a 64 bit off_t throughout the library and tests on POSIX
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
04e88240
|
2009-06-17T22:21:10
|
|
win32: Define the ssize_t type using SSIZE_T if supported
Some win32 compilers define the SSIZE_T type, with the same
meaning and intent as ssize_t. If available, make ssize_t a
synonym of SSIZE_T.
At present, the Digital-Mars compiler is known not to define
SSIZE_T, so we provide an SSIZE_T macro to use in the typedef.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
8a086f87
|
2009-06-14T22:12:20
|
|
win32: Add support for the MS Visual C/C++ compiler
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
502acd16
|
2009-03-23T18:37:51
|
|
win32: Add missing include for mkdir() and rmdir()
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
79ca2edc
|
2009-03-20T19:51:48
|
|
win32: Add routines to abstract memory-mapped file functions
In particular, the git__mmap() and git__munmap() routines provide
the interface to platform specific memory-mapped file facilities.
We provide implementations for unix and win32, which can be found
in their own sub-directories.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
840fb8b7
|
2009-02-18T18:53:48
|
|
win32: fixup some headers to improve win32 compilation
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
3a33c7b3
|
2009-01-02T20:51:47
|
|
Fix snprintf compiler warning on cygwin
As far as gcc is concerned, the "z size specifier" is available as
an extension to the language, which is available with or without any
-std= switch. (I think you have to go back to 2.95 for a version
of gcc which doesn't work.) Many other compilers have this as an
extension as well (ie without the equivalent of -std=c99).
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
2c4b7707
|
2008-12-31T16:06:48
|
|
Add git__fmt as an easier to use snprintf
Checking the return value of snprintf is a pain, as it must be
>= 0 and < sizeof(buffer). git__fmt is a simple wrapper to
perform these checks.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
028ef0de
|
2008-12-31T13:20:21
|
|
Add a mutex and atomic counter abstraction and implementations
These abstractions can be used to implement an efficient resource
reference counter and simple mutual exclusion. On pthreads we use
pthread_mutex_t, except when we are also on glibc and can directly
use its asm/atomic.h definitions.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
d44cfd46
|
2008-12-31T13:16:31
|
|
Cleanup our header inclusion order to ensure pthread.h is early
If we are using threads we need to make sure pthread.h comes
in before just about anything else. Some platforms enable
macros that alter what other headers define.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
64a47c01
|
2008-12-30T23:21:36
|
|
Wrap malloc and friends and report out of memory as GIT_ENOMEM
We now forbid direct use of malloc, strdup or calloc within the
library and instead use wrapper functions git__malloc, etc. to
invoke the underlying library malloc and set git_errno to a no
memory error code if the allocation fails.
In the future once we have pack objects in memory we are likely
to enhance these routines with garbage collection logic to purge
cached pack data when allocations fail. Because the size of the
function will grow somewhat large, we don't want to mark them for
inline as gcc tends to aggressively inline, creating larger than
expected executables.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
064301cc
|
2008-12-30T22:07:56
|
|
Fix size_t snprintf warning by using PRIuPTR format macro
This is the correct C99 format code for the size_t type when passed
as an argument to the *printf family. If the platform doesn't
define it, we assume %lu and just cross our fingers that its the
proper setting for a size_t on this system. On most sane platforms,
"unsigned long" is the underlying type of "size_t".
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
a1d34bc0
|
2008-12-30T21:49:38
|
|
Support building on Mac OS X by using pthread_getspecific for TLS
The Mach-O format does not permit gcc to implement the __thread
TLS specification, so we must instead emulate it using a single
int cell allocated from memory and stored inside of the thread
specific data associated with the current pthread.
What makes this tricky is git_errno must be a valid lvalue, so
we really need to return a pointer to the caller and deference it
as part of the git_errno macro.
The GCC-specific __attribute__((constructor)) extension is used
to ensure the pthread_key_t is allocated before any Git functions
are executed in the library, as this is necessary to access our
thread specific storage.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
b3039bee
|
2008-12-30T21:25:13
|
|
Cleanup formatting in our head files to be more consistent
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
75d58430
|
2008-12-18T22:56:14
|
|
Add a file reading routine along with an io buffer type
In particular, the gitfo_read_file() routine can be used to slurp
the complete file contents into an gitfo_buf structure. The buffer
content will be allocated by malloc() and may be released by the
gitfo_free_buf() routine. The io buffer type can be initialised
on the stack with the GITFO_BUF_INIT macro.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
5ee2fe77
|
2008-12-03T23:53:55
|
|
Add a GIT_PATH_MAX constant
The PATH_MAX symbol is often, but not always, defined
in the <limits.h> header. In particular, on cygwin you
need to include this header to avoid a compilation error.
However, some systems define PATH_MAX to be something as
small as 256, which POSIX is happy to allow, while others
allow much larger values. In general it can vary from
one filesystem to another.
In order to avoid the vagaries of different systems, define
our own symbol.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
76a8c447
|
2008-11-22T14:42:12
|
|
Add internal common.h file
This one pulls in compiler compatibility macros, some
common header files, and also the public common.h header.
C source files are modified to use the private common.h
in favour of the public one.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|