summaryrefslogtreecommitdiff
path: root/src/rebase.c
Commit message (Collapse)AuthorAgeFilesLines
* path: separate git-specific path functions from utilEdward Thomson2021-11-091-4/+4
| | | | | | Introduce `git_fs_path`, which operates on generic filesystem paths. `git_path` will be kept for only git-specific path functionality (for example, checking for `.git` in a path).
* str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstrEdward Thomson2021-10-171-81/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
* rebase: deprecate signing_cbethomson/commit_create_cbEdward Thomson2021-08-291-1/+6
| | | | | The signing callback should not be used; instead, callers should provide a commit_create_cb, perform the signing and commit creation themselves.
* rebase: introduce git_commit_create_cbEdward Thomson2021-08-291-35/+66
| | | | | | | 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.
* rebase: use GIT_ASSERTEdward Thomson2020-11-271-18/+26
|
* tree-wide: do not compile deprecated functions with hard deprecationPatrick Steinhardt2020-06-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | When compiling libgit2 with -DDEPRECATE_HARD, we add a preprocessor definition `GIT_DEPRECATE_HARD` which causes the "git2/deprecated.h" header to be empty. As a result, no function declarations are made available to callers, but the implementations are still available to link against. This has the problem that function declarations also aren't visible to the implementations, meaning that the symbol's visibility will not be set up correctly. As a result, the resulting library may not expose those deprecated symbols at all on some platforms and thus cause linking errors. Fix the issue by conditionally compiling deprecated functions, only. While it becomes impossible to link against such a library in case one uses deprecated functions, distributors of libgit2 aren't expected to pass -DDEPRECATE_HARD anyway. Instead, users of libgit2 should manually define GIT_DEPRECATE_HARD to hide deprecated functions. Using "real" hard deprecation still makes sense in the context of CI to test we don't use deprecated symbols ourselves and in case a dependant uses libgit2 in a vendored way and knows it won't ever use any of the deprecated symbols anyway.
* rebase: update enum type name for consistencyEdward Thomson2020-01-181-21/+21
| | | | | libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_rebase_type_t` to `git_rebase_t` for consistency.
* Merge pull request #4913 from implausible/feature/signing-rebase-commitsPatrick Steinhardt2019-08-091-4/+41
|\ | | | | Add sign capability to git_rebase_commit
| * rebase: always use git_commit_create_with_signatureTyler Ang-Wanek2019-07-021-32/+28
| | | | | | | | This simplifies the flow of rebase_commit__create because it doesn't have to juggle 2 different commit flows (one with signature and one without).
| * fixup: Leverage git_error_set_after_callback_functionTyler Ang-Wanek2019-07-021-7/+7
| |
| * Clear error before calling signing_cb, set error if one has not been setTyler Wanek2019-02-211-1/+3
| | | | | | | | We should clear the error before calling the signing_cb to allow the signing_cb to set its own errors. If the CB did not provide an error, we should set our own generic error before exiting rebase_commit__create
| * Set git_error when signing_cb returns an error codeTyler Wanek2019-02-201-1/+3
| |
| * fixup: More generic signing_cb for future flexibilityTyler Wanek2019-01-241-2/+2
| | | | | | | | | | 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`.
| * Single callback for commit signing in rebase w/ git_bufTyler Wanek2019-01-231-15/+15
| | | | | | Reduces the number of callbacks for signing a commit during a rebase operation to just one callback. That callback has 2 out git_buf parameters for signature and signature field. We use git_buf here, because we cannot make any assumptions about the heap allocator a user of the library might be using.
| * Add signing callbacks for git_rebase_commit in git_rebase_optionsTyler Wanek2019-01-231-4/+41
| | | | | | | | 2 callbacks have been added to git_rebase_options, git_rebase_commit_signature_cb and git_rebase_commit_signature_field_cb. When git_rebase_commit_signature_cb is present in git_rebase_options, it will be called whenever git_rebase_commit is performed, giving an opportunity to sign the commit. The signing procedure can be skipped if the callback specifies passthrough as the error. The git_rebase_commit_signature_field_cb will only be called if the other callback is present or did not passthrough, and it provides means to specify which field a signature is for. Git_rebase_options was chosen as the home for these callbacks as it keeps backwards compatibility with the current rebase api.
* | rebase: use size_t for path lengthEdward Thomson2019-06-241-1/+2
| |
* | Rename opt init functions to `options_init`Edward Thomson2019-06-141-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | In libgit2 nomenclature, when we need to verb a direct object, we name a function `git_directobject_verb`. Thus, if we need to init an options structure named `git_foo_options`, then the name of the function that does that should be `git_foo_options_init`. The previous names of `git_foo_init_options` is close - it _sounds_ as if it's initializing the options of a `foo`, but in fact `git_foo_options` is its own noun that should be respected. Deprecate the old names; they'll now call directly to the new ones.
* | rebase: orig_head and onto accessorsErik Aigner2019-04-211-0/+16
|/ | | | | | | | The rebase struct stores fields with information about the current rebase process, which were not accessible via a public interface. Accessors for getting the `orig_head` and `onto` branch names and object ids have been added.
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-28/+28
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-2/+2
| | | | Use the new object_type enumeration names within the codebase.
* global: replace remaining use of `git__strtol32`Patrick Steinhardt2018-10-181-1/+1
| | | | | | | Replace remaining uses of the `git__strtol32` function. While these uses are all safe as the strings were either sanitized or from a trusted source, we want to remove `git__strtol32` altogether to avoid future misuse.
* Convert usage of `git_buf_free` to new `git_buf_dispose`Patrick Steinhardt2018-06-101-19/+19
|
* checkout: change default strategy to SAFEEtienne Samson2018-03-261-3/+0
| | | As per #4200, our default is quite surprising to users that expect checkout to just "do the thing".
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* Merge pull request #4030 from libgit2/ethomson/fsyncEdward Thomson2017-03-221-9/+9
|\ | | | | fsync all the things
| * git_futils_writebuffer: default only when flags==0Edward Thomson2017-02-281-9/+9
| | | | | | | | | | Only use defaults for `git_futils_writebuffer` when flags == 0, lest (1 << 31) be treated as the defaults.
* | rebase: ignore untracked files in submodulesDavid Turner2017-03-031-1/+3
|/ | | | | | | | | An untracked file in a submodule should not prevent a rebase from starting. Even if the submodule's SHA is changed, and that file would conflict with a new tracked file, it's still OK to start the rebase and discover the conflict later. Signed-off-by: David Turner <dturner@twosigma.com>
* repository: rename `path_repository` and `path_gitlink`Patrick Steinhardt2017-02-131-3/+3
| | | | | | | | | | | | | The `path_repository` variable is actually confusing to think about, as it is not always clear what the repository actually is. It may either be the path to the folder containing worktree and .git directory, the path to .git itself, a worktree or something entirely different. Actually, the intent of the variable is to hold the path to the gitdir, which is either the .git directory or the bare repository. Rename the variable to `gitdir` to avoid confusion. While at it, also rename `path_gitlink` to `gitlink` to improve consistency.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-12/+12
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* rebase: check the result code of rebase_init_mergeJacques Germishuys2016-12-291-1/+1
|
* git_rebase_init: correctly handle detached HEADDavid Turner2016-12-011-1/+1
| | | | | | | | git_rebase_finish relies on head_detached being set, but rebase_init_merge was only setting it when branch->ref_name was unset. But branch->ref_name would be set to "HEAD" in the case of detached HEAD being either implicitly (NULL) or explicitly passed to git_rebase_init.
* rebase: don't ask for time sortingCarlos Martín Nieto2016-10-061-1/+1
| | | | | | `git-rebase--merge` does not ask for time sorting, but uses the default. We now produce the same default time-ordered output as git, so make us of that since it's not always the same output as our time sorting.
* rebase: change assertion to avoidEdward Thomson2016-06-011-4/+1
| | | | | | | It looks like we're getting the operation and not doing anything with it, when in fact we are asserting that it's not null. Simply assert that we are within the operation boundary instead of using the `git_array_get` macro to do this for us.
* rebase: handle no common ancestor for inmemoryethomson/rebase_inmemory_no_baseEdward Thomson2016-05-031-4/+15
|
* rebase: correctly finish rebasing detached headsethomson/rebase_detachedEdward Thomson2016-04-211-24/+35
| | | | | When rebasing with IDs, we do not return to the `branch`, we remain in a detached HEAD state.
* rebase: handle detached HEADs in `init`Edward Thomson2016-04-211-3/+11
| | | | | | When `init`ing a rebase from a detached HEAD, be sure to remember that we were in a detached HEAD state so that we can correctly `abort` the object that we just created.
* rebase: plug memory leak in `rebase_alloc`Patrick Steinhardt2016-02-231-10/+12
| | | | | | | Convert `rebase_alloc` to use our usual error propagation patterns, that is accept an out-parameter and return an error code that is to be checked by the caller. This allows us to use the GITERR_CHECK_ALLOC macro, which helps static analysis.
* rebase: persist a single in-memory indexEdward Thomson2016-02-151-12/+23
| | | | | | When performing an in-memory rebase, keep a single index for the duration, so that callers have the expected index lifecycle and do not hold on to an index that is free'd out from under them.
* rebase: allow custom merge_optionsEdward Thomson2016-02-111-2/+2
| | | | | | Allow callers of rebase to specify custom merge options. This may allow custom conflict resolution, or failing fast when conflicts are detected.
* rebase: introduce inmemory rebasingEdward Thomson2016-02-111-117/+250
| | | | | | | | | | Introduce the ability to rebase in-memory or in a bare repository. When `rebase_options.inmemory` is specified, the resultant `git_rebase` session will not be persisted to disk. Callers may still analyze the rebase operations, resolve any conflicts against the in-memory index and create the commits. Neither `HEAD` nor the working directory will be updated during this process.
* Fix #3094 - improve use of portable size_t/ssize_t format specifiers.Matthew Plough2015-07-121-2/+2
| | | | The header src/cc-compat.h defines portable format specifiers PRIuZ, PRIdZ, and PRIxZ. The original report highlighted the need to use these specifiers in examples/network/fetch.c. For this commit, I checked all C source and header files not in deps/ and transitioned to the appropriate format specifier where appropriate.
* Initialize a few variablesCarlos Martín Nieto2015-06-091-1/+1
| | | | | | Coverity complains about the git_rawobj ones because we use a loop in which we keep remembering the old version, and we end up copying our object as the base, so we want to have the data pointer be NULL.
* rebase: include checkout opts within rebase optsEdward Thomson2015-04-201-14/+6
|
* rebase: init and open take a rebase_optionsEdward Thomson2015-04-201-114/+118
| | | | | | `git_rebase_init` and `git_rebase_open` should take a `git_rebase_options` and use it for future rebase operations on that `rebase` object.
* rebase: take `checkout_options` where appropriateEdward Thomson2015-04-201-15/+29
|
* rebase: block rebase_commit with unstaged changesEdward Thomson2015-04-201-20/+30
|
* rebase: identify a rebase that has not startedEdward Thomson2015-04-201-1/+1
| | | | | | In `git_rebase_operation_current()`, indicate when a rebase has not started (with `GIT_REBASE_NO_OPERATION`) rather than conflating that with the first operation being in-progress.
* Plug a few leaksCarlos Martín Nieto2015-03-041-2/+2
|
* reset: remove reflog message overrideCarlos Martín Nieto2015-03-031-1/+1
| | | | | This function is meant to simulate what git does in the reset command, so we should include the reflog message in that.
* Remove the signature from ref-modifying functionsCarlos Martín Nieto2015-03-031-11/+12
| | | | | | | | | | 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.