Commit Graph

53 Commits

Author SHA1 Message Date
Vicent Martí
29e948debe global: Change parameter ordering in API
Consistency is good.
2012-05-18 01:25:57 +02:00
Vicent Martí
0f49200c9a msvc: Do not use isspace
Locale-aware bullshit bitting my ass again yo
2012-05-09 04:37:02 +02:00
Vicent Martí
3fbcac89c4 Remove old and unused error codes 2012-05-02 19:56:38 -07:00
Russell Belfer
44ef8b1b30 Fix warnings on 64-bit windows builds
This fixes all the warnings on win64 except those in deps, which
come from the regex code.
2012-04-17 10:47:39 -07:00
Russell Belfer
14a513e058 Add support for pathspec to diff and status
This adds preliminary support for pathspecs to diff and status.
The implementation is not very optimized (it still looks at
every single file and evaluated the the pathspec match against
them), but it works.
2012-04-13 15:00:29 -07:00
Russell Belfer
7c7ff7d11e Migrate index, oid, and utils to new errors
This includes a few cleanups that came up while converting
these files.

This commit introduces a could new git error classes, including
the catchall class: GITERR_INVALID which I'm using as the class
for invalid and out of range values which are detected at too low
a level of library to use a higher level classification.  For
example, an overflow error in parsing an integer or a bad letter
in parsing an OID string would generate an error in this class.
2012-03-19 16:10:11 -07:00
Russell Belfer
0d0fa7c368 Convert attr, ignore, mwindow, status to new errors
Also cleaned up some previously converted code that still had
little things to polish.
2012-03-16 15:56:01 -07:00
Russell Belfer
ae9e29fde7 Migrating diff to new error handling
Ended up migrating a bunch of upstream functions as well
including vector, attr_file, and odb in order to get this
to work right.
2012-03-06 16:27:13 -08:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Russell Belfer
bd370b14fe Improved gitattributes macro implementation
This updates to implementation of gitattribute macros to be much more
similar to core git (albeit not 100%) and to handle expansion of
macros within macros, etc.  It also cleans up the refcounting usage
with macros to be much cleaner.

Also, this adds a new vector function `git_vector_insert_sorted()`
which allows you to maintain a sorted list as you go.  In order to
write that function, this changes the function `git__bsearch()` to
take a somewhat different set of parameters, although the core
functionality is still the same.
2011-12-30 15:00:14 -08:00
Vicent Marti
3286c408ec global: Properly use git__ memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
2011-10-28 19:02:36 -07:00
Vicent Marti
fafd471021 config: Proper type declarations for 64 bit ints 2011-09-30 16:08:41 +02:00
nulltoken
ad196c6ae6 config: make git_config_[get|set]_long() able to properly deal with 8 bytes wide values
Should fix issue #419.

Signed-off-by: nulltoken <emeric.fermas@gmail.com>
2011-09-22 18:58:47 +02:00
Vicent Marti
87d9869fc3 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.
2011-09-19 03:34:49 +03:00
Vicent Marti
bb742ede3d Cleanup legal data
1. The license header is technically not valid if it doesn't have a
copyright signature.

2. The COPYING file has been updated with the different licenses used in
the project.

3. The full GPLv2 header in each file annoys me.
2011-09-19 01:54:32 +03:00
Sebastian Schuberth
26e74c6ace Fix some random size_t vs. int conversion warnings 2011-09-08 17:07:37 +02:00
Vicent Marti
84dd3820d4 posix: Properly handle snprintf in all platforms 2011-08-18 02:35:28 +02:00
nulltoken
d1f346931a util: Add git__strcmp_cb() wrapper
We don't want direct pointers to the CRT on Windows, we may get stdcall conflicts.
2011-08-09 22:34:54 +02:00
nulltoken
ae2e4c6a06 win32: replace usage of _MSV_VER with _MSC_VER 2011-07-09 08:41:02 +02:00
Vicent Marti
de18f27668 vector: Timsort all of the things
Drop the GLibc implementation of Merge Sort and replace it with Timsort.

The algorithm has been tuned to work on arrays of pointers (void **),
so there's no longer a need to abstract the byte-width of each element
in the array.

All the comparison callbacks now take pointers-to-elements, not
pointers-to-pointers, so there's now one less level of dereferencing.

E.g.

	 int index_cmp(const void *a, const void *b)
	 {
	-	const git_index_entry *entry_a = *(const git_index_entry **)(a);
	+	const git_index_entry *entry_a = (const git_index_entry *)(a);

The result is up to a 40% speed-up when sorting vectors. Memory usage
remains lineal.

A new `bsearch` implementation has been added, whose callback also
supplies pointer-to-elements, to uniform the Vector API again.
2011-07-07 02:54:07 +02:00
Vicent Martí
bf9a2e98b8 Merge pull request #296 from kiryl/index-optimization
Index optimization
2011-07-06 10:55:06 -07:00
Vicent Marti
e9c6571d7f fnmatch: Use native on Unix, emulate on Win32 2011-07-06 01:04:04 +02:00
Kirill A. Shutemov
c20ffa6104 util: introduce merge sort routine
In some cases it's important to preserve order of elements with equal
keys (stable sort). qsort(3) doesn't define order of elements with
equal keys.

git__msort() implements merge sort which is stable sort.

Implementation taken from git. Function renamed git_qsort() -> git__msort().

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-05 17:52:39 +03:00
Vicent Martí
f12aa9dc5e Merge pull request #300 from carlosmn/gsoc2011/master
A bit of networking
2011-07-05 04:31:37 -07:00
Vicent Marti
f79026b491 fileops: Cleanup
Cleaned up the structure of the whole OS-abstraction layer.

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

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

All the path-related methods have been moved from `utils.c` to `path.c`
and have their own prefix.
2011-07-05 02:04:03 +02:00
Kirill A. Shutemov
932d1baf29 cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-01 18:02:56 +02:00
Carlos Martín Nieto
63f91e1ce8 Add git.git's fnmatch, which is really GNU's and the git__fnmatch wrapper
If the strings match, git__fnmatch returns GIT_SUCCESS and
GIT_ENOMATCH on failure to match.

MSVC fixes: Added a test for _MSC_VER and (in that case) defined
HAVE_STRING_H to 1 so it doesn't try to include <strings.h> which
doesn't exist in the MSVC world. Moved the function declarations to
use the modern inline ones so MSVC doesn't have a fit. Added casts
everywhere so MSVC doesn't crap its pants.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Vicent Marti
536955f9d7 Add method to get the compiled version of the lib 2011-06-16 02:21:33 +02:00
Vicent Marti
0291b5b76b odb: Fix loading ODB alternates
Fixed an issue with the `strtokz implementation and added support for
comments and relative paths in the alternates file.
2011-06-03 20:01:18 +02:00
nulltoken
3a1c431011 Fix compilation warnings in MSVC
This allows to successfully build libgit2 with waf on Windows.
2011-05-24 18:55:35 +02:00
Jakob Pfender
33b1d19e76 util.c: Move to new error handling mechanism 2011-05-23 21:38:39 +03:00
Vicent Marti
0da2c70067 utils: Move git__str[n]tolower 2011-05-17 15:11:19 +03:00
Vicent Marti
c6e65acae6 Properly check strtol for errors
We are now using a custom `strtol` implementation to make sure we're not
missing any overflow errors.
2011-04-09 15:22:11 -07:00
nulltoken
2b861d7589 Add detection of incorrect usage to git__joinpath() 2011-03-23 00:25:04 +02:00
Vicent Marti
955f9ae9bd Export git_strarray_free instead of inlining
That way non-C bindings can use it.
2011-03-16 01:06:15 +02:00
Vicent Marti
246eba80af Use memmove() in git__dirname and git__basename
We cannot make sure that the user doesn't use the same buffer as source
and destination, so write to it using memmove.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:58:47 +02:00
Vicent Marti
60cb1d10b3 Use memmove() in git__joinpath for overlapping copies
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:56:14 +02:00
nulltoken
669db21b28 Slightly changed the behavior of git__joinpath() and git__joinpath_n(). 2011-03-03 20:23:51 +02:00
Vicent Marti
995f9c34a5 Use the new git__joinpath to build paths in methods
The `git__joinpath` function has been changed to use a statically
allocated buffer; we assume the buffer to be 4096 bytes, because fuck
you.

The new method also supports an arbritrary number of paths to join,
which may come in handy in the future.

Some methods which were manually joining paths with `strcpy` now use the
new function, namely those in `index.c` and `refs.c`.

Based on Emeric Fermas' original patch, which was using the old
`git__joinpath` because I'm stupid. Thanks!

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-09 12:43:19 +02:00
nulltoken
a79e8e632a Fixed a small issue in git__join_path(). Added tests to exercise git__join_path(). 2011-02-05 19:23:51 +01:00
Vicent Marti
412b388776 Add new utility method git__joinpath
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-05 13:12:02 +02:00
Vicent Marti
f725931b48 Fix directory/path manipulation methods
The `dirname` and `dirbase` methods have been replaced with the Android
implementation, which is actually compilant to some kind of standard.

A new method `topdir` has been added, which returns the topmost
directory in a path.

These changes fix issue #49:

	`gitfo_prettify_dir_path` converts "./.git/" to ".git/", so
	the code at src/repository.c:190 goes out of bounds when
	trying to find the topmost directory.

	The new `git__topdir` method handles this gracefully, and the
	fixed `git__dirname` now returns the proper value for the
	repository's working dir.

	E.g.

		/repo/.git/ ==> working dir '/repo/'
		.git/		==> working dir '.'

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-02-05 12:42:41 +02:00
Vicent Marti
e0646b38c7 Add generic hash function to util.c
It's MurmurHash3 slightly edited to make it
cross-platform. Fast and neat.

Use this for hashing strings on hash tables instead
of a full SHA1 hash. It's very fast and well distributed.

Obviously not crypto-secure.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-12-30 00:31:58 +02:00
Vicent Marti
9f54fe482d 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>
2010-12-23 00:15:09 +02:00
Vicent Marti
69a09b7c69 Fix wrong pointer check in git__strdup
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-11-19 17:17:46 +02:00
Vicent Marti
0e465f979b Add auxiliary method git__hexdump
New function in util.c to do a dump of a buffer's contents in
hexadecimal to stdout.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2010-08-12 18:49:04 +02: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
10aa3fa72a 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>
2009-06-05 12:14:24 +02:00
Ramsay Jones
a9984a4e60 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>
2009-03-17 18:59:26 -07:00
Ramsay Jones
ced645ea9c 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>
2009-01-28 12:25:24 -08:00