Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

builtin rebase options#33

Closed
dscho wants to merge 36 commits intogitgitgadget:pk/rebase-in-c-3-actsgitgitgadget/git:pk/rebase-in-c-3-actsfrom
dscho:rebase-in-c-4-optsdscho/git:rebase-in-c-4-optsCopy head branch name to clipboard
Closed

builtin rebase options#33
dscho wants to merge 36 commits intogitgitgadget:pk/rebase-in-c-3-actsgitgitgadget/git:pk/rebase-in-c-3-actsfrom
dscho:rebase-in-c-4-optsdscho/git:rebase-in-c-4-optsCopy head branch name to clipboard

Conversation

@dscho
Copy link
Member

@dscho dscho commented Sep 4, 2018

This patch series completes the support for all rebase options in the builtin rebase, e.g. --signoff, rerere-autoupdate, etc.

It is based on pk/rebase -in-c-3-acts.

Changes since v1:

  • Added the forgotten -k short option for --keep-empty (and verified that no other short options were forgotten).
  • The "Applied autostash" message is now translated (as was the original in the shell script version).

prertik added 30 commits August 10, 2018 13:37
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 introduces to the parse_options() call (which
"eats" argv[0]), the argc is now expected to be lower by one after this
patch, compared to before this patch: argv[0] no longer refers to the
command name, but to the first (non-option) command-line parameter.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit implements support for an --onto argument that is actually a
"symmetric range" i.e. `<rev1>...<rev2>`.

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 following the similar approach would be nice,
this would create more complexity than it is of current. Currently, for
simple convenience, the `get_oid_mb()` function is used whose return
value does not discern between those two error conditions.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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.

This commit goes further and introduces `--no-quiet` which is the
contrary of `--quiet` and it's introduction doesn't modify any
behaviour.

Note: The `flags` field in `rebase_options` will accumulate more bits in
subsequent commits, in particular a verbose and a diffstat flag. And as
--quoet inthe shell scripted version of the rebase command switches off
--verbose and --stat, and as --verbose switches off --quiet, we use the
(negated) REBASE_NO_QUIET instead of REBASE_QUIET: this allows us to
turn off the quiet mode and turn on the verbose and diffstat mode in a
single OPT_BIT(), and the opposite in a single OPT_NEGBIT().

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 back to
calling) git_default_config().

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit reads the index of the repository for rebase and checks
whether the repository is ready for rebase.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 expensive operation if, say, running an interactive
rebase).

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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, where we would really only want a valid,
fully-qualified ref name as value, and NULL for detached HEADs, using
"detached HEAD" for display only. Make it so.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit adds the option `--continue` which is used to resume
rebase after merge conflicts. The code tries to stay as close to
the equivalent shell scripts found in `git-legacy-rebase.sh` as
possible.

When continuing a rebase, the state variables are read from state_dir.
Some of the state variables are not actually stored there, such as
`upstream`. The shell script version simply does not set them, but for
consistency, we unset them in the builtin version.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit adds the option `--skip` which is used to restart
rebase after skipping the current patch.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit teaches the builtin rebase the "abort" action, which a user
can call to roll back a rebase that is in progress.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
With this patch, the builtin rebase handles the `--quit` action which
can be used to abort a rebase without rolling back any changes performed
during the rebase (this is useful when a user forgot that they were in
the middle of a rebase and continued working normally).

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
While these sub-commands are very different in spirit, their
implementation is almost identical, so we convert them in one go.

And since those are the last sub-commands that needed to be converted,
now we can also turn that `default:` case into a bug (because we should
now handle all the actions).

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit prevents actions (such as --continue, --skip) from running
when there is no rebase in progress.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit checks for the file `applying` used by `git am` in
`rebase-apply/` and if the file is present it means `git am` is in
progress so it errors out.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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: `--interactive`
followed by `--merge` won't reset the type to "merge" but keeps the type
as "interactive". And as t3418 tests this explicitly, we have to support
it in the builtin rebase, too.

Likewise, `--interactive` followed by `--preserve-merges` makes it an
"explicitly interactive" rebase, i.e. a rebase that should show the todo
list, while `--preserve-merges` alone is not interactive (and t5520
tests for this via `git pull --rebase=preserve`).

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 mode as fallback when figuring out which backend to use,
the C version needs to use a different route because the backend will
already be chosen during the `parse_options()` call.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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
rebase.autosquash. To support this, we also add a custom
rebase_config() function in this commit that will be used instead (and
falls back to) git_default_config().

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit introduces support for `--gpg-sign` option which is used
to GPG-sign commits.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 the interactive rebase into a
builtin.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit adds support for the `--exec` option which takes a shell
command-line as argument. This argument will be appended as an `exec
<cmd>` command after each line in the todo list that creates a commit in
the final history.  commands.

Note: while the shell script version of `git rebase` assigned the empty
string to `cmd` by default, we *unset* it here because the code looks
nicer and it does not change the behavior.

The `--exec` option requires `--interactive` machinery.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 `--allow-empty-message` overrides that behaviour which will allow
the commits having empty messages to continue in rebase operation.

Note: a very recent change made this the default in the shell scripted
`git rebase`, therefore the builtin rebase does the same.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The mode to rebase non-linear branches is now supported by the builtin
rebase, too.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 incorrect results). This did not matter when the function was
called in `git rev-parse --fork-point` because in that command, the
process definitely did not traverse any commits before exiting.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/gitgitgadget that referenced this pull request Sep 4, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member Author

dscho commented Sep 4, 2018

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Sep 4, 2018

An error occurred while submitting:

Error: git rev-list 95679cc...f155141 failed: 128,
fatal: Invalid symmetric difference expression 95679cc...f155141

@dscho
Copy link
Member Author

dscho commented Sep 4, 2018

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Sep 4, 2018

Submitted as pull.33.v2.git.gitgitgadget@gmail.com

@dscho dscho force-pushed the pk/rebase-in-c-3-acts branch from e01f72b to 0eabf4b Compare September 6, 2018 21:48
dscho added a commit to dscho/gitgitgadget that referenced this pull request Nov 1, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/gitgitgadget that referenced this pull request Nov 5, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/gitgitgadget that referenced this pull request Nov 5, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/gitgitgadget that referenced this pull request Nov 5, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Copy link
Member Author

dscho commented Nov 5, 2018

This branch is now known as pk/rebase-in-c-4-opts.

Copy link
Member Author

dscho commented Nov 5, 2018

This patch series was integrated into pu via git@0293121.

Copy link
Member Author

dscho commented Nov 5, 2018

This patch series was integrated into next via git@0293121.

Copy link
Member Author

dscho commented Nov 5, 2018

This patch series was integrated into master via git@0293121.

Copy link
Member Author

dscho commented Nov 5, 2018

Closed via 0293121.

@dscho dscho deleted the rebase-in-c-4-opts branch November 5, 2018 21:07
dscho added a commit to dscho/gitgitgadget that referenced this pull request Nov 5, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/gitgitgadget that referenced this pull request Dec 15, 2018
It is pretty nice to use GitGitGadget. But what if a patch series had
already been started without GitGitGadget?

Fear not. This script can be used to initialize the PR metadata
accordingly.

It is still a very manual, error-prone process (the information about
the number of patches should be taken from the cover letter, the tip
commit should be verified against the latest diff, and the base commit
should be determined automatically, just like the iteration).

If need be, we can start from here, automating one little piece by one
little piece.

The primary reason for this was to allow submitting v2 iterations for
rebase-in-c-2-basic and rebase-in-c-4-opts:
gitgitgadget/git#32 and
gitgitgadget/git#33

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.