summaryrefslogtreecommitdiff
path: root/tests/commit
Commit message (Collapse)AuthorAgeFilesLines
* commit: add failing tests for object checking for git_commit_with_signatureCarlos Martín Nieto2019-10-301-8/+32
| | | | | | | | | There can be a significant difference between the system where we created the buffer (if at all) and when the caller provides us with the contents of a commit. Provide some test cases (we have to adapt the existing ones because they refer to trees and commits which do not exist).
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-2/+2
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* references: use new names in internal usageethomson/git_refEdward Thomson2019-01-171-1/+1
| | | | Update internal usage to use the `git_reference` names for constants.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-3/+3
| | | | Use the new object_type enumeration names within the codebase.
* signature: fix out-of-bounds read when parsing timezone offsetPatrick Steinhardt2018-11-091-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | When parsing a signature's timezone offset, we first check whether there is a timezone at all by verifying that there are still bytes left to read following the time itself. The check thus looks like `time_end + 1 < buffer_end`, which is actually correct in this case. After setting the timezone's start pointer to that location, we compute the remaining bytes by using the formula `buffer_end - tz_start + 1`, re-using the previous `time_end + 1`. But this is in fact missing the braces around `(tz_start + 1)`, thus leading to an overestimation of the remaining bytes by a length of two. In case of a non-NUL terminated buffer, this will result in an overflow. The function `git_signature__parse` is only used in two locations. First is `git_signature_from_buffer`, which only accepts a string without a length. The string thus necessarily has to be NUL terminated and cannot trigger the issue. The other function is `git_commit__parse_raw`, which can in fact trigger the error as it may receive non-NUL terminated commit data. But as objects read from the ODB are always NUL-terminated by us as a cautionary measure, it cannot trigger the issue either. In other words, this error does not have any impact on security.
* treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-133-36/+36
| | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-102-4/+4
|
* signature: distinguish +0000 and -0000 UTC offsetsHenry Kleynhans2017-11-121-0/+27
| | | | | | | | | | | | | | Git considers '-0000' a valid offset for signature lines. They need to be treated as _not_ equal to a '+0000' signature offset. Parsing a signature line stores the offset in a signed integer which does not distinguish between `+0` and `-0`. This patch adds an additional flag `sign` to the `git_time` in the `signature` object which is populated with the sign of the offset. In addition to exposing this information to the user, this information is also used to compare signatures. /cc @pks-t @ethomson
* Fix initial commit testJohn Haley2016-05-041-30/+5
| | | | | | `test_commit_commit__create_initial_commit_parent_not_current` was not correctly testing that `HEAD` was not changed. Now we grab the oid that it was pointing to before the call to `git_commit_create` and the oid that it's pointing to afterwards and compare those.
* Add tests for creating an initial commitJohn Haley2016-05-031-0/+85
|
* Introduce `git_signature_from_buffer`ethomson/signature_from_bufferEdward Thomson2016-04-281-0/+13
| | | | | Allow users to construct a signature from the type of signature lines that actually appear in commits.
* Merge pull request #3673 from libgit2/cmn/commit-with-signatureEdward Thomson2016-03-171-0/+100
|\ | | | | commit: add function to attach a signature to a commit
| * commit: add function to attach a signature to a commitcmn/commit-with-signatureCarlos Martín Nieto2016-03-151-0/+100
| | | | | | | | | | In combination with the function which creates a commit into a buffer, this allows us to more easily create signed commits.
* | commit: fix extraction of single-line signaturescmn/extract-oneline-sigCarlos Martín Nieto2016-03-171-0/+24
|/ | | | | | | | The function to extract signatures suffers from a similar bug to the header field finding one by having an unecessary line feed check as a break condition of its loop. Fix that and add a test for this single-line signature situation.
* commit: split creating the commit and writing it outcmn/commit-to-memoryCarlos Martín Nieto2016-03-081-0/+39
| | | | | | Sometimes you want to create a commit but not write it out to the objectdb immediately. For these cases, provide a new function to retrieve the buffer instead of having to go through the db.
* turn on strict object validation by defaultEdward Thomson2016-02-281-4/+4
|
* git_commit: validate tree and parent idsEdward Thomson2016-02-281-5/+106
| | | | | When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate the tree and parent ids given to commit creation functions.
* commit: expose the different kinds of errorsCarlos Martín Nieto2016-02-161-0/+11
| | | | | | We should be checking whether the object we're looking up is a commit, and we should let the caller know whether the not-found return code comes from a bad object type or just a missing signature.
* commit: don't forget the last header fieldCarlos Martín Nieto2016-02-111-0/+7
| | | | | | | | | When we moved the logic to handle the first one, wrong loop logic was kept in place which meant we still finished early. But we now notice it because we're not reading past the last LF we find. This was not noticed before as the last field in the tested commit was multi-line which does not trigger the early break.
* Merge pull request #3599 from libgit2/gpgsignVicent Marti2016-02-091-0/+49
|\ | | | | Introduce git_commit_extract_signature
| * Introduce git_commit_extract_signaturegpgsignCarlos Martín Nieto2016-02-091-0/+49
| | | | | | | | | | | | This returns the GPG signature for a commit and its contents without the signature block, allowing for the verification of the commit's signature.
* | commit: also match the first header field when searchingcmn/header-field-2Carlos Martín Nieto2016-02-091-0/+4
|/ | | | | | | | We were searching only past the first header field, which meant we were unable to find e.g. `tree` which is the first field. While here, make sure to set an error message in case we cannot find the field.
* commit: Fix memory leak in test suitevmg/commit-leakVicent Marti2015-12-171-1/+1
|
* commit: introduce `git_commit_body`Patrick Steinhardt2015-12-011-0/+39
| | | | | | | | | It is already possible to get a commit's summary with the `git_commit_summary` function. It is not possible to get the remaining part of the commit message, that is the commit message's body. Fix this by introducing a new function `git_commit_body`.
* Fix git_commit_summary to convert newlines to spaces even afterStjepan Rajko2015-11-032-3/+7
| | | | whitespace. Collapse spaces around newlines for the summary.
* signature: Strip crud just like Git doesVicent Marti2015-10-211-0/+7
|
* commit: allow retrieving an arbitrary header fieldcmn/commit-header-fieldCarlos Martín Nieto2015-06-221-0/+38
| | | | | | 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/+7
| | | | | | | | | | 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-1/+1
| | | | | | | | | | 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.
* signature: don't allow empty emailscmn/signature-empty-emailCarlos Martín Nieto2014-09-101-2/+2
| | | | | | A signature is made up of a non-empty name and a non-empty email so let's validate that. This also brings us more in line with git, which also rejects ident with an empty email.
* Introduce cl_assert_equal_oidEdward Thomson2014-07-012-2/+2
|
* commit: safer commit creation with reference updatecmn/commit-create-safeCarlos Martín Nieto2014-04-301-0/+4
| | | | | | | | | | | | | | 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.
* Fix reflog message when creating commitsBen Straub2014-02-041-1/+14
|
* Summarize empty messagesEdward Thomson2014-01-221-0/+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.
* Introduce git_revert to revert a single commitEdward Thomson2013-12-021-0/+29
|
* Rename tests-clar to testsBen Straub2013-11-145-0/+747