summaryrefslogtreecommitdiff
path: root/src/commit.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix compilation errors and warningsnulltoken2012-04-111-9/+4
|
* error-handling: Commit (WIP)Vicent Martí2012-04-021-79/+104
|
* error-handling: RepositoryVicent Martí2012-03-071-1/+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.
* commit: actually allow yet to be born update_refschu2012-02-151-3/+7
| | | | | | | | git_commit_create is supposed to update the given reference "update_ref", but segfaulted in case of a yet to be born reference. Fix it. Signed-off-by: schu <schu-github@schulog.org>
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-1/+2
| | | | | | | | | | | | | | | | | | | | 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.
* repository: Change ownership semanticsVicent Marti2011-11-261-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Free all used references in the source treeschu2011-11-061-2/+13
| | | | | | | Since references are not owned by the repository anymore we have to free them manually now. Signed-off-by: schu <schu-github@schulog.org>
* refs: split internal and external referencesschu2011-11-061-2/+3
| | | | | | | | | | | | | | | | | Currently libgit2 shares pointers to its internal reference cache with the user. This leads to several problems like invalidation of reference pointers when reordering the cache or manipulation of the cache from user side. Give each user its own git_reference instead of leaking the internal representation (struct reference). Add the following new API functions: * git_reference_free * git_reference_is_packed Signed-off-by: schu <schu-github@schulog.org>
* global: Properly use `git__` memory wrappersVicent Marti2011-10-281-5/+5
| | | | | Ensure that all memory related functions (malloc, calloc, strdup, free, etc) are using their respective `git__` wrappers.
* commit: properly parse empty commit messagesBrodie Rao2011-10-121-2/+2
| | | | | | | | | This ensures commit->message is always non-NULL, even if the commit message is empty or consists of only a newline. One such commit can be found in the wild in the jQuery repository: https://github.com/jquery/jquery/commit/25b424134f9927a5bf0bab5cba836a0aa6c3cfc1
* Merge pull request #384 from kiryl/warningsVicent Martí2011-09-181-2/+2
|\ | | | | Add more -W flags to CFLAGS
| * CMakefile: add -Wmissing-prototypes and fix warningsKirill A. Shutemov2011-08-301-2/+2
| | | | | | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* | 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.
* Drop STRLEN() macrosKirill A. Shutemov2011-08-251-1/+1
| | | | | | | There is no need in STRLEN macros. Compilers can do this trivial optimization on its own. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* commit: Add support for Encoding headerVicent Marti2011-08-121-30/+30
|
* commit: fix cast warningsKirill A. Shutemov2011-07-251-2/+2
| | | | | | | | /home/kas/git/public/libgit2/src/commit.c: In function ‘commit_parse_buffer’: /home/kas/git/public/libgit2/src/commit.c:186:23: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] /home/kas/git/public/libgit2/src/commit.c:187:27: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual] Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* reflog: Fix reflog writer/readernulltoken2011-07-101-2/+2
| | | | | | - Use a space to separate oids and signature - Enforce test coverage - Make test run in a temporary folder in order not to alter the test repository
* Remove unused methodsVicent Marti2011-07-091-2/+2
| | | | | | | | | The direct-writes commit left some (slow) internals methods that were no longer needed. These have been removed. Also, the Reflog code was using the old `git_signature__write`, so it has been rewritten to use a normal buffer and the new `writebuf` signature writer. It's now slightly simpler and faster.
* odb: Direct writes are backVicent Marti2011-07-091-34/+21
| | | | | | | | | | | | | | | | | | | | | | DIRECT WRITES ARE BACK AND FASTER THAN EVER. The streaming writer to the ODB was an overkill for the smaller objects like Commit and Tags; most of the streaming logic was taking too long. This commit makes Commits, Tags and Trees to be built-up in memory, and then written to disk in 2 pushes (header + data), instead of streaming everything. This is *always* faster, even for big files (since the git_filebuf class still does streaming writes when the memory cache overflows). This is also a gazillion lines of code smaller, because we don't have to precompute the final size of the object before starting the stream (this was kind of defeating the point of streaming, anyway). Blobs are still written with full streaming instead of loading them in memory, since this is still the fastest way. A new `git_buf` class has been added. It's missing some features, but it'll get there.
* signature: Fix optional headerVicent Marti2011-07-091-2/+2
|
* Remove redundant methods from the APIVicent Marti2011-06-281-73/+17
| | | | | | | | | | | | | | | A bunch of redundant methods have been removed from the external API. - All the reference/tag creation methods with `_f` are gone. The force flag is now passed as an argument to the normal create methods. - All the different commit creation methods are gone; commit creation now always requires a `git_commit` pointer for parents and a `git_tree` pointer for tree, to ensure that corrupted commits cannot be generated. - All the different tag creation methods are gone; tag creation now always requires a `git_object` pointer to ensure that tags are not created to inexisting objects.
* Changed commit short messages so that they match git log --oneline output.Marc Pegon2011-06-081-4/+11
| | | | In git, the short message of a commit is the part of the commit message before 2 consecutive line breaks. In the short message, line breaks are replaced by space characters.
* commit: Reword errorsVicent Marti2011-05-231-9/+4
|
* commit.c: Move to new error handling mechanismJakob Pfender2011-05-231-7/+18
|
* Fix two warnings from ClangCarlos Martín Nieto2011-05-061-1/+1
| | | | | | Both are about not reading the value stored in a variable. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* commit: support a root commitsCarlos Martín Nieto2011-04-291-2/+11
| | | | | | | | | | | | A root commit is a commit whose branch (usually what HEAD points to) doesn't exist (yet). This situation can happen when the commit is the first after 1) a repository is initialized or 2) a orphan checkout has been performed. Take this opportunity to remove the symbolic link check, as git_reference_resolve works on OID refs as well. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
* Added git_commit_tree_oid and git_commit_parent_oid.Sam2011-04-081-0/+6
|
* Change `parse` methods to const bufferVicent Marti2011-04-021-2/+2
| | | | Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Switch from time_t to git_time_tnulltoken2011-03-231-1/+1
| | | | git_time_t is defined as a signed 64 integer. This allows a true predictable multiplatform behavior.
* Fix MSVC warningsVicent Marti2011-03-211-3/+3
|
* I broke your bindingsVicent Marti2011-03-201-113/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 headers for the new Revision WalkerVicent Marti2011-03-161-1/+0
| | | | | | The "oid.h" header is now included instead of "object.h". The old "revwalk.h" header has been removed; it was empty.
* Fix the retarded object interdependency systemVicent Marti2011-03-141-130/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix segmentation fault when freeing a repositoryVicent Marti2011-03-051-8/+8
| | | | | | | | 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>
* Fix several issues with refcountingVicent Marti2011-03-031-8/+19
| | | | | | | - Added several missing reference increases - Add new destructor to the repository that does not GC the objects Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Implement reference counting for git_objectsVicent Marti2011-03-031-1/+21
| | | | | | | | 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>
* Fix searching in git_vectorVicent Marti2011-03-031-1/+1
| | | | | | | | | | | | | | | | | | We now store only one sorting callback that does entry comparison. This is used when sorting the entries using a quicksort, and when looking for a specific entry with the new search methods. The following search methods now exist: git_vector_search(vector, entry) git_vector_search2(vector, custom_search_callback, key) git_vector_bsearch(vector, entry) git_vector_bsearch2(vector, custom_search_callback, key) The sorting state of the vector is now stored internally. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Change the object creation/lookup APIVicent Marti2011-03-031-2/+2
| | | | | | | | | | | | | | | | | | The methods previously known as git_repository_lookup git_repository_newobject git_repository_lookup_ref are now part of their respective namespaces: git_object_lookup git_object_new git_reference_lookup This makes the API more consistent with the new references API. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Fixed a bug with the way commits are writtenJohn Wiegley2011-02-011-2/+4
|
* Fixed memory leak in git_commit__free().Robert G. Jakabosky2011-01-081-0/+1
|
* Rename 'git_person' to 'git_signature'Vicent Marti2010-12-181-44/+27
| | | | | | | The new signature struct is public, and contains information about the timezone offset. Must be free'd manually by the user. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* Added timezone offset parsing and outputting.nulltoken2010-12-101-4/+18
|
* Set short message when changing a commit's messagev0.2.0Vicent Marti2010-12-071-3/+13
| | | | | | Yes, finally. 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>
* Small source code readability improvements.nulltoken2010-12-051-9/+9
| | | | Replaced magic number "0" with GIT_SUCCESS constant wherever it made sense.
* Commit parents now use the common 'vector' codeVicent Marti2010-12-021-53/+20
| | | | | | No more linked lists, no more O(n) access. Signed-off-by: Vicent Marti <tanoku@gmail.com>
* add git_commit_parent to retrieve a parent by indexJustin Love2010-11-301-0/+14
|
* add git_commit_parentcountJustin Love2010-11-301-0/+15
|