Commit Graph

61 Commits

Author SHA1 Message Date
Edward Thomson
49d3fadfca Revert "commit: fix const declaration"
This reverts commit cf19ddc522, which
was breaking for several projects.
2024-06-13 15:20:40 +02:00
Edward Thomson
55381816e8 commit: support specifying encoding for message 2024-01-15 15:53:19 +00:00
Edward Thomson
67a4d04b59 commit: introduce git_commit_create_from_stage
Provide a simple helper method that allows users to create a commit from
the current index with minimal information.
2024-01-15 15:53:19 +00:00
Edward Thomson
cf19ddc522 commit: fix const declaration
commit functions should take an array of const pointers, not a const
array.
2024-01-15 00:15:10 +00:00
Edward Thomson
98075baed2 fixup! commit: introduce git_repository_commit_parents 2023-12-23 15:30:31 +00:00
Edward Thomson
0572884693 commit: introduce git_repository_commit_parents
Emulating `git commit` is clunky - identifying your commit's parents is
part of the problem. Provide a helper to give you the parents given the
current repository state.
2023-12-23 14:11:26 +00:00
Edward Thomson
d4232e7c91 Apply suggestions from code review 2022-01-17 21:21:54 -05:00
punkymaniac
7491b3fd5d Set parameter name as function declaration 2022-01-12 09:40:13 +01:00
punkymaniac
68bc511abb Add documentation about parameter and return value 2022-01-09 10:17:51 +01:00
Edward Thomson
ef03e15038 rebase: deprecate signing_cb
The signing callback should not be used; instead, callers should provide
a commit_create_cb, perform the signing and commit creation themselves.
2021-08-29 10:16:56 -04:00
Edward Thomson
d3bdf33b58 rebase: introduce git_commit_create_cb
Introduce a new mechanism for `git_rebase_commit` for callers to
customize the experience.  Instead of assuming that we produce the
commit for them, provide a commit creation callback that allows callers
to produce the commit themselves and return the resulting commit id.
2021-08-29 10:16:29 -04:00
Tyler Ang-Wanek
8f68ad9df1 documentation: add small explanation for commit signing 2019-07-02 10:14:46 -07:00
Tyler Ang-Wanek
759471056f commit: git_commit_create_with_signature should support null signature
If provided with a null signature, skip adding the signature header and create the commit anyway.
2019-07-02 09:56:19 -07:00
Tyler Wanek
0d06bf4852 fixup: More generic signing_cb for future flexibility
In the case that we want to build merge + commit, cherrypick + commit, or even just build a commit with signing callback, `git_rebase_commit_signature_cb` particular callback should be made more generic. We also renamed `signature_cb` to `signing_cb` to improve clarity on the purpose of the callback (build a difference between a git_signature and the act of signing).

So we've ended up with `git_commit_signing_cb`.
2019-01-24 08:42:25 -07:00
Edward Thomson
20961b9871 git_error: use full class name in public error API
Move to the `git_error` name in error-related functions, deprecating the
`giterr` functions.  This means, for example, that `giterr_last` is now
`git_error_last`.  The old names are retained for compatibility.

This only updates the public API; internal API and function usage
remains unchanged.
2019-01-22 22:26:51 +00:00
Nika Layzell
e3dcaca579 mailmap: Integrate mailmaps with blame and signatures 2018-06-14 22:43:27 -07:00
Patrick Steinhardt
dc851d9eae commit: clear user-provided buffers
The functions `git_commit_header_field` and
`git_commit_extract_signature` both receive buffers used to hand back
the results to the user. While these functions called `git_buf_sanitize`
on these buffers, this is not the right thing to do, as it will simply
initialize or zero-terminate passed buffers. As we want to overwrite
contents, we instead have to call `git_buf_clear` to completely reset
them.
2017-02-13 13:50:52 +01:00
Edward Thomson
f0224772ee git_object_dup: introduce typesafe versions 2016-03-23 17:08:37 -04:00
Carlos Martín Nieto
02d61a3b66 commit: add function to attach a signature to a commit
In combination with the function which creates a commit into a buffer,
this allows us to more easily create signed commits.
2016-03-15 12:55:03 +01:00
Carlos Martín Nieto
47cb42da5a commit: split creating the commit and writing it out
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.
2016-03-08 13:11:49 +01:00
Carlos Martín Nieto
eadd0f05f6 commit: expose the different kinds of errors
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.
2016-02-16 14:06:48 +01:00
Carlos Martín Nieto
a65afb757e Introduce git_commit_extract_signature
This returns the GPG signature for a commit and its contents without the
signature block, allowing for the verification of the commit's
signature.
2016-02-09 15:58:16 +01:00
Patrick Steinhardt
7f8fe1d45e commit: introduce git_commit_body
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`.
2015-12-01 10:07:00 +01:00
Carlos Martín Nieto
a3f42fe8e4 commit: allow retrieving an arbitrary header field
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.
2015-06-22 15:56:31 +02:00
Carlos Martín Nieto
217c029b54 commit: safer commit creation with reference update
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.
2014-04-30 00:41:37 +02:00
Russell Belfer
80c29fe93e Add git_commit_amend API
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.
2014-02-07 16:17:59 -08:00
Edward Thomson
300d192f7e Introduce git_revert to revert a single commit 2013-12-02 16:57:41 -06:00
nulltoken
598f069b99 commit: Introduce git_commit_message_raw() 2013-10-03 07:59:55 +02:00
Russell Belfer
b2d3efcbce Some documentation improvements 2013-08-28 09:31:32 -07:00
Russell Belfer
f094f9052f Add raw header access to commit API 2013-07-10 20:50:32 +02:00
Andreas Linde
e196716457 Fixed most documentation header bugs
Fixed a few header @param and @return typos with the help of -Wdocumentation in Xcode.

The following warnings have not been fixed:
common.h:213 - Not sure how the documentation format is for '...'
notes.h:102 - Correct @param name but empty text
notes.h:111 - Correct @param name but empty text
pack.h:140 - @return missing text
pack.h:148 - @return missing text
2013-06-24 15:33:41 +02:00
Russell Belfer
58206c9ae7 Add cat-file example and increase const use in API
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.
2013-05-16 10:38:27 -07:00
J. David Ibáñez
6e8659969a Add git_commit_owner to the public interface
Just like git_tree_owner, etc.
2013-05-07 07:33:35 +02:00
Vicent Marti
0b726701f3 object: Explicitly define helper API methods for all obj types 2013-04-30 13:13:38 +02:00
Russell Belfer
9233b3de4e Move git_commit_create_from_oids into sys/commit.h
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).
2013-04-21 11:50:56 -07:00
John Wiegley
9255039898 Added git_commit_create_oid 2013-04-21 11:50:56 -07:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Vicent Marti
cfbe4be3fb More external API cleanup
Conflicts:
	src/branch.c
	tests-clar/refs/branches/create.c
2012-11-27 13:18:27 -08:00
nulltoken
b8457baae2 portability: Improve x86/amd64 compatibility 2012-07-24 16:10:12 +02:00
Carlos Martín Nieto
1ebe432e2f commit: properly export git_commit_nth_gen_ancestor() 2012-07-12 20:33:30 +02:00
nulltoken
b1aca6eae0 commit: introduce git_commit_nth_gen_ancestor() 2012-07-12 01:06:11 +02:00
nulltoken
743a4b3bdd message: Expose git_message_prettify()
git_commit() and git_tag() no longer prettify the
message by default. This has to be taken care of
by the caller.

This has the nice side effect of putting the
caller in position to actually choose to strip
the comments or not.
2012-06-19 10:02:22 +02:00
Vicent Martí
e172cf082e errors: Rename the generic return codes 2012-05-18 01:26:26 +02:00
nulltoken
458b94503d commit/tag: ensure the message is cleaned up
'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
2012-05-07 12:16:04 +02:00
schu
b4b79ac3db commit: actually allow yet to be born update_ref
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>
2012-02-15 13:07:41 +01:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Vicent Marti
45e79e3701 Rename all _close methods
There's no difference between `_free` and `_close` semantics: keep
everything with the same name to avoid confusions.
2011-11-26 08:48:00 +01:00
Vicent Marti
87d9869fc3 Tabify everything
There were quite a few places were spaces were being used instead of
tabs. Try to catch them all. This should hopefully not break anything.
Except for `git blame`. Oh well.
2011-09-19 03:34:49 +03:00
Vicent Marti
bb742ede3d Cleanup legal data
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.
2011-09-19 01:54:32 +03:00
David Boyce
d911172255 Standardized doxygen @return lines for int functions to say "GIT_SUCCESS or an error code". 2011-09-13 12:30:25 -04:00