summaryrefslogtreecommitdiff
path: root/src/blob.c
Commit message (Collapse)AuthorAgeFilesLines
* Reorganize diff and add basic diff driverRussell Belfer2013-06-101-0/+1
| | | | | | | | | | | | | | | | | | 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.
* object: Explicitly define helper API methods for all obj typesVicent Marti2013-04-301-2/+0
|
* Some cleanupsRussell Belfer2013-04-291-1/+1
| | | | | Removed useless prototype and renamed object typecast functions declaration macro.
* Standardize cast versions of git_object accessorsRussell Belfer2013-04-291-0/+2
| | | | | | This removes the GIT_INLINE versions of the simple git_object accessors and standardizes them with a helper macro in src/object.h to build the function bodies.
* Simplify object table parse functionsRussell Belfer2013-04-221-1/+1
| | | | | This unifies the object parse functions into one signature that takes an odb_object.
* Add callback to git_objects_tableRussell Belfer2013-04-221-4/+4
| | | | | | | | | | This adds create and free callback to the git_objects_table so that more of the creation and destruction of objects can be table driven instead of using switch statements. This also makes the semantics of certain object creation functions consistent so that we can make better use of function pointers. This also fixes a theoretical error case where an object allocation fails and we end up storing NULL into the cache.
* Use git_odb_object_data/_size whereever possibleRussell Belfer2013-04-221-3/+5
| | | | | This uses the odb object accessors so we can change the internals more easily...
* What has science done.Vicent Marti2013-04-221-5/+5
|
* Move odb_backend implementors stuff into git2/sysRussell Belfer2013-04-211-0/+1
| | | | | | | | | | | | This moves some of the odb_backend stuff that is related to the internals of an odb_backend implementation into include/git2/sys. Some of the stuff related to streaming I left in include/git2 because it seemed like it would be reasonably needed by a normal user who wanted to stream objects into and out of the ODB. Also, I added APIs for traversing the list of backends so that some of the tests would not need to access ODB internals.
* Move crlf conversion into buf_textautocrlf-fixesRussell Belfer2013-03-251-0/+1
| | | | | | | | | | | | | | 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.
* Add has_cr_in_index check to CRLF filterRussell Belfer2013-03-251-2/+12
| | | | | | | | | | | | 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
|
* Share git_diff_blobs/git_diff_blob_to_buffer codeRussell Belfer2013-01-071-2/+2
| | | | | | | This moves the implementation of these two APIs into common code that will be shared between the two. Also, this adds tests for the `git_diff_blob_to_buffer` API. Lastly, this adds some extra `const` to a few places that can use it.
* blob: introduce git_blob_is_binary()nulltoken2012-12-171-0/+12
|
* More external API cleanupVicent Marti2012-11-271-3/+3
| | | | | | Conflicts: src/branch.c tests-clar/refs/branches/create.c
* blob: do not create temp files in the current pathnulltoken2012-10-221-1/+10
| | | | | | | - make sure temporary streamed blobs are created under the .git/objects folder and not in the current path, whatever it is. - do not make the name of the temp file depend on the hintpath.
* Fix -Wuninitialized warningMichael Schubert2012-09-131-1/+1
|
* Merge branch 'diff-crlf-filters' into developmentVicent Marti2012-09-111-10/+9
|\
| * Properly handle p_readsVicent Marti2012-09-111-10/+9
| |
* | errors: deploy GIT_EBAREREPO usagenulltoken2012-09-061-1/+3
|/
* blob: add git_blob_create_fromchunks()nulltoken2012-06-071-11/+60
|
* blob: Add git_blob_create_fromdisk()nulltoken2012-05-131-16/+40
| | | | This function will create blobs in the object database from files anywhere on the filesystem. This can be run against bare and non-bare repositories.
* Implement git_pool paged memory allocatorRussell Belfer2012-04-251-2/+2
| | | | | | | | | | | | | | | | | | 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.
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-1/+1
| | | | | Also cleaned up some previously converted code that still had little things to polish.
* Continue error conversionRussell Belfer2012-03-141-63/+47
| | | | | | | This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
* Migrate ODB files to new error handlingRussell Belfer2012-03-121-1/+1
| | | | | | | | | | | | | | This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
* Add filter tests and fix some bugsRussell Belfer2012-03-021-0/+6
| | | | | This adds some initial unit tests for file filtering and fixes some simple bugs in filter application.
* filter: Beautiful refactoringVicent Martí2012-03-011-14/+20
| | | | Comments soothe my soul.
* filter: Add write-to CRLF filterVicent Martí2012-02-291-11/+13
|
* filter: Apply filters before writing a file to the ODBVicent Martí2012-02-271-48/+108
| | | | | | | | | | | | | | | | | | | | 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.
* Fix warnings about type conversion on win32Russell Belfer2012-02-231-3/+3
|
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* odb: Proper symlink hashingVicent Martí2012-02-101-25/+40
|
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-22/+29
| | | | | | | | | | | | | | | | | | | | This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
* Rename all `_close` methodsVicent Marti2011-11-261-1/+1
| | | | | There's no difference between `_free` and `_close` semantics: keep everything with the same name to avoid confusions.
* repository: Change ownership semanticsVicent Marti2011-11-261-5/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ownership semantics have been changed all over the library to be consistent. There are no more "borrowed" or duplicated references. Main changes: - `git_repository_open2` and `3` have been dropped. - Added setters and getters to hotswap all the repository owned objects: `git_repository_index` `git_repository_set_index` `git_repository_odb` `git_repository_set_odb` `git_repository_config` `git_repository_set_config` `git_repository_workdir` `git_repository_set_workdir` Now working directories/index files/ODBs and so on can be hot-swapped after creating a repository and between operations. - All these objects now have proper ownership semantics with refcounting: they all require freeing after they are no longer needed (the repository always keeps its internal reference). - Repository open and initialization has been updated to keep in mind the configuration files. Bare repositories are now always detected, and a default config file is created on init. - All the tests affected by these changes have been dropped from the old test suite and ported to the new one.
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-1/+1
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* Cleanup legal dataVicent Marti2011-09-191-21/+3
| | | | | | | | | | 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.
* Fix some random size_t vs. int conversion warningsSebastian Schuberth2011-09-081-1/+1
|
* fileops: CleanupVicent Marti2011-07-051-8/+8
| | | | | | | | | | | | | | | | 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.
* git_blob_create_fromfile: remove old codeschu2011-06-271-16/+5
| | | | | | | Remove call of gitfo_size, since we call gitfo_lstat anyway; remove some old workaround code for gitfo_read, which is obsolete now. Signed-off-by: schu <schu-github@schulog.org>
* Stat files with full pathnamesCarlos Martín Nieto2011-06-201-4/+8
| | | | | | | | Call gitfo_lstat with the full pathname instead of the relative one, which fails in case the current working directory is different from the workdir. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* blob: Fix git_blob_create_fromfile()nulltoken2011-06-151-2/+2
|
* windows: Fix Symlink issuesVicent Marti2011-06-081-2/+2
| | | | | | | | Handle Symlinks if they can be handled in Win32. This is not even compiled. Needs review. The lstat implementation is modified from core Git. The readlink implementation is modified from PHP.
* blob: Stat path inside git_blob_create_fromfileJakob Pfender2011-06-071-1/+4
| | | | | | | | | | | | | 00582bc introduced a change that required the caller of git_blob_create_fromfile() to pass a struct stat with the stat information for the file. Several developers pointed out that this would make life hard for the bindings developers as struct stat isn't widely supported by other languages. Make git_blob_create_fromfile() stat the path itself, eliminating the need for the file to be stat'ed by the caller. This makes index_init_entry() more costly as the file will be stat'ed twice but makes life easier for everyone else.
* blob: Require stat information for git_blob_create_fromfile()Jakob Pfender2011-06-071-11/+24
| | | | | | | | | | | | | | | | | In order to be able to write symlinks with git_blob_create_fromfile(), we need to check whether the file to be written is a symbolic link or not. Since the calling function of git_blob_create_fromfile() is likely to have stated the file before calling, we make it pass the stat. The reason for this is that writing symbolic link blobs is significantly different from writing ordinary files - we do not want to open the link destination but instead want to write the link itself, regardless of whether it exists or not. Previously, index_init_entry() used to error out if the file to be added was a symlink that pointed to a nonexistent file. Fix this behaviour to add the file regardless of whether it exists. This mimics git.git's behaviour.
* Merge pull request #144 from nordsturm/fix_fakewstreamVicent Martí2011-06-021-1/+4
|\ | | | | Fix fake wstream write
| * Add error processing in git_blob_create_frombuffer()Sergey Nikishin2011-04-241-1/+4
| |
* | blob: Reword errorsVicent Marti2011-05-231-6/+8
| |
* | blob.c: Move to new error handling mechanismJakob Pfender2011-05-231-3/+7
| |