|
e272b103
|
2010-04-26T20:10:44
|
|
MSVC: Fix some compiler warnings
In particular, using the normal (or production) compiler
warning level (-W3), msvc complains as follows:
.../sha1.c(244) : warning C4018: '<' : signed/unsigned mismatch
.../sha1.c(270) : warning C4244: 'function' : conversion from \
'unsigned __int64' to 'unsigned long', possible loss of data
.../sha1.c(271) : warning C4244: 'function' : conversion from \
'unsigned __int64' to 'unsigned long', possible loss of data
Note that gcc issues a similar complaint about line 244 when
compiling with -Wextra.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
e2337f39
|
2010-04-25T21:55:41
|
|
MSVC: Fix a syntax error caused by an inline function definition
Commit 5dddf7c (Add block-sha1 in favour of the mozilla routines
2010-04-14) introduced the "bswap.h" header file which contains
an inline function (default_swab32()). The msvc compiler does
not support the inline keyword which causes the build to fail
with a syntax error.
However, msvc does support inline functions using the __inline
keyword language extension. We already have the GIT_INLINE()
macro that allows us to hide this syntatic difference. In order
to fix the build, we simply use GIT_INLINE() in the definition
of the default_swab32() function.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
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>
|
|
d15e94c0
|
2010-04-14T20:23:36
|
|
Add assembly sha1 implementation for ppc
We don't use it yet, but now we have it there at least.
All the non-trivial parts of it appears to have been written
and contributed to git.git by some anonymous genius. The original
implementation was done by Paul Mackerras <paulus@samba.org>.
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
2cdc4544
|
2010-02-26T22:53:10
|
|
Add a pack index 'virtual function' to fetch an index entry
Given an index entry number, the idx_get() function returns an
(version agnostic) index_entry structure containing all of the
information required to unpack the corresponding object from
the '.pack' file.
Since the v1 and v2 file formats differ in the layout of the
object records, we provide two implementations of the get
function and initialise the function pointer appropriately.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
608d33fa
|
2010-02-26T19:59:06
|
|
Add a pack index 'virtual function' to search by file offset
In addition to searching the index by oid, we need to search by
'.pack' file offset, particularly when processing OBJ_OFS_DELTA
objects. Since the v1 and v2 file formats differ in the layout
of the object records, we provide two implementations of the
search function and initialise the (virtual) function pointer
appropriately.
Note that, as part of the creation of the 'offset index', we also
add a check that the offset data in the index is within the bounds
of the '.pack' file. Having sorted the file offsets, while creating
the index, we only need to check the smallest and largest values.
The offset index consists of the im_off_idx array, which contains
the index entry numbers sorted into file offset order, and the
im_off_next mapping array. The im_off_next array maps an index
entry number to the 'next' index entry in file offset order.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
abf5681c
|
2010-02-26T19:29:54
|
|
Change the interface of the pack index search function
In particular, on a successful search, we now return the index
entry number of the object rather than the '.pack' file offset.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
238e54bc
|
2010-02-21T15:34:53
|
|
Add an 64-bit offset table index bounds check for v2 pack index
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
255a0dab
|
2010-02-19T22:36:31
|
|
Add a minimum size check when opening an v2 pack index file
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
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>
|
|
1e5dd572
|
2010-02-12T16:50:33
|
|
Fix some coding style issues
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
73dcf287
|
2010-01-12T16:39:25
|
|
msvc: Fix some "unreferenced formal parameter" warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
e8a95256
|
2010-01-04T18:57:13
|
|
msvc: Fix some -W4 warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
1a7bae4d
|
2010-01-11T22:51:42
|
|
Fix some "unused parameter" warnings with -Wextra
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
e3fe32b6
|
2010-01-11T21:11:55
|
|
Fix "'__thread' not at start of declaration" warnings (-Wextra)
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
0ef9d2aa
|
2010-01-03T22:56:54
|
|
Fix some "signed v unsigned comparison" warnings with -Wextra
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
a4f863af
|
2010-01-03T19:37:04
|
|
Fix an always false comparison "unsigned < 0" warning
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
803a6b4d
|
2010-01-03T19:12:05
|
|
Save the git_file in the gitfo_cache when enabling caching
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
e97179b6
|
2010-01-13T20:01:11
|
|
win32: Add a 'git__' prefix to the directory reading routines
This reduces the global namespace pollution and allows for
a win32 compiler (eg. Open Watcom) to provide these routines
in a header other than <dirent.h> (eg in <io.h>).
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>
|
|
960ca1d7
|
2009-08-28T21:22:46
|
|
Add the git_oid_to_string() utility function
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>
|
|
5cae6c25
|
2009-06-17T15:54:59
|
|
Disable some msvc "deprecated function" warnings again
In addition to removing the inline #define, commit 209849a also
removed a #pragma to disable msvc deprecated function warnings.
Without this #pragma, msvc currently issues 19 warnings related
to "deprecated insecure c-library functions", such as strcpy()
and 22 warnings related to "deprecated POSIX function names",
such as open().
In order to supress these warnings, re-instate the #pragma.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
209849a4
|
2009-06-15T21:27:49
|
|
Use GIT_INLINE macro instead of keyword inline.
No need to define inline as __inline because libgit2 code
should be using GIT_INLINE instead.
Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
c79dded3
|
2009-06-14T22:13:35
|
|
win32: Add an fsync() implementation for windows
For information on FlushFileBuffers(), see the msdn document
at msdn.microsoft.com/en-us/library/aa364439(VS.85).aspx
Note that Windows 2000 is shown as the minimum windows version
to support FlushFileBuffers(), so if we wish to support Win9X
and NT4, we will need to add code to dynamically check if
kernel32.dll contains the function.
The only error return mentioned in the msdn document is
ERROR_INVALID_HANDLE, which is returned if the file/device
(eg console) is not buffered. The fsync(2) manpage says that
EINVAL is returned in errno, if "fd is bound to a special
file which does not support synchronization".
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>
|
|
2bf93fa1
|
2009-06-14T22:10:23
|
|
Correct the spelling of the FLEX_ARRAY macro
When setting the default value, the macro name was specified
as GIT_FLEX_ARRAY, which is inconsistent with it's earlier
usage in the file. This caused a compilation error, using the
MS Visual C/C++ compiler, when compiling the git_packlist
struct definition in src/odb.c.
In addition to changing the spelling of the FLEX_ARRAY macro
to GIT_FLEX_ARRAY, including it's use in src/odb.c, we also
rename the TYPEOF macro to GIT_TYPEOF.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
|
|
10aa3fa7
|
2009-06-04T17:14:35
|
|
Fix some "signed/unsigned mismatch" (msvc) compiler warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
4c9a3973
|
2009-06-04T17:13:49
|
|
Improve the portability of the gitfo_cache code (to 64-bit systems)
This supresses some "conversion from 'size_t' to 'unsigned int',
possible loss of data" warning messages from the MS Visual C/C++
compiler with -Wp64.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
3e0fb8fb
|
2009-06-04T17:12:59
|
|
thread-utils.h: Avoid using a non-standard C construct
In particular, in standard C, a struct or union must have at
least one member declared (ie. structs and unions cannot be
empty). Some compilers allow empty structs as an extension
and won't even issue a warning unless asked for it (eg, gcc
requires -pedantic). Some compilers allow empty structs as
an extension and will only treat it as an error if asked for
strict checking (eg Digital-Mars with -A). Some compilers
simply treat it as an error (eg MS Visual C/C++).
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
e17a3f56
|
2009-06-04T16:47:59
|
|
Implement git_odb_write()
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
ca481fc4
|
2009-06-04T16:46:54
|
|
Add the git_move_file() function
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
4319860c
|
2009-06-04T16:45:59
|
|
win32: Add some file operation stubs and wrapper functions
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
4d503f88
|
2009-06-04T16:48:53
|
|
gitfo_exists: replace call to stat() with access()
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
ac04bdf6
|
2009-06-04T16:44:54
|
|
Fix a usage error in a call to the object_file_name() function
In 82324ac, the new static function exists_loose() called
object_file_name() and, in order to detect an error return,
tested for a negative value. This usage is incorrect, as
the error return is indicated by a positive return value.
(A successful call is indicated by a zero return value)
The only error return from object_file_name() relates to
insufficient buffer space and the return value gives the
required minimum buffer size (which will always be >0).
If the caller requires a dynamically allocated buffer,
this allows something like the following call sequence:
size_t len = object_file_name(NULL, 0, db->object_dir, id);
char *buf = git__malloc(len);
if (!buf)
error(...);
object_file_name(buf, len, db->object_dir,id);
...
No current callers take advantage of this capability.
Fix up the call site and change the return type of the
function, from int to size_t, which more accurately
reflects the implementation.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Andreas Ericsson <ae@op5.se>
|
|
498bc090
|
2009-03-23T18:47:18
|
|
t0020-dirent.c: allow test to be run standalone
This test assumed that it was invoked in an empty directory,
which is true when run from the Makefile, and so would fail
if run standalone. In order to allow the test to work when
run from any directory, create a sub directory "dir-walk"
and chdir() into this directory while running the tests.
Also, add some additional tests.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
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>
|
|
0234c186
|
2009-03-20T19:52:50
|
|
win32: Add <dirent.h> directory reading routines
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>
|
|
7a6cf815
|
2009-03-16T17:08:45
|
|
win32: Open or create files in binary mode
On windows, unless we use the O_BINARY flag in the open()
call, the file I/O routines will perform line ending
conversion (\r\n => \n on input, \n => \r\n on output).
In addition to the performance penalty, most files in the
object database are binary and will, therefore, become
corrupted by this conversion.
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>
|
|
a9984a4e
|
2009-02-18T18:52:13
|
|
Fix some (digital-mars) compiler warnings
In particular, conditional expressions which contain an
assignment statement, where the expression type is not
explicitly made to be boolean, elicits the following
message:
warning 2: possible unintended assignment
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
fc3c3a20
|
2009-02-18T18:50:36
|
|
Avoid using a gcc compiler language extension
In particular, using pointer arithmetic on void pointers,
despite being quite useful, is not legal in standard C.
Avoiding non-standard C constructs will help in porting
the library to other compilers/platforms.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
1906f236
|
2009-02-26T20:37:20
|
|
Add built-in (Mozilla) SHA1 routines
Paul agreed to the GCC-exception license by email:
|
| From: Paul Kocher <paul@cryptography.com>
| Date: Sun, 15 Mar 2009 11:37:23 -0700
| Subject: Re: Adding Mozilla SHA1 implementation to libgit2
|
| Yes - that's fine.
|
| At 01:56 AM 3/5/2009, Andreas Ericsson wrote:
| > Hi Paul. We spoke earlier about this, if you remember?
| > We'd like to add the GCC-exception to the GPL license
| > for these files.
Signed-off-by: Paul Kocher <paul@cryptography.com>
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
82324ac1
|
2009-02-10T21:49:48
|
|
Add the git_odb_exists() object query function
This function determines if the given object can be found
in the object database. At present, only the local object
database is searched.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
e9f5e877
|
2009-02-03T18:25:13
|
|
Rearrange some code to improve clarity
In particular, the test for z-stream input completion
(zs.avail_in != 0) logically belongs with the test for
the Z_STREAM_END stream status. This is also consistent
with the identical check in finish_inflate().
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
236e7579
|
2009-02-03T18:23:50
|
|
Check for error returns from inflateInit()
At present, it is sufficient to ensure that an error return
from inflateInit() is not ignored. Most error returns, like
Z_VERSION_ERROR and Z_STREAM_ERROR, indicate programming or
build errors. These errors could, perhaps, be handled with
simple asserts. However, for a Z_MEM_ERROR, we may want to
perform some further error handling in the future.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
c94eb4aa
|
2009-02-03T18:22:09
|
|
Fix a potential memory leak
In particular, neglecting to call inflateEnd() along various
codepaths in the inflate_tail() routine, would result in the
failure to release zlib internal state.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
cfe96f31
|
2009-01-12T19:44:51
|
|
Add some (macro) file operation wrappers
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
ced645ea
|
2009-01-12T19:42:13
|
|
Add git__dirname and git__basename utility routines
These routines are intended to extract the directory and
base name from a path string. Note that these routines
do not interact with any filesystem and work only on the
text of the path.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
66a4bfac
|
2009-01-12T19:38:37
|
|
Fix a sparse "symbol not declared" warning
In particular, the git__delta_apply() function has not been
declared prior to it's definition. In order to suppress the
warning, include the delta-apply.h header which provides the
public interface. This ensures that the declaration and
definition are consistent.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
c23841c8
|
2009-01-03T04:21:30
|
|
Add the binary delta apply algorithm for pack style deltas
The git__delta_apply() function can be used to apply a Git style
delta, such as those used in pack files or in git patch files,
to recover the original object stream.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
bed3229b
|
2009-01-03T03:34:09
|
|
Precompute the fanout decoding and the oid offset in a pack-*.idx
The fanout table is fairly commonly accessed, we need to read it
twice for each object we lookup in any given pack file. Most of
the processors running Git are running in little-endian mode, as
they are variants of the x86 platform, so reading the fanout is
a costly operation as we need to convert from network byte order
to local byte order. By decoding the fanout table into a malloc
obtained buffer we can save these 2 decode operations per lookup
and make search go more quickly.
This also cleans up the initialization of the search functions
by cutting out a few instructions, saving a small amount of time.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
a7c60cfc
|
2009-01-03T02:41:26
|
|
Add basic support to read pack-*.idx v1 and v2 files
The index data is mapped into memory and then scanned using a
binary search algorithm to locate the matching entry for the
supplied git_oid. The standard fanout hash trick is applied to
reduce the search space by 8 iterations.
Since the v1 and v2 file formats differ in their search function,
due to the different layouts used for the object records, we use
two different search implementations and a virtual function pointer
to jump to the correct version of code for the current pack index.
The single function jump per-pack should be faster then computing
a branch point inside the inner loop of a common binary search.
To improve concurrency during read operations the pack lock is only
held while verifying the index is actually open, or while opening
the index for the first time. This permits multiple concurrent
readers to scan through the same index.
If an invalid index file is opened we close it and mark the
git_pack's invalid bit to true. The git_pack structure is kept
around in its parent git_packlist, but the invalid bit will cause
all future readers to skip over the pack entirely. Pruning the
invalid entries is relatively unimportant because they shouldn't
be very common, a $GIT_DIRECTORY/objects/pack directory tends to
only have valid pack files.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
20e7f426
|
2009-01-03T00:36:10
|
|
Add a simple mmap wrapper for cross-platform mmap usage
Win32 has a variant of mmap that is harder to use than POSIX, but
to run natively and efficiently on Win32 we need some form of it.
gitfo_map_ro() provides a basic mmap function for use in locations
where we need read-only random data access to large ranges of a file,
such as a pack-*.idx.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
098ac57a
|
2009-01-03T00:02:25
|
|
Refactor pack memory management and locking to be safer
Using an atomic reference counter is difficult to make
cross-platform, as the reference count implementations
are generally processor specific. Its also hard to do
a proper multi-read/single-write implementation.
We now use a simple mutex around the reference count for the list
of packs. Readers grab the mutex and either build the list, or
increment the existing one's reference count. When the reader is
done with the list, the reference count is decremented. In this way
parallel readers are able to operate on the list without worrying
about it being deallocated out from under them.
Individual pack structures are held by reference counts, but we
only care about the list the pack structure is held in. There is
no need to increment/decrement the pack reference counts as we
scan through them during a read operation, the caller holds the
git_packlist and that is sufficient to hold the packs it references.
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>
|
|
51eb2f90
|
2009-01-02T21:48:40
|
|
Change the use of asm/atomic.h to require -DGIT_HAS_ASM_ATOMIC
These headers aren't always available; they typically come from the
Linux kernel, but aren't supposed to be exported into the userspace
/usr/include. Modern kernels won't install these and some distros
rm -rf the directory post kernel header install.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
11bb049b
|
2009-01-02T21:41:52
|
|
Fix pthread_mutex based gitrc_dec
The function should return true only when the counter drops to 0.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
b438016e
|
2008-12-31T16:20:05
|
|
Find pack files in $GIT_DIR/objects/pack directory on git_odb_open
Currently we only catalog the available pack files into a table,
storing their path names relative to the pack directory.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
7350e633
|
2008-12-31T16:07:38
|
|
Define gitfo_exists to determine file presence
When scanning the pack directory we need to see if the path
name is present for ".idx" when we discover a ".pack" file.
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>
|
|
5690f02e
|
2008-12-31T15:35:36
|
|
Rewrite git_foreach_dirent into gitfo_dirent
Our fileops API is currently private. We aren't planning on supplying
a cross-platform file API to applications that link to us. If we did,
we'd probably whole-sale publish fileops, not just the dirent code.
By moving it to be private we can also change the call signature to
permit the buffer to be passed down through the call chain. This is
very helpful when we are doing a recursive scan as we can reuse just
one buffer in all stack frames, reducing the impact the recursion has
on the stack frames in the data cache.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
9eb79764
|
2008-12-31T14:35:39
|
|
Add string utility functions for prefix and suffix compares
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
5614dc18
|
2008-12-31T13:27:51
|
|
Add basic locking to the git_odb structure
We grab the lock while accessing the alternates list, ensuring that
we only initialize it once for the given git_odb.
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>
|
|
5673434f
|
2008-12-31T07:34:43
|
|
Undefine malloc,strdup,calloc before redefining them
Some systems may use cpp macros to define these functions, glibc
appears to be one of them.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
7dd8a9f7
|
2008-12-30T23:26:38
|
|
Set GIT_EOSERR when the OS errno should be consulted
This error code indicates the OS error code has a better value
describing the last error, as it is likely a network or local
file IO problem identified by a C library function call.
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>
|
|
ffb55c53
|
2008-12-30T22:29:04
|
|
Rename the path of the objects directory to be more specific
We're likely to add additional path data, like the path of the
refs or the path to the config file into the git_odb structure,
as it may grow into the repository wrapper. Changing the name
of the objects directory reference makes it more clear should
we later add something else.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
4c67e2e9
|
2008-12-30T22:25:30
|
|
Change git_odb__read_packed to return ENOTFOUND until implemented
We didn't search for the object, so we cannot possibly promise it
to the caller of git_odb_read().
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>
|
|
d7467949
|
2008-12-30T21:50:10
|
|
Remove unnecessary import of stdlib.h from revwalk.h
OS headers are best imported from a more central location anyway.
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>
|
|
213e720c
|
2008-12-20T20:47:41
|
|
Change usages of static inline to GIT_INLINE
Signed-off-by: Julio Espinoza-Sokal <julioes@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
c960d6a3
|
2008-12-27T18:59:43
|
|
Add a routine to determine a git_oid given an git_obj
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
007e0753
|
2008-12-27T18:58:25
|
|
Add some routines for SHA1 hash computation
[sp: Changed signature for output to use git_oid, and added
a test case to verify an allocated git_hash_ctx can be
reinitialized and reused.]
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
42fd40db
|
2008-12-27T18:56:16
|
|
Fix a bug in gitfo_read_file()
In particular, when asked to read an empty file, this function
calls malloc() with a zero size allocation request. Standard C
says that the behaviour of malloc() in this case is implementation
defined.
[C99, 7.20.3 says "... If the size of the space requested is zero,
the behavior is implementation-defined: either a null pointer is
returned, or the behavior is as if the size were some nonzero
value, except that the returned pointer shall not be used to
access an object."]
Finesse the issue by over-allocating by one byte. Setting the extra
byte to '\0' may also provide a useful sentinel for text files.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
3d3552e8
|
2008-12-18T22:58:10
|
|
Implement git_odb__read_loose()
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
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>
|
|
7b6e8067
|
2008-12-10T18:31:28
|
|
Add some git_otype string conversion and testing routines
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
b3be0fc7
|
2008-12-03T23:54:47
|
|
Fix an "implicit function definition" warning on cygwin
In particular, the warning relates to malloc(), which is
declared in <stdlib.h>. This header is now included,
indirectly, via the "common.h" header.
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>
|
|
192678b5
|
2008-12-03T23:52:57
|
|
Fix some doxygen warnings and errors
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
af795e49
|
2008-12-02T09:56:23
|
|
Add routines to convert git_oid to hex strings
[sp: Credit for some of this implementation goes to Pieter, I
started off a patch he proposed for libgit2 but reworked
enough of it that I don't want to blame him for any bugs.]
Suggested-by: Pieter de Bie <pdebie@ai.rug.nl>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
b72ca267
|
2008-11-29T19:21:24
|
|
Diasble TLS on cygwin
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
17643760
|
2008-11-29T19:20:07
|
|
Use __CHECKER__ to detect when sparse is running
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
43288a07
|
2008-11-29T19:18:43
|
|
Fixup documentation to reflect the "git_obj" rename
commit dff79e27d3d2cdc09790ded80fe2ea8ff5d61034 renamed
the (small object) "git_sobj" to a plain "git_obj", but
neglected to update some of the documentation to reflect
that change.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
ea790f33
|
2008-11-29T15:34:20
|
|
Add a dirent walker to the fileops API
Since at least MS have something like GetFirstDirEnt() and
GetNextDirEnt() (presumably with superior performance), we
can let MS hackers add support for a dirent walker using
that API instead, while we stick with the posix-style
readdir() calls.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
4188d28f
|
2008-11-29T15:28:12
|
|
Add an io caching layer to the gitfo api
The idea is taken from Junio's work in read-cache.c, where
it's used for writing out the index without tap-dancing on
the poor harddrive. Since it's almost certainly useful for
cached writing of packfiles too, we turn it into a generic
API, making it perfectly simple to reuse it later.
gitfo_write_cached() has the same contract as gitfo_write(), it
returns GIT_SUCCESS if all bytes are successfully written (or were
at least buffered for later writing), and <0 if an error occurs
during buffer writing.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
ec250c6e
|
2008-11-23T22:37:55
|
|
Remove config.h and make fileops an internal API
Since it doesn't make sense to make the disk access stuff
portable *AND* public (that's a job for each application
imo), we can take a shortcut and just support unixy stuff
for now and get away with coding most of it as macros.
Since we go with an internal API for starters and only
provide higher-level API's to the libgit users, we'll be
ok with this approach.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
c6ebb4a9
|
2008-11-22T15:17:17
|
|
Remove license top-comment from public header files
Since it's being added when we install the headers anyway,
we might as well get rid of it. If anything, we should point
coders to the COPYING file in the project's root directory
instead of duplicating the same (large-ish) text everywhere.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
f501265f
|
2008-11-22T14:40:51
|
|
Add cc-compat.h - C compiler compat macros for internal use
Holds things such as FLEX_ARRAY and whatnot.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
c215be41
|
2008-11-22T14:57:40
|
|
Rename git_revpool_* functions gitrp_*
Otherwise their prototypes don't match their declarations.
Detected by 'sparse', which is obviously good to run
before each commit.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|
|
4f0adcd0
|
2008-11-18T21:28:55
|
|
Get rid of GIT__PRIVATE macro
Using it in the first place means something's wrong.
This patch replaces it with an internal header which
carries the previously "protected" code instead.
Internal source-files simply include "commit.h" and
they're done. The internal header includes the public
one to make sure we always use the proper prototype.
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
|