src/util.c


Log

Author Commit Date CI Message
Krishna Ram Prakash R 70b9b841 2016-06-28T20:19:52 Fixed bug while parsing INT64_MIN
Edward Thomson d34f6826 2014-04-08T17:18:47 Patch parsing from patch files
Edward Thomson e683d152 2015-09-30T05:49:04 qsort_r/qsort_s: detect their support
John Haley eba784d2 2015-08-05T10:19:06 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
Edward Thomson e069c621 2015-07-02T09:25:48 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).
Edward Thomson 75a4636f 2015-05-29T16:56:38 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.
Edward Thomson 006548da 2015-05-29T16:07:51 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.
Edward Thomson ec510666 2015-02-10T15:10:32 Credit utf8proc for utf8 iterator
Vicent Marti 8e35527d 2014-12-16T13:03:02 path: Use UTF8 iteration for HFS chars
Edward Thomson a64119e3 2014-11-25T18:13:00 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.
Jacques Germishuys 491ad0de 2014-07-05T21:26:35 qsort_r is only available from Visual Studio 2005+
Jacques Germishuys 90a4340a 2014-04-30T11:47:58 cygwin also doesn't have qsort_r
Russell Belfer 3b4c401a 2014-02-10T13:20:08 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.
Edward Thomson e85bbd52 2014-01-14T14:41:49 Move libgit2 settings out of util
Brodie Rao 2fcc0d07 2014-01-12T23:32:10 util: handle NULL pointers passed to git_strarray_free() Signed-off-by: Brodie Rao <brodie@sf.io>
Jacques Germishuys 551f5cef 2014-01-08T13:47:47 Solaris does not have qsort_r
Alessandro Ghedini 963edd9b 2013-11-19T17:58:58 util: NetBSD doesn't have qsort_r either
Vicent Martí 3d4f1698 2013-09-17T10:21:22 Merge pull request #1858 from linquize/win32-template-dir Configurable template dir for Win32
Russell Belfer a9f51e43 2013-09-11T22:00:36 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.
Linquize b99b10f2 2013-09-17T23:38:52 Can git_libgit2_opts() with GIT_OPT_GET_TEMPLATE_PATH and GIT_OPT_SET_TEMPLATE_PATH
Krzysztof Adamski b1447ede 2013-09-01T18:47:56 Use git__insertsort_r on Android too.
Russell Belfer 290e1479 2013-07-09T16:17:41 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.
Russell Belfer c9b18018 2013-06-13T15:26:56 Fix some warnings
Edward Thomson e3b4a47c 2013-05-31T16:30:09 git__strcasesort_cmp: strcasecmp sorting rules but requires strict equality
yorah 3425fee6 2013-06-17T14:27:34 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.
Vicent Marti 6de9b2ee 2013-06-12T21:10:33 util: It's called `memzero`
Russell Belfer 3e9e6cda 2013-06-07T09:54:33 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.
Edward Thomson c37fb41a 2013-05-25T12:35:55 qsort_r appeared in glibc 2.8
Edward Thomson 25a899ec 2013-05-24T10:30:32 qsort_r is broken on HURD, avoid
Sebastian Bauer 7f8cf6fe 2013-05-07T09:15:12 Fixed qsort_r() problem when targeting AmigaOS. We fall back to the libgit2-provided insert sort as done for other platforms.
Edward Thomson eb63fda2 2013-04-25T11:52:17 git_atomic_ssize for 64-bit atomics only on 64-bit platforms
Vicent Marti a2378ae4 2013-04-23T20:42:29 opts: Add getter for cached memory
Vicent Marti a14163a7 2013-04-22T17:30:49 cache: Shared meter for memory usage
Vicent Marti d8771592 2013-04-22T17:04:52 cache: Max cache size, and evict when the cache fills up
Vicent Marti ee12272d 2013-04-05T22:48:39 Global option setters
Russell Belfer b12b72ea 2013-04-12T12:44:51 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.
Vicent Marti 5df18424 2013-04-01T19:38:23 lol this worked first try wtf
Carlos Martín Nieto 872ca1d3 2013-04-15T20:00:42 Fix compilation on OpenBSD
Michael Schubert f5e28202 2013-03-25T13:38:43 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.
Russell Belfer 32460251 2013-03-18T15:54:35 Fixes and cleanups Get rid of some dead code, tighten things up a bit, and fix a bug with core::env test.
Russell Belfer 41954a49 2013-03-18T14:19:35 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.
Russell Belfer 5540d947 2013-03-15T16:39:00 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.
Vicent Marti ad003763 2013-03-12T20:36:35 MSVC: What could possibly be the size of a void*?
Russell Belfer 62beacd3 2013-03-11T16:43:58 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).
Russell Belfer e40f1c2d 2013-03-08T16:39:57 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.
Philip Kelley 11d9f6b3 2013-01-27T14:17:07 Vector improvements and their fallout
Vicent Marti a0f777c8 2013-01-23T23:44:34 opts: Add getters too
Vicent Marti 59853eff 2013-01-23T02:58:58 Global options setter
Russell Belfer 851ad650 2013-01-09T16:00:16 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.
Edward Thomson 359fc2d2 2013-01-08T17:07:25 update copyrights
Martin Woodward 43464497 2013-01-03T22:24:10 Add full license notice to bsearch code 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.
Philip Kelley 853488ee 2013-01-03T08:45:09 Fix git__strncasecmp
Martin Woodward 0470f8fc 2013-01-03T22:24:10 Add full license notice to bsearch code 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.
Philip Kelley 0db4cd04 2013-01-03T08:45:09 Fix git__strncasecmp
Edward Thomson 7fcec834 2012-12-11T22:31:21 fetchhead reading/iterating
Michael Schubert 101659be 2012-12-17T15:50:12 Fix -Wmaybe-uninitialized warning
Russell Belfer 91e7d263 2012-12-10T15:29:44 Fix iterator reset and add reset ranges The `git_iterator_reset` command has not been working in all cases particularly when there is a start and end range. This fixes it and adds tests for it, and also extends it with the ability to update the start/end range strings when an iterator is reset.
Russell Belfer 16248ee2 2012-11-21T11:03:07 Fix up some missing consts in tree & index This fixes some missed places where we can apply const-ness to various public APIs. There are still some index and tree APIs that cannot take const pointers because we sort our `git_vectors` lazily and so we can't reliably bsearch the index and tree content without applying a `git_vector_sort()` first. This also fixes some missed places where size_t can be used and where const can be applied to a couple internal functions.
Russell Belfer a277345e 2012-11-14T22:37:13 Create internal strcmp variants for function ptrs Using the builtin strcmp and strcasecmp as function pointers is problematic on win32. This adds internal implementations and divorces us from the platform linkage.
Carlos Martín Nieto 47db054d 2012-11-13T13:41:01 config: distinguish between a lone variable name and one without rhs '[section] variable' and '[section] variable =' behave differently when parsed as booleans, so we need to store that distinction internally.
Philip Kelley ec40b7f9 2012-09-17T15:42:41 Support for core.ignorecase
Carlos Martín Nieto 3ce22c74 2012-08-26T19:22:34 http: use WinHTTP on Windows Wondows has its own HTTP library. Use that one when possible instead of our own. As we don't depend on them anymore, remove the http-parser library from the Windows build, as well as the search for OpenSSL.
Sascha Cunz e564e496 2012-08-01T20:02:32 Add function to query for compile time settings.
yorah 02a0d651 2012-07-12T16:31:59 Add git_buf_unescape and git__unescape to unescape all characters in a string (in-place)
Adam Roben 8e60c712 2012-06-07T09:50:19 Fix git_status_file for files that start with a character > 0x7f git_status_file would always return GIT_ENOTFOUND for these files. The underlying bug was that git__strcmp_cb, which is used by git_path_with_stat_cmp to sort entries in the working directory, compares strings based on unsigned chars (this is confirmed by the strcmp(3) manpage), while git__prefixcmp, which is used by workdir_iterator__entry_cmp to search for a path in the working directory, compares strings based on char. So the sort puts this path at the end of the list, while the search expects it to be at the beginning. The fix was simply to make git__prefixcmp compare using unsigned chars, just like strcmp(3). The rest of the change is just adding/updating tests.
Vicent Martí 29e948de 2012-05-10T10:38:10 global: Change parameter ordering in API Consistency is good.
Vicent Martí 0f49200c 2012-05-09T04:37:02 msvc: Do not use `isspace` Locale-aware bullshit bitting my ass again yo
Vicent Martí 3fbcac89 2012-05-02T19:56:38 Remove old and unused error codes
Russell Belfer 44ef8b1b 2012-04-13T13:00:10 Fix warnings on 64-bit windows builds This fixes all the warnings on win64 except those in deps, which come from the regex code.
Russell Belfer 14a513e0 2012-04-13T15:00:29 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.
Russell Belfer 7c7ff7d1 2012-03-19T16:10:11 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.
Russell Belfer 0d0fa7c3 2012-03-16T15:56:01 Convert attr, ignore, mwindow, status to new errors Also cleaned up some previously converted code that still had little things to polish.
Russell Belfer ae9e29fd 2012-03-06T16:14:31 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.
schu 5e0de328 2012-02-13T17:10:24 Update Copyright header Signed-off-by: schu <schu-github@schulog.org>
Russell Belfer 83bfbdf5 2012-01-16T18:00:18 Remove poor git__removechar function Going back over this, the git__removechar function was not needed (only invoked once) and is actually mislabeled. As implemented, it really only made sense for removing backslash characters, since two of the "removed" characters in a row would include the second one -- i.e. it really implements stripping backslash-escaped strings where a backslash allows internal whitespace in a word.
Russell Belfer a51cd8e6 2012-01-16T16:58:27 Fix handling of relative paths for attrs Per issue #533, the handling of relative paths in attribute and ignore files was not right. Fixed this by pre-joining the relative path of the attribute/ignore file onto the match string when a full path match is required. Unfortunately, fixing this required a bit more code than I would have liked because I had to juggle things around so that the fnmatch parser would have sufficient information to prepend the relative path when it was needed.
Russell Belfer bd370b14 2011-12-30T15:00:14 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.
Vicent Marti 3286c408 2011-10-28T14:51:13 global: Properly use `git__` memory wrappers Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
Vicent Marti fafd4710 2011-09-30T16:08:06 config: Proper type declarations for 64 bit ints
nulltoken ad196c6a 2011-09-21T23:17:39 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>
Vicent Marti 87d9869f 2011-09-19T03:34:49 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.
Vicent Marti bb742ede 2011-09-19T01:54:32 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.
Sebastian Schuberth 26e74c6a 2011-09-08T14:21:17 Fix some random size_t vs. int conversion warnings
Vicent Marti 84dd3820 2011-08-18T02:13:51 posix: Properly handle `snprintf` in all platforms
nulltoken d1f34693 2011-08-09T12:07:47 util: Add git__strcmp_cb() wrapper We don't want direct pointers to the CRT on Windows, we may get stdcall conflicts.
nulltoken ae2e4c6a 2011-07-09T08:41:02 win32: replace usage of _MSV_VER with _MSC_VER
Vicent Marti de18f276 2011-07-07T01:46:20 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.
Vicent Martí bf9a2e98 2011-07-06T10:55:06 Merge pull request #296 from kiryl/index-optimization Index optimization
Vicent Marti e9c6571d 2011-07-06T01:04:04 fnmatch: Use native on Unix, emulate on Win32
Kirill A. Shutemov c20ffa61 2011-07-01T00:34:23 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>
Vicent Martí f12aa9dc 2011-07-05T04:31:37 Merge pull request #300 from carlosmn/gsoc2011/master A bit of networking
Vicent Marti f79026b4 2011-07-04T11:43:34 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.
Kirill A. Shutemov 932d1baf 2011-06-30T19:52:34 cleanup: remove trailing spaces Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Carlos Martín Nieto 63f91e1c 2011-06-22T16:52:30 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>
Vicent Marti 536955f9 2011-06-16T02:21:33 Add method to get the compiled version of the lib
Vicent Marti 0291b5b7 2011-06-03T19:59:16 odb: Fix loading ODB alternates Fixed an issue with the `strtokz implementation and added support for comments and relative paths in the alternates file.
nulltoken 3a1c4310 2011-05-24T18:55:35 Fix compilation warnings in MSVC This allows to successfully build libgit2 with waf on Windows.
Jakob Pfender 33b1d19e 2011-05-19T15:13:40 util.c: Move to new error handling mechanism
Vicent Marti 0da2c700 2011-05-17T15:09:30 utils: Move git__str[n]tolower
Vicent Marti c6e65aca 2011-04-09T15:22:11 Properly check `strtol` for errors We are now using a custom `strtol` implementation to make sure we're not missing any overflow errors.