summaryrefslogtreecommitdiff
path: root/src/util.c
Commit message (Collapse)AuthorAgeFilesLines
* qsort_r/qsort_s: detect their supportEdward Thomson2015-09-301-13/+8
|
* Fix duplicate basenames to support older VSJohn Haley2015-08-051-1/+1
| | | | | | | 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
* git__getenv: utf-8 aware env readerEdward Thomson2015-07-021-0/+48
| | | | | | 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).
* git__tolower: a tolower() that isn't dumbEdward Thomson2015-05-291-9/+9
| | | | | | | | 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.
* git__strcasecmp: treat input bytes as unsignedEdward Thomson2015-05-291-2/+2
| | | | | | 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.
* Credit utf8proc for utf8 iteratorEdward Thomson2015-02-101-0/+25
|
* path: Use UTF8 iteration for HFS charsVicent Marti2014-12-161-0/+76
|
* checkout: disallow bad paths on win32Edward Thomson2014-12-161-0/+15
| | | | | | | | | | | | | | | 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.
* qsort_r is only available from Visual Studio 2005+Jacques Germishuys2014-07-061-1/+2
|
* cygwin also doesn't have qsort_rJacques Germishuys2014-04-301-1/+1
|
* Decouple index iterator sort from indexRussell Belfer2014-04-171-3/+5
| | | | | | | | 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.
* Move libgit2 settings out of utilEdward Thomson2014-01-141-123/+0
|
* util: handle NULL pointers passed to git_strarray_free()Brodie Rao2014-01-121-0/+4
| | | | Signed-off-by: Brodie Rao <brodie@sf.io>
* Solaris does not have qsort_rJacques Germishuys2014-01-081-0/+1
|
* util: NetBSD doesn't have qsort_r eitherAlessandro Ghedini2013-11-191-1/+2
|
* Merge pull request #1858 from linquize/win32-template-dirVicent Martí2013-09-171-0/+13
|\ | | | | Configurable template dir for Win32
| * Can git_libgit2_opts() with GIT_OPT_GET_TEMPLATE_PATH and ↵Linquize2013-09-181-0/+13
| | | | | | | | GIT_OPT_SET_TEMPLATE_PATH
* | Merge git_buf and git_bufferRussell Belfer2013-09-171-0/+3
|/ | | | | | | | | | | 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.
* Use git__insertsort_r on Android too.Krzysztof Adamski2013-09-011-1/+1
|
* Add GIT_CAP_SSH if library was built with SSHRussell Belfer2013-07-091-0/+3
| | | | | This also adds a test that actually calls git_libgit2_capabilities and git_libgit2_version.
* Fix some warningsRussell Belfer2013-06-171-9/+6
|
* git__strcasesort_cmp: strcasecmp sorting rules but requires strict equalityEdward Thomson2013-06-171-0/+25
|
* util: git__memzero() tweaksyorah2013-06-171-9/+0
| | | | | | | 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.
* util: It's called `memzero`Vicent Marti2013-06-121-3/+2
|
* Add safe memset and use itRussell Belfer2013-06-071-0/+10
| | | | | | 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.
* qsort_r appeared in glibc 2.8Edward Thomson2013-05-251-1/+2
|
* qsort_r is broken on HURD, avoidEdward Thomson2013-05-241-1/+2
|
* Fixed qsort_r() problem when targeting AmigaOS.Sebastian Bauer2013-05-071-1/+1
| | | | | We fall back to the libgit2-provided insert sort as done for other platforms.
* git_atomic_ssize for 64-bit atomics only on 64-bit platformsEdward Thomson2013-04-251-3/+3
|
* opts: Add getter for cached memoryvmg/atomic64Vicent Marti2013-04-231-0/+5
|
* cache: Shared meter for memory usageVicent Marti2013-04-221-2/+1
|
* cache: Max cache size, and evict when the cache fills upvmg/new-cacheVicent Marti2013-04-221-1/+5
|
* Add range checking around cache optsRussell Belfer2013-04-221-3/+5
| | | | | | | 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.
* Global option settersVicent Marti2013-04-221-0/+11
|
* lol this worked first try wtfVicent Marti2013-04-221-8/+0
|
* Fix compilation on OpenBSDCarlos Martín Nieto2013-04-151-1/+1
|
* opts: allow configuration of odb cache sizeMichael Schubert2013-03-251-0/+9
| | | | | | | | 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.
* Fixes and cleanupsRussell Belfer2013-03-181-53/+7
| | | | | Get rid of some dead code, tighten things up a bit, and fix a bug with core::env test.
* Switch search paths to classic delimited stringsRussell Belfer2013-03-181-15/+9
| | | | | | | | | | | | 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.
* Implement global/system file search pathsRussell Belfer2013-03-151-8/+98
| | | | | | | | | | | | | | | | | | | | | | | 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.
* MSVC: What could possibly be the size of a void*?Vicent Marti2013-03-121-1/+2
|
* Sorting function cleanup and MinGW fixRussell Belfer2013-03-111-6/+28
| | | | | | | 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).
* Make tree iterator handle icase equivalenceRussell Belfer2013-03-081-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Vector improvements and their falloutPhilip Kelley2013-01-271-6/+6
|
* opts: Add getters tooVicent Marti2013-01-231-2/+10
|
* Global options setterVicent Marti2013-01-231-0/+23
|
* Add payload "_r" versions of bsearch and tsortRussell Belfer2013-01-151-1/+32
| | | | | | | | | 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.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Add full license notice to bsearch codeMartin Woodward2013-01-031-1/+25
| | | | | | The original BSD glibc code contains the notice as given at http://opensource.apple.com/source/gcc/gcc-5666.3/libiberty/bsearch.c and should be given in full along with the code.
* Fix git__strncasecmpPhilip Kelley2013-01-031-7/+5
|