summaryrefslogtreecommitdiff
path: root/src/blob.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
| |
* | Move blob.c to the new error handlingschu2011-05-111-3/+3
|/ | | | Signed-off-by: schu <schu-github@schulog.org>
* Close file descriptor when writing a blobVicent Marti2011-04-151-0/+1
|
* I broke your bindingsVicent Marti2011-03-201-64/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hey. Apologies in advance -- I broke your bindings. This is a major commit that includes a long-overdue redesign of the whole object-database structure. This is expected to be the last major external API redesign of the library until the first non-alpha release. Please get your bindings up to date with these changes. They will be included in the next minor release. Sorry again! Major features include: - Real caching and refcounting on parsed objects - Real caching and refcounting on objects read from the ODB - Streaming writes & reads from the ODB - Single-method writes for all object types - The external API is now partially thread-safe The speed increases are significant in all aspects, specially when reading an object several times from the ODB (revwalking) and when writing big objects to the ODB. Here's a full changelog for the external API: blob.h ------ - Remove `git_blob_new` - Remove `git_blob_set_rawcontent` - Remove `git_blob_set_rawcontent_fromfile` - Rename `git_blob_writefile` -> `git_blob_create_fromfile` - Change `git_blob_create_fromfile`: The `path` argument is now relative to the repository's working dir - Add `git_blob_create_frombuffer` commit.h -------- - Remove `git_commit_new` - Remove `git_commit_add_parent` - Remove `git_commit_set_message` - Remove `git_commit_set_committer` - Remove `git_commit_set_author` - Remove `git_commit_set_tree` - Add `git_commit_create` - Add `git_commit_create_v` - Add `git_commit_create_o` - Add `git_commit_create_ov` tag.h ----- - Remove `git_tag_new` - Remove `git_tag_set_target` - Remove `git_tag_set_name` - Remove `git_tag_set_tagger` - Remove `git_tag_set_message` - Add `git_tag_create` - Add `git_tag_create_o` tree.h ------ - Change `git_tree_entry_2object`: New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)` - Remove `git_tree_new` - Remove `git_tree_add_entry` - Remove `git_tree_remove_entry_byindex` - Remove `git_tree_remove_entry_byname` - Remove `git_tree_clearentries` - Remove `git_tree_entry_set_id` - Remove `git_tree_entry_set_name` - Remove `git_tree_entry_set_attributes` object.h ------------ - Remove `git_object_new - Remove `git_object_write` - Change `git_object_close`: This method is now *mandatory*. Not closing an object causes a memory leak. odb.h ----- - Remove type `git_rawobj` - Remove `git_rawobj_close` - Rename `git_rawobj_hash` -> `git_odb_hash` - Change `git_odb_hash`: New signature is `(git_oid *id, const void *data, size_t len, git_otype type)` - Add type `git_odb_object` - Add `git_odb_object_close` - Change `git_odb_read`: New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)` - Change `git_odb_read_header`: New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)` - Remove `git_odb_write` - Add `git_odb_open_wstream` - Add `git_odb_open_rstream` odb_backend.h ------------- - Change type `git_odb_backend`: New internal signatures are as follows int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *) int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype) int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *) - Add type `git_odb_stream` - Add enum `git_odb_streammode` Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix the retarded object interdependency systemVicent Marti2011-03-141-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's no longer retarded. All object interdependencies are stored as OIDs instead of actual objects. This should be hundreds of times faster, specially on big repositories. Heck, who knows, maye it doesn't even segfault -- wouldn't that be awesome? What has changed on the API? `git_commit_parent`, `git_commit_tree`, `git_tag_target` now return their values through a pointer-to-pointer, and have an error code. `git_commit_set_tree` and `git_tag_set_target` now return an error code and may fail. `git_repository_free__no_gc` has been deprecated because it's stupid. Since there are no longer any interdependencies between objects, we don't need internal reference counting, and GC never fails or double-free's pointers. `git_object_close` now does a very sane thing: marks an object as unused. Closed objects will be eventually free'd from the object cache based on LRU. Please use `git_object_close` from the garbage collector `destroy` method on your bindings. It's 100% safe. `git_repository_gc` is a new method that forces a garbage collector pass through the repo, to free as many LRU objects as possible. This is useful if we are running out of memory.
* Change the return type of `git_blob_rawcontent`Vicent Marti2011-03-051-1/+1
| | | | | | Should return `void *` for raw bytes. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fix segmentation fault when freeing a repositoryVicent Marti2011-03-051-1/+1
| | | | | | | | Disable garbage collection of cross-references to prevent double-freeing. Internal reference management is now done with a separate method. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Implement reference counting for git_objectsVicent Marti2011-03-031-0/+4
| | | | | | | | All `git_object` instances looked up from the repository are reference counted. User is expected to use the new `git_object_close` when an object is no longer needed to force freeing it. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change the library include fileVicent Marti2010-12-061-3/+3
| | | | | | | | | | | | Libgit2 is now officially include as #include "<git2.h>" or indidividual files may be included as #include <git2/index.h> Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change include structure for the projectVicent Marti2010-12-061-1/+1
| | | | | | | | | | | The maze with include dependencies has been fixed. There is now a global include: #include <git.h> The git_odb_backend API has been exposed. Signed-off-by: Vicent Marti <tanoku@gmail.com>