summaryrefslogtreecommitdiff
path: root/src/util.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge remote-tracking branch 'arrbee/minor-paranoia' into developmentVicent Marti2013-06-121-3/+8
|\
| * Add safe memset and use itRussell Belfer2013-06-071-3/+8
| | | | | | | | | | | | 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.
* | Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+2
|/ | | | | | | | | | | | | | | | | | This is a significant reorganization of the diff code to break it into a set of more clearly distinct files and to document the new organization. Hopefully this will make the diff code easier to understand and to extend. This adds a new `git_diff_driver` object that looks of diff driver information from the attributes and the config so that things like function content in diff headers can be provided. The full driver spec is not implemented in the commit - this is focused on the reorganization of the code and putting the driver hooks in place. This also removes a few #includes from src/repository.h that were overbroad, but as a result required extra #includes in a variety of places since including src/repository.h no longer results in pulling in the whole world.
* Fix issues with git_diff_find_similarRussell Belfer2013-05-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a number of bugs in the rename code that only were obvious when I started testing it against large old repos with more complex patterns. (The code to do that testing is not ready to merge with libgit2, but I do plan to add more thorough tests.) This contains a significant number of changes and also tweaks the public API slightly to make emulating core git easier. Most notably, this separates the GIT_DIFF_FIND_AND_BREAK_REWRITES flag into FIND_REWRITES (which adds a self-similarity score to every modified file) and BREAK_REWRITES (which splits the modified deltas into add/remove pairs in the diff list). When you do a raw output of core git, rewrites show up as M090 or such, not at A and D output, so I wanted to be able to emulate that. Publicly, this also changes the flags to be uint16_t since we don't need values out of that range. Internally, this contains significant changes from a number of small bug fixes (like using the wrong side of the diff to decide if the object could be found in the ODB vs the workdir) to larger issues about which files can and should be compared and how the various edge cases of similarity scores should be treated. Honestly, I don't think this is the last update that will have to be made to this code, but I think this moves us closer to correct behavior and I tried to document the code so it would be easier to follow..
* Unify whitespaces to tabsLinquize2013-05-151-4/+4
|
* Make refcounting atomicCarlos Martín Nieto2013-04-221-4/+4
|
* Add git__compare_and_swap and use itRussell Belfer2013-04-221-19/+0
| | | | | | | This removes the lock from the repository object and changes the internals to use the new atomic git__compare_and_swap to update the _odb, _config, _index, and _refdb variables in a threadsafe manner.
* Further threading fixesRussell Belfer2013-04-221-1/+20
| | | | | | | | | | | | | This builds on the earlier thread safety work to make it so that setting the odb, index, refdb, or config for a repository is done in a threadsafe manner with minimized locking time. This is done by adding a lock to the repository object and using it to guard the assignment of the above listed pointers. The lock is only held to assign the pointer value. This also contains some minor fixes to the other work with pack files to reduce the time that locks are being held to and fix an apparently memory leak.
* Move refdb_backend to include/git2/sysRussell Belfer2013-04-211-0/+2
| | | | | | | | | This moves most of the refdb stuff over to the include/git2/sys directory, with some minor shifts in function organization. While I was making the necessary updates, I also removed the trailing whitespace in a few files that I modified just because I was there and it was bugging me.
* Sorting function cleanup and MinGW fixRussell Belfer2013-03-111-5/+7
| | | | | | | 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/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* signature: Shut up MSVC, you silly gooseVicent Marti2013-02-201-0/+15
|
* Use malloc rather than callocBen Straub2013-02-011-1/+2
|
* Introduce git__substrdupBen Straub2013-02-011-5/+9
|
* Vector improvements and their falloutPhilip Kelley2013-01-271-1/+4
|
* Add payload "_r" versions of bsearch and tsortRussell Belfer2013-01-151-2/+18
| | | | | | | | | 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
|
* fetchhead reading/iteratingEdward Thomson2012-12-191-0/+1
|
* Create internal strcmp variants for function ptrsRussell Belfer2012-11-141-0/+5
| | | | | | Using the builtin strcmp and strcasecmp as function pointers is problematic on win32. This adds internal implementations and divorces us from the platform linkage.
* Some diff refactorings to help code reuseRussell Belfer2012-11-091-0/+5
| | | | | | | | | | | | | | | | | There are some diff functions that are useful in a rewritten checkout and this lays some groundwork for that. This contains three main things: 1. Share the function diff uses to calculate the OID for a file in the working directory (now named `git_diff__oid_for_file` 2. Add a `git_diff__paired_foreach` function to iterator over two diff lists concurrently. Convert status to use it. 3. Move all the string/prefix/index entry comparisons into function pointers inside the `git_diff_list` object so they can be switched between case sensitive and insensitive versions. This makes them easier to reuse in various functions without replicating logic. As part of this, move a couple of index functions out of diff.c and into index.c.
* Fix implementation of strndup to not overrunPhilip Kelley2012-11-091-5/+6
|
* Support for core.ignorecasePhilip Kelley2012-09-171-0/+7
|
* Add git_buf_unescape and git__unescape to unescape all characters in a ↵yorah2012-07-241-0/+9
| | | | string (in-place)
* Merge pull request #812 from arrbee/assorted-tweaksVicent Martí2012-07-121-1/+1
|\ | | | | Assorted goodies
| * Adding unicode space to match crlf patternsRussell Belfer2012-07-101-1/+1
| | | | | | | | | | Adding 0x85 to `git__isspace` since we also look for that in filter.c as a whitespace character.
* | util: add git__isdigit()nulltoken2012-07-071-0/+5
|/
* revparse: fix parsing of date specifiersnulltoken2012-07-021-7/+0
|
* Move git__date_parse declaration to util.h.Ben Straub2012-06-061-0/+10
|
* Merge branch 'development' into rev-parseBen Straub2012-06-051-0/+14
|\ | | | | | | | | | | Conflicts: src/util.h tests-clar/refs/branches/listall.c
| * global: Change parameter ordering in APIVicent Martí2012-05-181-0/+9
| | | | | | | | Consistency is good.
| * Ranged iterators and rewritten git_status_fileRussell Belfer2012-05-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this work is to rewrite git_status_file to use the same underlying code as git_status_foreach. This is done in 3 phases: 1. Extend iterators to allow ranged iteration with start and end prefixes for the range of file names to be covered. 2. Improve diff so that when there is a pathspec and there is a common non-wildcard prefix of the pathspec, it will use ranged iterators to minimize excess iteration. 3. Rewrite git_status_file to call git_status_foreach_ext with a pathspec that covers just the one file being checked. Since ranged iterators underlie the status & diff implementation, this is actually fairly efficient. The workdir iterator does end up loading the contents of all the directories down to the single file, which should ideally be avoided, but it is pretty good.
* | Fix date.c build in msvc.Ben Straub2012-05-151-1/+1
| | | | | | | | | | | | Ported the win32 implementations of gmtime_r, localtime_r, and gettimeofday to be part of the posix compatibility layer, and fixed git_signature_now to use them.
* | Rev-parse: @{time} syntax.Ben Straub2012-05-111-0/+7
|/ | | | | | Ported date.c (for approxidate_careful) from git.git revision aa39b85. Trimmed out the parts we're not using.
* util: Fix git__isspace() implementationnulltoken2012-05-091-1/+1
| | | | | | The characters <space>, <form-feed>, <newline>, <carriage-return>, <tab>, and <vertical-tab> are part of the "space" definition. cf. http://www.kernel.org/doc/man-pages/online/pages/man5/locale.5.html
* msvc: Do not use `isspace` Vicent Martí2012-05-091-0/+15
| | | | Locale-aware bullshit bitting my ass again yo
* Remove old and unused error codesVicent Martí2012-05-021-2/+0
|
* Moving power-of-two bit utilities into util.hRussell Belfer2012-04-251-0/+17
|
* error-handling: On-disk config file backendVicent Martí2012-03-091-11/+5
| | | | | | | | | | | | | | | Includes: - Proper error reporting when encountering syntax errors in a config file (file, line number, column). - Rewritten `config_write`, now with 99% less goto-spaghetti - Error state in `git_filebuf`: filebuf write functions no longer need to be checked for error returns. If any of the writes performed on a buffer fail, the last call to `git_filebuf_commit` or `git_filebuf_hash` will fail accordingly and set the appropiate error message. Baller!
* Migrating diff to new error handlingRussell Belfer2012-03-061-0/+5
| | | | | | Ended up migrating a bunch of upstream functions as well including vector, attr_file, and odb in order to get this to work right.
* error-handling: RepositoryVicent Martí2012-03-071-5/+7
| | | | | | | | This also includes droping `git_buf_lasterror` because it makes no sense in the new system. Note that in most of the places were it has been dropped, the code needs cleanup. I.e. GIT_ENOMEM is going away, so instead it should return a generic `-1` and obviously not throw anything.
* util: add git__ishexschu2012-02-151-0/+9
| | | | | | git__ishex allows to check if a string is a hexadecimal representation. Signed-off-by: schu <schu-github@schulog.org>
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Patch cleanup for mergeRussell Belfer2012-01-161-1/+1
| | | | | | | | | | After reviewing the gitignore support with Vicent, we came up with a list of minor cleanups to prepare for merge, including: * checking git_repository_config error returns * renaming git_ignore_is_ignored and moving to status.h * fixing next_line skipping to include \r skips * commenting on where ignores are and are not included
* Initial implementation of gitignore supportRussell Belfer2012-01-111-0/+7
| | | | | | | | Adds support for .gitignore files to git_status_foreach() and git_status_file(). This includes refactoring the gitattributes code to share logic where possible. The GIT_STATUS_IGNORED flag will now be passed in for files that are ignored (provided they are not already in the index or the head of repo).
* Merge remote-tracking branch 'nulltoken/topix/path_fromurl' into developmentVicent Martí2012-01-041-0/+23
|\ | | | | | | | | | | Conflicts: tests-clay/clay.h tests-clay/clay_main.c
| * util: add git__fromhex()nulltoken2011-12-281-0/+23
| |
* | Improved gitattributes macro implementationRussell Belfer2011-12-301-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Add support for macros and cache flush API.Russell Belfer2011-12-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for git attribute macro definitions. Also, add support for cache flush API to clear the attribute file content cache when needed. Additionally, improved the handling of global and system files, making common utility functions in fileops and converting config and attr to both use the common functions. Adds a bunch more tests and fixed some memory leaks. Note that adding macros required me to use refcounted attribute assignment definitions, which complicated, but probably improved memory usage.
* | Add APIs for git attributesRussell Belfer2011-12-201-0/+1
|/ | | | | | | | | This adds APIs for querying git attributes. In addition to the new API in include/git2/attr.h, most of the action is in src/attr_file.[hc] which contains utilities for dealing with a single attributes file, and src/attr.[hc] which contains the implementation of the APIs that merge all applicable attributes files.
* util: Remove unused macroVicent Marti2011-11-261-19/+0
|