summaryrefslogtreecommitdiff
path: root/src/crlf.c
Commit message (Collapse)AuthorAgeFilesLines
* crlf: give Unix the glory of autocrlf=trueEdward Thomson2015-06-221-13/+14
| | | | | Perform LF->CRLF for core.autocrlf=true on non-Win32 because core git does.
* crlf: use statistics to control to workdir filterEdward Thomson2015-06-221-4/+25
| | | | | Use statistics (like core git) to control the behavior of the to workdir CRLF filter.
* git_filter_opt_t -> git_filter_flag_tEdward Thomson2015-02-191-1/+1
| | | | | For consistency with the rest of the library, where an opt is an options *structure*.
* Check for OOMJacques Germishuys2014-12-301-0/+2
|
* Update text=auto / core.autocrlf=false behaviorEdward Thomson2014-06-241-1/+2
| | | | | | | Git for Windows 1.9.4 changed the behavior when the text=auto attribute is specified and core.autocrlf=false. Previous observed behavior would *not* filter files when going into the working directory, the new behavior *does* filter. Update our behavior to match.
* Just don't CRLF filter if there are no CRsrb/safecrlf-on-lf-platformRussell Belfer2014-05-191-3/+5
|
* Make core.safecrlf work on LF-ending platformsRussell Belfer2014-05-191-1/+3
| | | | | | If you enabled core.safecrlf on an LF-ending platform, we would error even for files with all LFs. We should only be warning on irreversible mappings, I think.
* Add filter options and ALLOW_UNSAFERussell Belfer2014-05-061-4/+19
| | | | | | | | | Diff and status do not want core.safecrlf to actually raise an error regardless of the setting, so this extends the filter API with an additional options flags parameter and adds a flag so that filters can be applied with GIT_FILTER_OPT_ALLOW_UNSAFE, indicating that unsafe filter application should be downgraded from a failure to a warning.
* Determine crlf safety by statistics, not literal reversibilityEdward Thomson2014-04-071-24/+9
|
* Introduce core.safecrlf handlingEdward Thomson2014-04-071-2/+32
|
* Never convert CRLF->LFEdward Thomson2014-02-111-17/+4
| | | | Core git performs no conversion on systems that use LF, emulate that.
* core.autocrlf=input w/ text=auto attr to workdirEdward Thomson2014-02-091-1/+7
|
* index: rename an entry's id to 'id'Carlos Martín Nieto2014-01-251-1/+1
| | | | This was not converted when we converted the rest, so do it now.
* Fix incorrect return code in crlf filterRussell Belfer2013-09-241-2/+2
| | | | | | The git_buf_text_gather_stats call returns a boolean indicating if the file looks like binary data. That shouldn't be an error; it should be used to skip CRLF processing though.
* Bug fixes and cleanupsRussell Belfer2013-09-171-9/+9
| | | | | | | | | | | | | 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.
* Move binary check to CRLF filter itselfRussell Belfer2013-09-171-0/+4
| | | | | | | | | | | | Checkout should not reject binary files from filters, as a filter may actually wish to operate on binary files. The CRLF filter should reject binary files itself if it wishes to. Moreover, the CRLF filter requires this logic so that users can emulate the checkout data in their odb -> workdir filtering. Conflicts: src/checkout.c src/crlf.c
* Merge git_buf and git_bufferRussell Belfer2013-09-171-28/+14
| | | | | | | | | | | 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-6/+1
| | | | | | | 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-4/+10
| | | | | | | | 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-4/+9
| | | | | This updates the git filter registry to be a little cleaner and plugs some memory leaks.
* Extend public filter api with filter listsRussell Belfer2013-09-171-4/+3
| | | | | | | | | | | 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-39/+16
| | | | | | | | | | | | | | | | | | 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-5/+10
|
* Create public filter object and use itRussell Belfer2013-09-171-70/+101
| | | | | | | 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.
* Start of filter API + git_blob_filtered_contentRussell Belfer2013-09-171-8/+12
| | | | | | | | | | This begins the process of exposing git_filter objects to the public API. This includes: * new public type and API for `git_buffer` through which an allocated buffer can be passed to the user * new API `git_blob_filtered_content` * make the git_filter type and GIT_FILTER_TO_... constants public
* Reorganize diff and add basic diff driverRussell Belfer2013-06-101-2/+4
| | | | | | | | | | | | | | | | | | 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.
* Move crlf conversion into buf_textautocrlf-fixesRussell Belfer2013-03-251-63/+17
| | | | | | | | | | | | | | This adds crlf/lf conversion functions into buf_text with more efficient implementations that bypass the high level buffer functions. They attempt to minimize the number of reallocations done and they directly write the buffer data as needed if they know that there is enough memory allocated to memcpy data. Tests are added for these new functions. The crlf.c code is updated to use the new functions. Removed the include of buf_text.h from filter.h and just include it more narrowly in the places that need it.
* don't convert CRLF to CRCRLFEdward Thomson2013-03-251-4/+9
|
* Add has_cr_in_index check to CRLF filterRussell Belfer2013-03-251-8/+51
| | | | | | | | | | | | This adds a check to the drop_crlf filter path to check it the file in the index already has a CR in it, in which case this will not drop the CRs from the workdir file contents. This uncovered a "bug" in `git_blob_create_fromworkdir` where the full path to the file was passed to look up the attributes instead of the relative path from the working directory root. This meant that the check in the index for a pre-existing entry of the same name was failing.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Consolidate text buffer functionsRussell Belfer2012-11-281-8/+5
| | | | | | | | | | | | | 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).
* Add git_repository_hashfile to hash with filtersRussell Belfer2012-09-111-2/+3
| | | | | | | | The existing `git_odb_hashfile` does not apply text filtering rules because it doesn't have a repository context to evaluate the correct rules to apply. This adds a new hashfile function that will apply repository-specific filters (based on config, attributes, and filename) before calculating the hash.
* Alternate test for autocrlf with statusRussell Belfer2012-09-061-1/+1
| | | | | I couldn't get the last failing test to actually fail. This is a different test suggested by @nulltoken which should fail.
* Checkout: crlf filter.Ben Straub2012-07-311-8/+80
|
* Checkout: obey core.symlinks.Ben Straub2012-07-171-1/+1
|
* Checkout: add structure for CRLF.Ben Straub2012-07-091-2/+18
|
* errors: Rename error codesbreaking-changesVicent Martí2012-05-181-1/+1
|
* errors: Rename the generic return codesVicent Martí2012-05-181-3/+3
|
* global: Change parameter ordering in APIVicent Martí2012-05-181-3/+3
| | | | Consistency is good.
* Support reading attributes from indexRussell Belfer2012-05-031-1/+2
| | | | | | | | | | | | | | Depending on the operation, we need to consider gitattributes in both the work dir and the index. This adds a parameter to all of the gitattributes related functions that allows user control of attribute reading behavior (i.e. prefer workdir, prefer index, only use index). This fix also covers allowing us to check attributes (and hence do diff and status) on bare repositories. This was a somewhat larger change that I hoped because it had to change the cache key used for gitattributes files.
* Remove old and unused error codesVicent Martí2012-05-021-2/+1
|
* buf: deploy git_buf_len()nulltoken2012-04-301-2/+2
|
* error-handling: RepositoryVicent Martí2012-03-071-2/+1
| | | | | | | | 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.
* Add filter tests and fix some bugsRussell Belfer2012-03-021-40/+20
| | | | | 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-2/+10
|
* attr: Change the attribute check macrosVicent Martí2012-03-021-4/+4
| | | | | | | | | | | | | | | | | | | | | The point of having `GIT_ATTR_TRUE` and `GIT_ATTR_FALSE` macros is to be able to change the way that true and false values are stored inside of the returned gitattributes value pointer. However, if these macros are implemented as a simple rename for the `git_attr__true` pointer, they will always be used with the `==` operator, and hence we cannot really change the implementation to any other way that doesn't imply using special pointer values and comparing them! We need to do the same thing that core Git does, which is using a function macro. With `GIT_ATTR_TRUE(attr)`, we can change internally the way that these values are stored to anything we want. This commit does that, and rewrites a large chunk of the attributes test suite to remove duplicated code for expected attributes, and to properly test the function macro behavior instead of comparing pointers.
* filter: Beautiful refactoringVicent Martí2012-03-011-34/+82
| | | | Comments soothe my soul.
* filter: Add write-to CRLF filterVicent Martí2012-02-291-0/+193