Commit Graph

116 Commits

Author SHA1 Message Date
Krishna Ram Prakash R
70b9b84179 Fixed bug while parsing INT64_MIN 2016-06-29 13:32:18 +05:30
Edward Thomson
d34f68261e Patch parsing from patch files 2016-05-26 11:36:11 -05:00
Edward Thomson
e683d15247 qsort_r/qsort_s: detect their support 2015-09-30 05:49:04 -04:00
John Haley
eba784d24d Fix duplicate basenames to support older VS
With Visual Studio versions 2008 and older they ignore the full path to files and only check
the basename of the file to find a collision. Additionally, having duplicate basenames can break
other build tools like GYP.

This fixes https://github.com/libgit2/libgit2/issues/3356
2015-08-05 13:02:58 -07:00
Edward Thomson
e069c621bd git__getenv: utf-8 aware env reader
Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere.
Make `cl_getenv` use this to keep consistent memory handling around
return values (free everywhere, as opposed to only some platforms).
2015-07-02 16:35:43 +00:00
Edward Thomson
75a4636f50 git__tolower: a tolower() that isn't dumb
Some brain damaged tolower() implementations appear to want to
take the locale into account, and this may require taking some
insanely aggressive lock on the locale and slowing down what should
be the most trivial of trivial calls for people who just want to
downcase ASCII.
2015-05-29 18:16:46 -04:00
Edward Thomson
006548da91 git__strcasecmp: treat input bytes as unsigned
Treat input bytes as unsigned before doing arithmetic on them,
lest we look at some non-ASCII byte (like a UTF-8 character) as a
negative value and perform the comparison incorrectly.
2015-05-29 16:07:51 -04:00
Edward Thomson
ec510666a1 Credit utf8proc for utf8 iterator 2015-02-10 21:34:08 -05:00
Vicent Marti
8e35527de2 path: Use UTF8 iteration for HFS chars 2014-12-16 10:24:18 -06:00
Edward Thomson
a64119e396 checkout: disallow bad paths on win32
Disallow:
 1. paths with trailing dot
 2. paths with trailing space
 3. paths with trailing colon
 4. paths that are 8.3 short names of .git folders ("GIT~1")
 5. paths that are reserved path names (COM1, LPT1, etc).
 6. paths with reserved DOS characters (colons, asterisks, etc)

These paths would (without \\?\ syntax) be elided to other paths - for
example, ".git." would be written as ".git".  As a result, writing these
paths literally (using \\?\ syntax) makes them hard to operate with from
the shell, Windows Explorer or other tools.  Disallow these.
2014-12-16 10:08:53 -06:00
Jacques Germishuys
491ad0de59 qsort_r is only available from Visual Studio 2005+ 2014-07-06 09:22:24 +02:00
Jacques Germishuys
90a4340aaa cygwin also doesn't have qsort_r 2014-04-30 13:17:15 +02:00
Russell Belfer
3b4c401a38 Decouple index iterator sort from index
This makes the index iterator honor the GIT_ITERATOR_IGNORE_CASE
and GIT_ITERATOR_DONT_IGNORE_CASE flags without modifying the
index data itself.  To take advantage of this, I had to export a
number of the internal index entry comparison functions.  I also
wrote some new tests to exercise the capability.
2014-04-17 14:43:45 -07:00
Edward Thomson
e85bbd5250 Move libgit2 settings out of util 2014-01-14 18:36:00 -08:00
Brodie Rao
2fcc0d07d0 util: handle NULL pointers passed to git_strarray_free()
Signed-off-by: Brodie Rao <brodie@sf.io>
2014-01-12 23:34:09 -08:00
Jacques Germishuys
551f5cefb4 Solaris does not have qsort_r 2014-01-08 13:47:47 +02:00
Alessandro Ghedini
963edd9bff util: NetBSD doesn't have qsort_r either 2013-11-19 17:59:55 +01:00
Vicent Martí
3d4f169867 Merge pull request #1858 from linquize/win32-template-dir
Configurable template dir for Win32
2013-09-17 10:21:22 -07:00
Russell Belfer
a9f51e430f Merge git_buf and git_buffer
This makes the git_buf struct that was used internally into an
externally available structure and eliminates the git_buffer.

As part of that, some of the special cases that arose with the
externally used git_buffer were blended into the git_buf, such as
being careful about git_buf objects that may have a NULL ptr and
allowing for bufs with a valid ptr and size but zero asize as a
way of referring to externally owned data.
2013-09-17 09:31:45 -07:00
Linquize
b99b10f285 Can git_libgit2_opts() with GIT_OPT_GET_TEMPLATE_PATH and GIT_OPT_SET_TEMPLATE_PATH 2013-09-18 00:00:41 +08:00
Krzysztof Adamski
b1447edebc Use git__insertsort_r on Android too. 2013-09-01 18:47:56 +02:00
Russell Belfer
290e147985 Add GIT_CAP_SSH if library was built with SSH
This also adds a test that actually calls git_libgit2_capabilities
and git_libgit2_version.
2013-07-09 16:17:41 -07:00
Russell Belfer
c9b18018fd Fix some warnings 2013-06-17 10:03:48 -07:00
Edward Thomson
e3b4a47c1e git__strcasesort_cmp: strcasecmp sorting rules but requires strict equality 2013-06-17 10:03:15 -07:00
yorah
3425fee637 util: git__memzero() tweaks
On Linux: fix a warning message related to the volatile qualifier (cast)
On Windows: use SecureZeroMemory()

On both, inline the call, so that no entry point can lead back to this "secure" memory zeroing.
2013-06-17 15:42:33 +02:00
Vicent Marti
6de9b2ee14 util: It's called memzero 2013-06-12 21:10:33 +02:00
Russell Belfer
3e9e6cdaff Add safe memset and use it
This adds a `git__memset` routine that will not be optimized away
and updates the places where I memset() right before a free() call
to use it.
2013-06-07 09:54:33 -07:00
Edward Thomson
c37fb41ae0 qsort_r appeared in glibc 2.8 2013-05-25 12:35:55 -04:00
Edward Thomson
25a899ec84 qsort_r is broken on HURD, avoid 2013-05-24 10:32:26 +00:00
Sebastian Bauer
7f8cf6fefd Fixed qsort_r() problem when targeting AmigaOS.
We fall back to the libgit2-provided insert sort as done for other
platforms.
2013-05-07 09:15:12 +02:00
Edward Thomson
eb63fda2e2 git_atomic_ssize for 64-bit atomics only on 64-bit platforms 2013-04-25 12:40:33 -05:00
Vicent Marti
a2378ae4fe opts: Add getter for cached memory 2013-04-23 20:42:29 +02:00
Vicent Marti
a14163a79d cache: Shared meter for memory usage 2013-04-22 17:30:49 +02:00
Vicent Marti
d877159260 cache: Max cache size, and evict when the cache fills up 2013-04-22 17:04:52 +02:00
Russell Belfer
b12b72ea82 Add range checking around cache opts
Add a git_cache_set_max_object_size method that does more checking
around setting the max object size.  Also add a git_cache_size to
read the number of objects currently in the cache.  This makes it
easier to write tests.
2013-04-22 16:50:51 +02:00
Vicent Marti
ee12272d17 Global option setters 2013-04-22 16:50:51 +02:00
Vicent Marti
5df184241a lol this worked first try wtf 2013-04-22 16:50:50 +02:00
Carlos Martín Nieto
872ca1d302 Fix compilation on OpenBSD 2013-04-15 20:00:42 +02:00
Michael Schubert
f5e28202cb opts: allow configuration of odb cache size
Currently, the odb cache has a fixed size of 128 slots as defined by
GIT_DEFAULT_CACHE_SIZE. Allow users to set the size of the cache via
git_libgit2_opts().

Fixes #1035.
2013-03-25 15:45:56 +01:00
Russell Belfer
324602514f Fixes and cleanups
Get rid of some dead code, tighten things up a bit, and fix a bug
with core::env test.
2013-03-18 15:54:35 -07:00
Russell Belfer
41954a49c1 Switch search paths to classic delimited strings
This switches the APIs for setting and getting the global/system
search paths from using git_strarray to using a simple string with
GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment
PATH variable would contain.  This makes it simpler to get and set
the value.

I also added code to expand "$PATH" when setting a new value to
embed the old value of the path.  This means that I no longer
require separate actions to PREPEND to the value.
2013-03-18 14:19:35 -07:00
Russell Belfer
5540d9477e 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.
2013-03-15 16:39:00 -07:00
Vicent Marti
ad003763cc MSVC: What could possibly be the size of a void*? 2013-03-12 20:36:35 +01:00
Russell Belfer
62beacd300 Sorting function cleanup and MinGW fix
Clean up some sorting function stuff including fixing qsort_r
on MinGW, common function pointer type for comparison, and basic
insertion sort implementation (which we, regrettably, fall back
on for MinGW).
2013-03-11 16:43:58 -07:00
Russell Belfer
e40f1c2d23 Make tree iterator handle icase equivalence
There is a serious bug in the previous tree iterator implementation.
If case insensitivity resulted in member elements being equivalent
to one another, and those member elements were trees, then the
children of the colliding elements would be processed in sequence
instead of in a single flattened list.  This meant that the tree
iterator was not truly acting like a case-insensitive list.

This completely reworks the tree iterator to manage lists with
case insensitive equivalence classes and advance through the items
in a unified manner in a single sorted frame.

It is possible that at a future date we might want to update this
to separate the case insensitive and case sensitive tree iterators
so that the case sensitive one could be a minimal amount of code
and the insensitive one would always know what it needed to do
without checking flags.

But there would be so much shared code between the two, that I'm
not sure it that's a win.  For now, this gets what we need.

More tests are needed, though.
2013-03-08 16:39:57 -08:00
Philip Kelley
11d9f6b304 Vector improvements and their fallout 2013-01-27 14:17:07 -05:00
Vicent Marti
a0f777c87f opts: Add getters too 2013-01-23 23:44:34 +01:00
Vicent Marti
59853eff99 Global options setter 2013-01-23 02:58:58 +01:00
Russell Belfer
851ad65081 Add payload "_r" versions of bsearch and tsort
git__bsearch and git__tsort did not pass a payload through to the
comparison function.  This makes it impossible to implement sorted
lists where the sort order depends on external data (e.g. building
a secondary sort order for the entries in a tree).  This commit
adds git__bsearch_r and git__tsort_r versions that pass a third
parameter to the cmp function of a user payload.
2013-01-15 09:51:35 -08:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00