Commit Graph

4856 Commits

Author SHA1 Message Date
Vicent Marti
8903968265 Removed 'git_commit_uninteresting' from the public API.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
1a895dd787 Add arbritrary ordering revision walking.
The 'gitrp_next()' method now correctly does a revision walking
of all the pushed revisions in arbritary ordering.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
8add015392 Split git_commit_lookup into separate functions.
git_commit_lookup() now creates commit references
without loading them from the ODB.

git_commit_parse() creates a commit reference, loads
it and parses it from the ODB.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
08d5d00056 Add commit parents to parsed commits and commit lists to the revpool.
Basic support for iterating the revpool.

The following functions of the revwalk API have been partially
implemented:

    void gitrp_reset(git_revpool *pool);
    void gitrp_push(git_revpool *pool, git_commit *commit);
    void gitrp_prepare_walk(git_revpool *pool);
    git_commit *gitrp_next(git_revpool *pool);

Parsed commits' parents are now also parsed and stored in a
"git_commit_list" structure (linked list).

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
42281e007e Add unit tests for Commit parsing
A few initial tests for commit parsing:

    "parse_buffer_test" tests git_commit__parse_buffer() with
    several malformed commit messages and a few corner cases
    which should pass.

    "parse_oid_test" tests git_commit__parse_oid() with several
    malformed commit lines containing broken SHA1 OIDs.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
4caa8962a6 Fixed indentation issues in commit.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
417f0abc9b Add basic functionality for commit lookup/parsing
The external API function "git_commit_parse" has been renamed
to "git_commit_lookup" and has been partially implemented with
support for loading commits straight from the ODB. It still lacks
the functionality to lookup cached commits in the revpool and to
resolve tags to commits.

The following internal functions have been partially implemented:

int git_commit__parse_buffer(...);
int git_commit__parse_time(...);
int git_commit__parse_oid(...);

Commits are now fully parsed but the generated parent and tree
references are not handled yet.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Vicent Marti
1bb1185935 Fixed typos in the revwalk API documentation
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-06-02 10:32:06 +02:00
Ramsay Jones
38c513b9d1 Add support to enable the library to use OpenSSL SHA1 functions
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-05-04 21:36:12 +02:00
Ramsay Jones
89217d8f1a Add functions to open a '*.pack' file and perform some basic validation
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-30 09:48:07 +02:00
Ramsay Jones
3cc606359d Add some more (macro) file operation wrappers
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-30 09:47:58 +02:00
Ramsay Jones
54b9460fee Fix the memory leak caused by failing to free the 'offset index'
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-30 09:47:53 +02:00
Ramsay Jones
19d13c65e1 Makefile(s): Don't include the OpenSSL crypto library in the link
Also, fully purge the NO_OPENSSL build variable.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-28 20:58:24 +01:00
Ramsay Jones
f019bd17a1 Makefile: 'make clean' wipe all editor backup files in src/*/
In a similar way to commit 9b17380 ("Make 'make clean' wipe all
object files in src/*/", 2010-04-14), we use a shell glob when
removing editor backup files.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-28 20:57:54 +01:00
Ramsay Jones
44debd80c4 Makefile: Add source for the built-in SHA1 routines to $(SRC_C)
This results in the 'sparse' and 'coverage' targets including the
C source files for the built-in SHA1 routines. In addition to the
sparse check, this results in the generation of the '.gcov' file
and inclusion in the test coverage report.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-28 20:57:03 +01:00
Ramsay Jones
70aab459aa win32: Remove wsock32 from the list of libraries to link
Commit 5dddf7c (Add block-sha1 in favour of the mozilla routines
2010-04-14) introduced the "bswap.h" header file which, for x86
or x86-64 machines, provides a "sane" implementation of ntohl()
and htonl().

The wsock32 library, on the msvc and MinGW build, is only included
in the link to supply the ntohl()/htonl() routines.  Since we now
have a built-in implementation, we can remove the wsock32 library
from the link.

[This will break a Windows build on a non-intel machine]

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-04-28 20:56:19 +01:00
Ramsay Jones
e272b10388 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>
2010-04-28 20:55:56 +01:00
Ramsay Jones
e2337f39c3 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>
2010-04-28 20:55:04 +01:00
Andreas Ericsson
fb799dfe77 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
2010-04-23 09:59:22 +02:00
Andreas Ericsson
100746511c Correct Adam Simpkins' name
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-04-15 09:57:58 +02:00
Andreas Ericsson
5dddf7c855 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>
2010-04-14 20:44:22 +02:00
Andreas Ericsson
d15e94c0d4 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>
2010-04-14 20:23:36 +02:00
Andreas Ericsson
a7335c5170 Add generic buildrule for assembly files
Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-04-14 19:40:10 +02:00
Andreas Ericsson
9b17380391 Make 'make clean' wipe all object files in src/*/
Instead of naming the subdirectories explicitly (which will result in
us forgetting about one sooner or later), we change the shell glob
pattern to wipe all object files from all subdirectories under src/.

Signed-off-by: Andreas Ericsson <ae@op5.se>
2010-04-14 19:38:38 +02:00
Ramsay Jones
2cdc454423 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>
2010-02-28 20:16:30 +00:00
Ramsay Jones
608d33fa67 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>
2010-02-28 20:13:29 +00:00
Ramsay Jones
abf5681c03 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>
2010-02-28 20:12:32 +00:00
Ramsay Jones
238e54bcff Add an 64-bit offset table index bounds check for v2 pack index
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-02-28 20:12:04 +00:00
Ramsay Jones
255a0dabb2 Add a minimum size check when opening an v2 pack index file
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-02-28 20:11:33 +00:00
Ramsay Jones
e8cc449fe9 win32: Add separate MinGW and MSVC compatability header files
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-02-28 20:10:56 +00:00
Ramsay Jones
56931d1ab4 Makefile: Add support for custom build options in config.mak file
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-02-28 20:10:35 +00:00
Ramsay Jones
1e5dd57214 Fix some coding style issues
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-02-28 20:09:45 +00:00
Ramsay Jones
74eff33f8b Makefile: Add support for building with MSVC
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-02-01 10:39:10 +01:00
Ramsay Jones
73dcf2876f msvc: Fix some "unreferenced formal parameter" warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:22:10 +00:00
Ramsay Jones
e8a952561c msvc: Fix some -W4 warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:20:47 +00:00
Ramsay Jones
1a7bae4d0f Fix some "unused parameter" warnings with -Wextra
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:19:55 +00:00
Ramsay Jones
e3fe32b6a4 Fix "'__thread' not at start of declaration" warnings (-Wextra)
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:19:06 +00:00
Ramsay Jones
0ef9d2aa93 Fix some "signed v unsigned comparison" warnings with -Wextra
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:18:36 +00:00
Ramsay Jones
a4f863af4d Fix an always false comparison "unsigned < 0" warning
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:18:15 +00:00
Ramsay Jones
803a6b4d41 Save the git_file in the gitfo_cache when enabling caching
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:17:56 +00:00
Ramsay Jones
1cfb0ff4b6 Makefile: Add some missing $(GIT_LIB) dependencies
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:17:18 +00:00
Ramsay Jones
e97179b6de 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>
2010-01-20 20:16:34 +00:00
Ramsay Jones
90d4d2f0fc win32: Use an 64-bit file offset type
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:15:57 +00:00
Ramsay Jones
a1c0728d12 Add support for the MinGW platform
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:15:07 +00:00
Ramsay Jones
cfe3a027ab Use a 64 bit off_t throughout the library and tests on POSIX
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2010-01-20 20:13:07 +00:00
Ramsay Jones
960ca1d779 Add the git_oid_to_string() utility function
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2009-10-13 16:27:33 +01:00
Ramsay Jones
e45535849c Add test-suite coverage testing using gcov
Add a new "coverage" Makefile target that re-builds the
library and tests using the gcc compiler/linker flags
required by gcov, runs the test suite to capture the
runtime data, then compiles a coverage report.

The report, which is saved in a file named "untested",
consists of a list of untested files, followed by a list
of untested functions. More detailed execution statistics
are given in the gcov log files which are saved in the
top-level directory (named like src#hash.c.gcov).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2009-10-13 16:26:05 +01:00
Ramsay Jones
d2ef83fcdc t0101-oid.c: Fix a memory leak reported by valgrind
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2009-10-13 16:25:26 +01:00
Ramsay Jones
cac5d927b5 Add support for running the tests via valgrind
Add some makefile targets, which use valgrind's memcheck tool to
run the tests, in order to help diagnose memory problems in the
library.

In addition, we enable the '--leak-check' option to report on any
memory leaks. However, unlike the other memory problems reported
by memcheck, memory leak reports do not result in an error exit
from valgrind. (So memory leaks are reported on stderr, but don't
halt the test run.)

A suppressions file (tests.supp) is included since libz triggers
some false positives.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
2009-10-13 16:23:54 +01:00
Ramsay Jones
04e8824004 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>
2009-10-13 16:22:58 +01:00