summaryrefslogtreecommitdiff
path: root/src/commit.c
Commit message (Collapse)AuthorAgeFilesLines
* commit: allow retrieving an arbitrary header fieldcmn/commit-header-fieldCarlos Martín Nieto2015-06-221-0/+55
| | | | | | This allows the user to look up fields which we don't parse in libgit2, and allows them to access gpgsig or mergetag fields if they wish to check the signature.
* commit: ignore multiple author fieldscmn/double-authorCarlos Martín Nieto2015-06-111-0/+10
| | | | | | | | | | Some tools create multiple author fields. git is rather lax when parsing them, although fsck does complain about them. This means that they exist in the wild. As it's not too taxing to check for them, and there shouldn't be a noticeable slowdown when dealing with correct commits, add logic to skip over these extra fields when parsing the commit.
* Remove the signature from ref-modifying functionsCarlos Martín Nieto2015-03-031-2/+2
| | | | | | | | | | The signature for the reflog is not something which changes dynamically. Almost all uses will be NULL, since we want for the repository's default identity to be used, making it noise. In order to allow for changing the identity, we instead provide git_repository_set_ident() and git_repository_ident() which allow a user to override the choice of signature.
* Remove extra semicolon outside of a functionStefan Widgren2015-02-151-1/+1
| | | | | Without this change, compiling with gcc and pedantic generates warning: ISO C does not allow extra ‘;’ outside of a function.
* git_rebase_commit: write HEAD's reflog appropriatelyEdward Thomson2014-10-261-31/+5
|
* commit: safer commit creation with reference updatecmn/commit-create-safeCarlos Martín Nieto2014-04-301-21/+78
| | | | | | | | | | | | | | The current version of the commit creation and amend function are unsafe to use when passing the update_ref parameter, as they do not check that the reference at the moment of update points to what the user expects. Make sure that we're moving history forward when we ask the library to update the reference for us by checking that the first parent of the new commit is the current value of the reference. We also make sure that the ref we're updating hasn't moved between the read and the write. Similarly, when amending a commit, make sure that the current tip of the branch is the commit we're amending.
* commit: simplify and correct refcounting in nth_gen_ancestorCarlos Martín Nieto2014-03-071-9/+8
| | | | | | | | We can make use of git_object_dup to use refcounting instead of pointer comparison to make sure we don't free the caller's object. This also lets us simplify the case for '~0' which is now just an assignment instead of looking up the object we have at hand.
* Remove now-duplicated stdarg.h includeEdward Thomson2014-02-241-2/+0
|
* Add git_commit_amend APIRussell Belfer2014-02-071-66/+161
| | | | | | | | | This adds an API to amend an existing commit, basically a shorthand for creating a new commit filling in missing parameters from the values of an existing commit. As part of this, I also added a new "sys" API to create a commit using a callback to get the parents. This allowed me to rewrite all the other commit creation APIs so that temporary allocations are no longer needed.
* Merge remote-tracking branch 'libgit2/development' into bs/more-reflog-stuffBen Straub2014-02-051-28/+12
|\
| * commit: faster parsingCarlos Martín Nieto2014-02-051-28/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current code issues a lot of strncmp() calls in order to check for the end of the header, simply in order to copy it and start going through it again. These are a lot of calls for something we can check as we go along. Knowing the amount of parents beforehand to reduce allocations in extreme cases does not make up for them. Instead start parsing immediately and check for the double-newline after each header field, leaving the raw_header allocation for the end, which lets us go through the header once and reduces the amount of strncmp() calls significantly. In unscientific testing, this has reduced a shortlog-like usage (walking though the whole history of a branch and extracting data from the commits) of git.git from ~830ms to ~700ms and makes the time we spend in strncmp() negligible.
* | Fix reflog message when creating commitsBen Straub2014-02-041-2/+21
|/
* commit: remvoe legacy 'oid' namingCarlos Martín Nieto2014-01-251-2/+2
|
* Summarize empty messagesEdward Thomson2014-01-221-1/+4
|
* refs: remove the _with_log differentiationCarlos Martín Nieto2014-01-151-1/+1
| | | | | | Any well-behaved program should write a descriptive message to the reflog whenever it updates a reference. Let's make this more prominent by removing the version without the reflog parameters.
* commit: Fix potential segfault in git_commit_messagePaul Holden2013-12-081-1/+3
| | | | Dereferencing commit pointer before asserting
* Introduce git_revert to revert a single commitEdward Thomson2013-12-021-0/+29
|
* commit: Introduce git_commit_message_raw()nulltoken2013-10-031-5/+18
|
* commit: Trim message leading newlinesnulltoken2013-09-301-1/+1
| | | | Fix libgit2/libgit2sharp#522
* Fix warnings on Win64Russell Belfer2013-07-111-1/+2
|
* Convert commit->parent_ids to git_array_tRussell Belfer2013-07-101-22/+7
| | | | | | | | | This converts the array of parent SHAs from a git_vector where each SHA has to be separately allocated to a git_array_t where all the SHAs can be kept in one block. Since the two collections have almost identical APIs, there isn't much involved in making the change. I did add an API to git_array_t so that it could be allocated at a precise initial size.
* Add raw header access to commit APIRussell Belfer2013-07-101-10/+37
|
* Add cat-file example and increase const use in APIRussell Belfer2013-05-161-2/+4
| | | | | | | | | | | | | | | | This adds an example implementation that emulates git cat-file. It is a convenient and relatively simple example of getting data out of a repository. Implementing this also revealed that there are a number of APIs that are still not using const pointers to objects that really ought to be. The main cause of this is that `git_vector_bsearch` may need to call `git_vector_sort` before doing the search, so a const pointer to the vector is not allowed. However, for tree objects, with a little care, we can ensure that the vector of tree entries is always sorted and allow lookups to take a const pointer. Also, the missing const in commit objects just looks like an oversight.
* Fix broken build when MSVC SDL checks is enabledLinquize2013-05-111-1/+1
|
* commit: make create_from_oids() accept plain oidnulltoken2013-05-051-1/+0
|
* commit: guard create() against not owned treesnulltoken2013-05-051-0/+1
|
* Simplify object table parse functionsRussell Belfer2013-04-221-1/+3
| | | | | This unifies the object parse functions into one signature that takes an odb_object.
* Add callback to git_objects_tableRussell Belfer2013-04-221-11/+5
| | | | | | | | | | 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-1/+2
| | | | | This uses the odb object accessors so we can change the internals more easily...
* What has science done.Vicent Marti2013-04-221-1/+1
|
* Move git_commit_create_from_oids into sys/commit.hRussell Belfer2013-04-211-38/+43
| | | | | | | | Actually this renames git_commit_create_oid to git_commit_create_from_oids and moves the API declaration to include/git2/sys/commit.h since it is a dangerous API for general use (because it doesn't check that the OID list items actually refer to real objects).
* Added git_commit_create_oidJohn Wiegley2013-04-211-10/+40
|
* commit: correctly detect the start of the commit messageCarlos Martín Nieto2013-04-151-2/+2
| | | | | | | | | The end of the header is signaled by to consecutive LFs and the commit message starts immediately after. Jumping over LFs at the start of the message is a bug and leads to creating different commits if when rebuilding history. This also fixes an empty commit message being returned as "\n".
* Several warnings detected by static code analyzer fixedArkadiy Shapkin2013-03-181-1/+1
| | | | | | | 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
* immutable references and a pluggable ref databaseEdward Thomson2013-03-071-1/+1
|
* Vector improvements and their falloutPhilip Kelley2013-01-271-1/+2
|
* commit: don't include the LF in the header field valueCarlos Martín Nieto2013-01-201-2/+3
| | | | | | | | | When the encoding header changed to be treated as an additional header, the EOL pointer started to point to the byte after the LF, making the git__strndup call copy the LF into the value. Increase the EOL pointer value after copying the data to keep the rest of the semantics but avoid copying LF.
* Add skipping of unknown commit headersRussell Belfer2013-01-171-14/+16
| | | | | | | | This moves the check for the "encoding" header into a loop which is just scanning for non-required headers at the end of a commit header. That loop will skip unrecognized lines (including header continuation lines) until a terminating completely blank line is found, and only then does it move to reading the commit message.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* More external API cleanupVicent Marti2012-11-271-29/+24
| | | | | | Conflicts: src/branch.c tests-clar/refs/branches/create.c
* portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
|
* commit: introduce git_commit_nth_gen_ancestor()nulltoken2012-07-121-0/+34
|
* commit: reduce code duplicationnulltoken2012-07-121-10/+9
|
* Fix broken tests caused by no longer prettifying by defaultTim Clem2012-06-151-5/+2
|
* Kill message_prettify - we will export insteadTim Clem2012-06-151-4/+0
|
* Don't strip comments (#) from commit messages by defaultTim Clem2012-06-151-1/+1
|
* Add git_reset()nulltoken2012-06-071-61/+1
| | | | Currently supports Soft and Mixed modes.
* CleanupMichael Schubert2012-05-191-9/+0
| | | | | | | * indexer: remove leftover printf * commit: remove unused macros COMMIT_BASIC_PARSE, COMMIT_FULL_PARSE and COMMIT_PRINT
* commit/tag: ensure the message is cleaned upnulltoken2012-05-071-3/+11
| | | | | | 'git commit' and 'git tag -a' enforce some conventions, like cleaning up excess whitespace and making sure that the last line ends with a '\n'. This fix replicates this behavior. Fix libgit2/libgit2sharp#117
* error handling: move the missing parts over to the new error handlingCarlos Martín Nieto2012-04-261-2/+4
|