[PATCH v2 12/18] builtin rebase: support `--exec`

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for the `--exec` option which takes a shell command-line as argument. This argument will be appended as an `exec ` command after each line in the todo list that creates a commit in the final history. commands. Note: while the shell script version of

[PATCH v2 17/18] builtin rebase: add support for custom merge strategies

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki When running a rebase in non-am mode, it uses the recursive merge to cherry-pick the commits, and the rebase command allows to configure the merge strategy to be used in this operation. This commit adds that support to the builtin rebase. Signed-off-by: Pratik Karki

[PATCH v2 16/18] builtin rebase: support `fork-point` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for `--fork-point` and `--no-fork-point`. This is converted as-is from `git-legacy-rebase.sh`. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 11 +++ 1 file changed, 11 insertions(+) diff --git

[PATCH v2 11/18] builtin rebase: support `--autostash` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki To support `--autostash` we introduce a function `apply_autostash()` just like in `git-legacy-rebase.sh`. Rather than refactoring and using the same function that exists in `sequencer.c`, we go a different route here, to avoid clashes with the sister GSoC project that turns

[PATCH v2 13/18] builtin rebase: support `--allow-empty-message` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit introduces the `--allow-empty-message` option to `builtin/rebase.c`. The motivation behind this option is: if there are empty messages (which is not allowed in Git by default, but can be imported from different version control systems), the rebase will fail. Using

[PATCH v2 18/18] builtin rebase: support --root

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This option allows to rebase entire histories up to, and including, the root commit. The conversion from the shell script is straight-forward, apart from the fact that we do not have to write an empty tree in C. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin

[PATCH v2 09/18] builtin rebase: support `--gpg-sign` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit introduces support for `--gpg-sign` option which is used to GPG-sign commits. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/builtin/rebase.c

[PATCH v2 15/18] merge-base --fork-point: extract libified function

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki We need this functionality in the builtin rebase. Note: to make this function truly reusable, we have to switch the call get_merges_many_dirty() to get_merges_many() because we want the commit flags to be reset (otherwise, subsequent get_merge_bases() calls would obtain

[PATCH v2 10/18] builtin rebase: support `-C` and `--whitespace=`

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit converts more code from the shell script version to the builtin rebase. In this instance, we just have to be careful to keep support for passing multiple `--whitespace` options, as the shell script version does so, too. Signed-off-by: Pratik Karki Signed-off-by:

[PATCH v2 14/18] builtin rebase: support --rebase-merges[=[no-]rebase-cousins]

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki The mode to rebase non-linear branches is now supported by the builtin rebase, too. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 21 + 1 file changed, 21 insertions(+) diff --git a/builtin/rebase.c

[PATCH v2 08/18] builtin rebase: support `--autosquash`

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for the `--autosquash` option which is used to automatically squash the commits marked as `squash` or `fixup` in their messages. This is converted following `git-legacy-rebase.sh` closely. This option can also be configured via the Git config setting

[PATCH v2 07/18] builtin rebase: support `keep-empty` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki The `--keep-empty` option can be used to keep the commits that do not change anything from its parents in the result. While the scripted version uses `interactive_rebase=implied` to indicate that the rebase needs to use the `git-rebase--interactive` backend in non-interactive

[PATCH v2 06/18] builtin rebase: support `ignore-date` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for `--ignore-date` which is passed to `git am` to easily change the dates of the rebased commits. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 8 1 file changed, 8 insertions(+) diff --git

[PATCH v2 02/18] builtin rebase: support --signoff

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for `--signoff` which is used to add a `Signed-off-by` trailer to all the rebased commits. The actual handling is left to the rebase backends. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 17

[PATCH v2 05/18] builtin rebase: support `ignore-whitespace` option

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for the `--ignore-whitespace` option of the rebase command. This option is simply passed to the `--am` backend. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 6 ++ 1 file changed, 6 insertions(+) diff

[PATCH v2 03/18] builtin rebase: support --rerere-autoupdate

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki The `--rerere-autoupdate` option allows rerere to update the index with resolved conflicts. This commit follows closely the equivalent part of `git-legacy-rebase.sh`. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 25

[PATCH v2 04/18] builtin rebase: support --committer-date-is-author-date

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This option is simply handed down to `git am` by way of setting the `git_am_opt` variable that is handled by the `git-rebase--am` backend. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 10 ++ 1 file changed, 10 insertions(+)

[PATCH v2 01/18] builtin rebase: allow selecting the rebase "backend"

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki With this commit the builtin rebase supports selecting the "rebase backends" (or "type") `interactive`, `preserve-merges`, and `merge`. The `state_dir` was already handled according to the rebase type in a previous commit. Note that there is one quirk in the shell script:

[PATCH v2 07/11] builtin rebase: try to fast forward when possible

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki In this commit, we add support to fast forward. Note: we will need the merge base later, therefore the call to can_fast_forward() really needs to be the first one when testing whether we can skip the rebase entirely (otherwise, it would make more sense to skip the possibly

[PATCH v2 10/11] builtin rebase: only store fully-qualified refs in `options.head_name`

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki When running a rebase on a detached HEAD, we currently store the string "detached HEAD" in options.head_name. That is a faithful translation of the shell script version, and we still kind of need it for the purposes of the scripted backends. It is poor style for C, though,

[PATCH v2 04/11] builtin rebase: support --quiet

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit introduces a rebase option `--quiet`. While `--quiet` is commonly perceived as opposite to `--verbose`, this is not the case for the rebase command: both `--quiet` and `--verbose` default to `false` if neither `--quiet` nor `--verbose` is present. Despite the

[PATCH v2 02/11] builtin rebase: support `git rebase --onto A...B`

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit implements support for an --onto argument that is actually a "symmetric range" i.e. `...`. The equivalent shell script version of the code offers two different error messages for the cases where there is no merge base vs more than one merge base. Though it would

[PATCH v2 11/11] builtin rebase: support `git rebase `

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit adds support for `switch-to` which is used to switch to the target branch if needed. The equivalent codes found in shell script `git-legacy-rebase.sh` is converted to builtin `rebase.c`. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin ---

[PATCH v2 09/11] builtin rebase: start a new rebase only if none is in progress

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki To run a new rebase, there needs to be a check to assure that no other rebase is in progress. New rebase operation cannot start until an ongoing rebase operation completes or is terminated. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c

[PATCH v2 03/11] builtin rebase: handle the pre-rebase hook and --no-verify

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit converts the equivalent part of the shell script `git-legacy-rebase.sh` to run the pre-rebase hook (unless disabled), and to interrupt the rebase with error if the hook fails. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c |

[PATCH v2 01/11] builtin rebase: support --onto

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki The `--onto` option is important, as it allows to rebase a range of commits onto a different base commit (which gave the command its odd name: "rebase"). This commit introduces options parsing so that different options can be added in future commits. Note: As this commit

[PATCH v2 05/11] builtin rebase: support the `verbose` and `diffstat` options

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit introduces support for the `-v` and `--stat` options of rebase. The --stat option can also be configured via the Git config setting rebase.stat. To support this, we also add a custom rebase_config() function in this commit that will be used instead of (and falls

[PATCH v2 08/11] builtin rebase: support --force-rebase

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki In this commit, we add support to `--force-rebase` option. The equivalent part of the shell script found in `git-legacy-rebase.sh` is converted as faithfully as possible to C. The --force-rebase option ensures that the rebase does not simply fast-forward even if it could.

[PATCH v2 06/11] builtin rebase: require a clean worktree

2018-09-04 Thread Pratik Karki via GitGitGadget
From: Pratik Karki This commit reads the index of the repository for rebase and checks whether the repository is ready for rebase. Signed-off-by: Pratik Karki Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 11 +++ 1 file changed, 11 insertions(+) diff --git