Commit Graph

4488 Commits

Author SHA1 Message Date
Shawn O. Pearce
d746794980 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>
2008-12-30 21:52:07 -08:00
Shawn O. Pearce
b3039beea6 Cleanup formatting in our head files to be more consistent
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-30 21:52:07 -08:00
Julio Espinoza-Sokal
213e720ca8 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>
2008-12-30 21:52:07 -08:00
Steve Frécinaux
6f6a17db05 Fix pkgconfig file wrt last added dependencies
libz and libcrypto dependencies were added recently while libgit2.pc
did not get updated.

Signed-off-by: Steve Frécinaux <code@istique.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-30 16:50:45 -08:00
Ramsay Jones
c960d6a3f9 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>
2008-12-30 07:52:55 -08:00
Ramsay Jones
007e075337 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>
2008-12-30 07:48:10 -08:00
Ramsay Jones
42fd40db68 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>
2008-12-30 07:32:16 -08:00
Steve Frécinaux
d7fbfe155f Add pkg-config support.
The libgit2.pc is generated on make install and installed, to allow
using the lib through the pkg-config helper.

Signed-off-by: Steve Frécinaux <code@istique.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-30 07:31:03 -08:00
Steve Frécinaux
5ddbd5edf8 Add make install and uninstall targets.
It accepts a prefix= parameter (default: /usr/local).

Signed-off-by: Steve Frécinaux <code@istique.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-30 07:31:02 -08:00
Ramsay Jones
3d3552e8fd Implement git_odb__read_loose()
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-19 07:23:00 -08:00
Ramsay Jones
75d5843055 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>
2008-12-19 07:21:20 -08:00
Shawn O. Pearce
def425bf85 Remove references to src/git/config.h
It was removed in ec250c6e18.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-18 08:20:50 -08:00
Shawn O. Pearce
c18626eef6 Run tests in their own subdirectory
This way tests can run in parallel without stepping on each other's
temporary work files.  If a test passes the directory is removed
completely; if a test fails only empty directories are removed.
This permits inspection of the failed test's left behind state.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-18 08:17:05 -08:00
Ramsay Jones
7b6e8067ec 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>
2008-12-10 11:49:06 -08:00
Ramsay Jones
b3be0fc756 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>
2008-12-09 08:38:10 -08:00
Ramsay Jones
5ee2fe777c 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>
2008-12-09 08:37:52 -08:00
Ramsay Jones
192678b55c 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>
2008-12-09 08:36:32 -08:00
Andreas Ericsson
4b8e8b32c1 Add Adam Simpkins to list of consenting authors
Signed-off-by: Andreas Ericsson <ae@op5.se>
2008-12-09 08:36:10 -08:00
Shawn O. Pearce
af795e498d 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>
2008-12-02 10:02:29 -08:00
Ramsay Jones
b72ca26740 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>
2008-12-02 09:23:48 -08:00
Ramsay Jones
1764376034 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>
2008-12-02 09:23:18 -08:00
Ramsay Jones
80133dad8a Use cgcc in the sparse target
cgcc is the recommended way to run sparse, since it provides
many -Defines suitable to the given gcc platform. For example,
on some Ubuntu/glibc versions, a plain sparse invocation gives
the following warning:

    "warning: This machine appears to be neither x86_64 nor i386."

Using "cgcc -no-compile" instead eliminates this warning.

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>
2008-12-02 09:21:50 -08:00
Ramsay Jones
43288a0733 Fixup documentation to reflect the "git_obj" rename
commit dff79e27d3 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>
2008-12-02 09:20:06 -08:00
Andreas Ericsson
ea790f337b 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>
2008-12-02 09:18:19 -08:00
Andreas Ericsson
4188d28f1c 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>
2008-12-02 09:17:42 -08:00
Andreas Ericsson
ec250c6e18 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>
2008-12-02 09:17:23 -08:00
Andreas Ericsson
42c07750c4 doxygen config: Update path to public headers
In d4043ee9d9, public headers
were moved from include/git to src/git, but the doxygen
configuration wasn't updated to reflect this. This patch
amends that slippage, making documentation generation once
again work as intended.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:45:03 -08:00
Andreas Ericsson
634a64b10a Add a new author state "ign" to git.git-authors
This is to be used for application code that currently
resides in git, but only for authors whose only not
insignificant contributions are for that code (such as
"imap-send").

Presently, this is used for Mike McCormack and Robert
Shearman.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:44:36 -08:00
Andreas Ericsson
9e300586fb Add Kristian Høgsberg to the list of consenting authors
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:44:36 -08:00
Andreas Ericsson
0cfd861bd5 Add Adam Simpkins as ??? to git.git-authors
Adam has made significant contributions to the http
transport code, but his listed email address is no longer
valid.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:44:36 -08:00
Andreas Ericsson
6e9ac9c85e Add René Scharfe to git.git-authors
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:44:36 -08:00
Andreas Ericsson
f2b93d4124 Add Matthieu Moy and Steffen Prohaska to git.git-authors
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:44:36 -08:00
Andreas Ericsson
cc7301d8a2 Add Sven Verdoolaege to git.git-authors
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-12-02 08:44:36 -08:00
Andreas Ericsson
ab3f234e5f Make using CFLAGS a bit simpler
This patch introduces the $(ALL_CFLAGS) variable, which holds
$(BASIC_CFLAGS) as well as userdefined $(CFLAGS) and then
consistently uses that variable where both were used anyway.

Since we're in the area, we optimize the sparse running a
bit, getting rid of the shell and just letting sparse iterate
over the files.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
6013ffa66e Add $(CONFIG_H) as a build-dependency for sparse
Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
21648b4535 Make src/git/config.h a macro in Makefile
This makes it far more convenient to reference as a dependency
for other targets.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
c6ebb4a940 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>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
ae23486285 Add an embryo of a TLS-aware error handling system
This adds the per-thread global variable git_errno to the
system, which callers can examine to get information about
an error.

Two helper functions are added to reduce LoC-count for the
library code itself.

Also, some exceptions are made for running sparse on GIT_TLS
definitions, since it doesn't grok thread-local variables at
all.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
3a2aabdce1 Add util.h - utility macros
ARRAY_SIZE() et al go in util.h, included from common.h

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
76a8c44727 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>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
f501265f97 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>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
c215be4120 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>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
3e1d42b7d9 Add a 'sparse' make target
Given the confusion on git@vger, we'd better not name
this target "check" or (worse) "test", but it's still
useful to have. As "sparse", noone should have problems
understanding what it does.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
ff7c7576aa s/COPYING/.HEADER/ for install-headers target
We don't want to prepend the entire license; Only the
file header part of it.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
4f0adcd0e6 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>
2008-11-22 12:08:00 -08:00
Andreas Ericsson
36f0f61fc8 Add compiler/platform agnostic thread-local storage
It doesn't cover all cases, but we can work on those as
we go along. For now, gcc, MSVC++, Intel C/C++, IBM XL C/C++,
Sun Studio C/C++ and Borland C++ Builder are the supported
compilers (although we boldly assume that they all are of
a recent enough version to support thread-local storage).

This is intended to be used in upcoming patches that implement
graceful (but TLS-dependant) error-handling in the library.

As an added bonus, we also bring the online_cpus() function
from git.git to detect the number of usable cpu's.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-18 10:32:53 -08:00
Andreas Ericsson
a57e9a8cc1 Add a fake and phony install-headers target
It actually does what it's supposed to (more or less),
but not very portably and not to the correct directory.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-18 10:32:53 -08:00
Andreas Ericsson
d4043ee9d9 Move public headers to src/git
It's arguably smoother to keep them close to the source,
as that's where one's working when modifying them. More
importantly, though, is the ability to use private headers
in the src/ dir that simply include "git/$samename.h" to
get to the public API at the same time.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-18 10:32:53 -08:00
Andreas Ericsson
1b9e92c73b s/git_revp/git_revpool/
git_revp is something I personally can't stop pronouncing
"rev pointer". I'm sure others would suffer the same
problem.

Also, rename the git_revp_ sub-api "gitrp_". This is the
first of many such renames, primarily done to prevent
extreme inflation in the "git_" namespace, which we'd like
to reserve for a higher-level API.

While we're at it, we remove the noise-char "c" from a lot
of functions. Since revision walking is all about commits,
the common case should be that we're dealing with commits.
Exceptions can get a more mnemonic description as needed.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-18 10:32:53 -08:00
Andreas Ericsson
dff79e27d3 Rename "git_sobj" "git_obj"
The 's' never really made sense, since it's not a "small"
object at all, but rather a plain object. As such, it should
have a "plain" object name.

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-18 10:32:53 -08:00