summaryrefslogtreecommitdiff
path: root/src/filter.c
Commit message (Collapse)AuthorAgeFilesLines
* Cleanups, renames, and leak fixesRussell Belfer2013-12-121-1/+1
| | | | | | | | | This renames git_vector_free_all to the better git_vector_free_deep and also contains a couple of memory leak fixes based on valgrind checks. The fixes are specifically: failure to free global dir path variables when not compiled with threading on and failure to free filters from the filter registry that had not be initialized fully.
* Fix warnings on Windows 64-bit buildRussell Belfer2013-09-231-3/+11
|
* Bug fixes and cleanupsRussell Belfer2013-09-171-6/+8
| | | | | | | | | | | | | This contains a few bug fixes and some header and API cleanups. The main API change is that filters should now use GIT_PASSTHROUGH to indicate that they wish to skip processing a file instead of GIT_ENOTFOUND. The bug fixes include a possible out-of-range buffer access in the ident filter, a filter ordering problem I introduced into the custom filter tests on Windows, and a filter buf NUL termination issue that was coming up on Linux.
* Some tests with ident and crlf filtersRussell Belfer2013-09-171-1/+1
| | | | | | | | | | | | | | Fixed the filter order to match core Git, too. This test demonstrates an interesting behavior of core Git (which is totally reasonable and which libgit2 matches, although mostly by coincidence). If you use the ident filter and commit a file with a garbage ident in it, like '$Id: this is just garbage$' and then immediately do a 'git checkout-index' with the new file, Git will not consider the file out of date and will not overwrite the file with an updated $Id$. Libgit2 has the same behavior. If you remove the file and then do a checkout-index, it will be replaced with a filtered version that has injected the OID correctly.
* Fix win32 warningsRussell Belfer2013-09-171-3/+3
| | | | | | I wish MSVC understood that "const char **" is not a const ptr, but it a non-const pointer to an array of const ptrs. Does that seem like too much to ask.
* Port tests from PR 1683Russell Belfer2013-09-171-0/+5
| | | | | | This ports over some of the tests from https://github.com/libgit2/libgit2/pull/1683 by @yorah and @ethomson
* Merge git_buf and git_bufferRussell Belfer2013-09-171-24/+24
| | | | | | | | | | | 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.
* Add ident filterRussell Belfer2013-09-171-2/+29
| | | | | | | This adds the ident filter (that knows how to replace $Id$) and tweaks the filter APIs and code so that git_filter_source objects actually have the updated OID of the object being filtered when it is a known value.
* Add functions to manipulate filter listsRussell Belfer2013-09-171-3/+49
| | | | | | | | Extend the git2/sys/filter API with functions to look up a filter and add it manually to a filter list. This requires some trickery because the regular attribute lookups and checks are bypassed when this happens, but in the right hands, it will allow a user to have granular control over applying filters.
* Update filter registry codeRussell Belfer2013-09-171-54/+113
| | | | | This updates the git filter registry to be a little cleaner and plugs some memory leaks.
* Hook up filter initialize callbackRussell Belfer2013-09-171-2/+32
| | | | I knew I forgot something
* Extend public filter api with filter listsRussell Belfer2013-09-171-51/+96
| | | | | | | | | | | This moves the git_filter_list into the public API so that users can create, apply, and dispose of filter lists. This allows more granular application of filters to user data outside of libgit2 internals. This also converts all the internal usage of filters to the public APIs along with a few small tweaks to make it easier to use the public git_buffer stuff alongside the internal git_buf.
* Add attributes to filters and fix registryRussell Belfer2013-09-171-20/+243
| | | | | | | | | | | | | | | | | | The filter registry as implemented was too primitive to actually work once multiple filters were coming into play. This expands the implementation of the registry to handle multiple prioritized filters correctly. Additionally, this adds an "attributes" field to a filter that makes it really really easy to implement filters that are based on one or more attribute values. The lookup and even simple value checking can all happen automatically without custom filter code. Lastly, with the registry improvements, this fills out the filter lifecycle callbacks, with initialize and shutdown callbacks that will be called before the filter is first used and after it is last invoked. This allows for system-wide initialization and cleanup by the filter.
* Make git_filter_source opaqueRussell Belfer2013-09-171-0/+27
|
* Create public filter object and use itRussell Belfer2013-09-171-33/+143
| | | | | | | This creates include/sys/filter.h with a basic definition of a git_filter and then converts the internal code to use it. There are related internal objects (git_filter_list) that we will want to publish at some point, but this is a first step.
* Several warnings detected by static code analyzer fixedArkadiy Shapkin2013-03-181-1/+2
| | | | | | | Implicit type conversion argument of function to size_t type Suspicious sequence of types castings: size_t -> int -> size_t Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)' Unsigned type is never < 0
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Consolidate text buffer functionsRussell Belfer2012-11-281-69/+0
| | | | | | | | | | | | | There are many scattered functions that look into the contents of buffers to do various text manipulations (such as escaping or unescaping data, calculating text stats, guessing if content is binary, etc). This groups all those functions together into a new file and converts the code to use that. This has two enhancements to existing functionality. The old text stats function is significantly rewritten and the BOM detection code was extended (although largely we can't deal with anything other than a UTF8 BOM).
* Update of text stats calculationJameson Miller2012-11-011-4/+0
| | | | | Do not interpret 0x85 as Next Line (NEL) char when gathering statistics for a text file.
* checkout : reduce memory usage when not filteringnulltoken2012-09-171-19/+0
|
* checkout: introduce git_checkout_tree()nulltoken2012-09-171-25/+9
|
* filter: fix memory leakBen Straub2012-07-211-0/+3
|
* Migrate code to git_filter_blob_contents.Ben Straub2012-07-161-0/+33
| | | | | | Also removes the unnecessary check for filter length, since git_filters_apply does the right thing when there are none, and it's more efficient than this.
* Checkout: add structure for CRLF.Ben Straub2012-07-091-3/+3
|
* errors: Rename the generic return codesVicent Martí2012-05-181-2/+2
|
* Remove old and unused error codesVicent Martí2012-05-021-4/+4
|
* Merge remote-tracking branch 'carlosmn/remaining-errors' into new-error-handlingVicent Martí2012-05-011-2/+2
|\ | | | | | | | | Conflicts: src/refspec.c
| * error handling: move the missing parts over to the new error handlingCarlos Martín Nieto2012-04-261-2/+2
| |
* | buf: deploy git_buf_len()nulltoken2012-04-301-5/+5
|/
* Implement git_pool paged memory allocatorRussell Belfer2012-04-251-1/+1
| | | | | | | | | | | | | | | | | | This adds a `git_pool` object that can do simple paged memory allocation with free for the entire pool at once. Using this, you can replace many small allocations with large blocks that can then cheaply be doled out in small pieces. This is best used when you plan to free the small blocks all at once - for example, if they represent the parsed state from a file or data stream that are either all kept or all discarded. There are two real patterns of usage for `git_pools`: either for "string" allocation, where the item size is a single byte and you end up just packing the allocations in together, or for "fixed size" allocation where you are allocating a large object (e.g. a `git_oid`) and you generally just allocation single objects that can be tightly packed. Of course, you can use it for other things, but those two cases are the easiest.
* Add filter tests and fix some bugsRussell Belfer2012-03-021-16/+15
| | | | | This adds some initial unit tests for file filtering and fixes some simple bugs in filter application.
* config: Implement a proper cvar cacheVicent Martí2012-03-021-50/+0
|
* filter: Beautiful refactoringVicent Martí2012-03-011-56/+60
| | | | Comments soothe my soul.
* filter: Properly cache filter settingsVicent Martí2012-03-011-2/+8
|
* filter: Precache the filter config options on loadVicent Martí2012-03-011-0/+41
|
* filter: Add write-to CRLF filterVicent Martí2012-02-291-93/+38
|
* filter: Load attributes for fileVicent Martí2012-02-281-0/+88
|
* filter: Apply filters before writing a file to the ODBVicent Martí2012-02-271-0/+132
Initial implementation. The relevant code is in `blob.c`: the blob write function has been split into smaller functions. - Directly write a file to the ODB in streaming mode - Directly write a symlink to the ODB in direct mode - Apply a filter, and write a file to the ODB in direct mode When trying to write a file, we first call `git_filter__load_for_file`, which populates a filters array with the required filters based on the filename. If no filters are resolved to the filename, we can write to the ODB in streaming mode straight from disk. Otherwise, we load the whole file in memory and use double-buffering to apply the filter chain. We finish by writing the file as a whole to the ODB.