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

A minimal builtin rebase#32

Closed
dscho wants to merge 11 commits intogitgitgadget:pk/rebase-in-cgitgitgadget/git:pk/rebase-in-cfrom
dscho:rebase-in-c-2-basicdscho/git:rebase-in-c-2-basicCopy head branch name to clipboard
Closed

A minimal builtin rebase#32
dscho wants to merge 11 commits intogitgitgadget:pk/rebase-in-cgitgitgadget/git:pk/rebase-in-cfrom
dscho:rebase-in-c-2-basicdscho/git:rebase-in-c-2-basicCopy head branch name to clipboard

Conversation

@dscho
Copy link
Member

@dscho dscho commented Sep 4, 2018

This patch series provides the bare minimum to run more than just the trivial rebase (i.e. git rebase <upstream>): it implements the most common options such as --onto.

It is based the latest iteration of pk/rebase-in-c.

This is the second patch series that brings us more closer to a builtin "git rebase".

Changes since v1:

  • Many commit messages were reworded.
  • An indentation fix was folded into the commit that introduces the incorrect indentation.
  • A missing space after a comma was inserted.

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: Johannes Schindelin <johannes.schindelin@gmx.de>
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 it would be nice to retain this distinction, dropping it makes it
possible to simply use the `get_oid_mb()` function. Besides, it happens
rarely in real-world scenarios.

Therefore, in the interest of keeping the code less complex, let's just
use that function, and live with an error message that does not
distinguish between those two error conditions.

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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: Johannes Schindelin <johannes.schindelin@gmx.de>
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 default being `false` for both verbose and quiet mode,
passing the `--quiet` option will turn off verbose mode, and `--verbose`
will turn off quiet mode.

This patch introduces the `flags` bit field, with `REBASE_NO_QUIET`
as first user (with many more to come).

We do *not* use `REBASE_QUIET` here for an important reason: To keep the
implementation simple, this commit introduces `--no-quiet` instead of
`--quiet`, so that a single `OPT_NEGBIT()` can turn on quiet mode and
turn off verbose and diffstat mode at the same time. Likewise, the
companion commit which will introduce support for `--verbose` will have
a single `OPT_BIT()` that turns off quiet mode and turns on verbose and
diffstat mode at the same time.

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

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

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 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>
Copy link
Member Author

dscho commented Nov 2, 2018

This branch is now known as pk/rebase-in-c-2-basic.

Copy link
Member Author

dscho commented Nov 2, 2018

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

Copy link
Member Author

dscho commented Nov 2, 2018

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

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>

This comment has been minimized.

Copy link
Member Author

dscho commented Nov 5, 2018

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

Copy link
Member Author

dscho commented Nov 5, 2018

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

Copy link
Member Author

dscho commented Nov 5, 2018

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

@dscho dscho added the master label Nov 5, 2018 — with GitGitGadget
@dscho dscho closed this Nov 5, 2018
Copy link
Member Author

dscho commented Nov 5, 2018

Closed via e0720a3.

@dscho dscho deleted the rebase-in-c-2-basic branch November 5, 2018 21:10
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.