Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve rebase onto commit selection #10879

Conversation

pmiossec
Copy link
Member

Improvement over #9686

Proposed changes

  • Hide stashes in revision grid when selecting commit range (now that we display all the stashes in the revision grid)
  • Select first parent which is a better default selection. So if the user want to rebase only one commit (which is not so rare), he only has to validate the selection...

Screenshots

Before

We see stashes and the selection is on the tip of the branch:
image

After

Stashes are not displayed and the 2nd commit of the branch is selected
image

Test methodology

  • Manual

Test environment(s)

  • Git Extensions 33.33.33
  • Build 74ad450
  • Git 2.40.0.windows.1
  • Microsoft Windows NT 10.0.22621.0
  • .NET 6.0.15
  • DPI 96dpi (no scaling)

Merge strategy

Rebase merge.


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned pmiossec Apr 13, 2023

try
{
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true);
AppSettings.ShowStashes = false;
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also work for detached head?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, failure to parse will give null (no error popup)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a little changed that to improve when in detached head and have the same behavior (even if I really don't see the case of rebasing in detached head)

using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true);
AppSettings.ShowStashes = false;
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~");
var preSelectedCommit = string.IsNullOrEmpty(txtFrom.Text) ? firstParent?.ToString() ?? string.Empty : txtFrom.Text;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var preSelectedCommit = string.IsNullOrEmpty(txtFrom.Text) ? firstParent?.ToString() ?? string.Empty : txtFrom.Text;
string preSelectedCommit = string.IsNullOrEmpty(txtFrom.Text) ? firstParent?.ToString() ?? string.Empty : txtFrom.Text;

Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


try
{
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true);
AppSettings.ShowStashes = false;
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: This should be queried from RevGrid to avoid extra Git commands. It is Git access that slows down the app...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree in this case.
In this control we don't have access to the revision grid and I had a look, it will add a lot of logic to be able to pass the needed information as the form browse is called in multiple case (rebase, interactive, rebase onto, ....). So more than 4 or 6 different cases to handle.

And for the performance, doing a revparse is very quick (around 40ms) which is much less than requesting the logs to display the revision grid and opening the form. And also the goal of this feature is to make the use more convenient when you want to rebase onto only one commit and in this case, you probably gain 2 or 3s. So the net gain should be good 😉


try
{
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true);
AppSettings.ShowStashes = false;
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, failure to parse will give null (no error popup)

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo the other comments

@pmiossec pmiossec force-pushed the improve_rebase_onto_commit_selection branch from 74ad450 to 4370d91 Compare April 14, 2023 07:13
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true);
AppSettings.ShowStashes = false;
ObjectId firstParent = UICommands.GitModule.RevParse("HEAD~");
string preSelectedCommit = string.IsNullOrEmpty(txtFrom.Text) ? firstParent?.ToString() ?? string.Empty : txtFrom.Text;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Text value can't be null, but it can whitespace. So the check should be IsNullOrWhitespace.
Also suggest to invert the condition as it'd read easier.

due to how rebase onto is working
(the selected revision is excluded from the rebase --as it is the "base")

So if the user want to rebase only one commit (which is not so rare),
he only has to validate the selection...
@pmiossec pmiossec force-pushed the improve_rebase_onto_commit_selection branch from 4370d91 to 400d6e9 Compare April 14, 2023 10:03
@vbjay
Copy link
Contributor

vbjay commented Apr 14, 2023 via email

@pmiossec
Copy link
Member Author

If there isn't a toggle to take off the first parent then I don't think it's a good idea. That will upset a lot of people if they can't select a mid work commit. If a visible toggle is there to allow them to turn it off, then that would be ok.

@vbjay I absolutely don' t understand you point of view.
This feature prevent no one to select the commit he wants. That's just that a better commit is pre-selected (because it makes no sense for the user to select the 1st as base) and so in the best case the user has just to validate. Wort case, he just has to select the commit he wants as base commit.
The only thing that could happen to the user is that he economize 1 click and some seconds...

@vbjay
Copy link
Contributor

vbjay commented Apr 14, 2023

If there isn't a toggle to take off the first parent then I don't think it's a good idea. That will upset a lot of people if they can't select a mid work commit. If a visible toggle is there to allow them to turn it off, then that would be ok.

@vbjay I absolutely don' t understand you point of view.
This feature prevent no one to select the commit he wants. That's just that a better commit is pre-selected (because it makes no sense for the user to select the 1st as base) and so in the best case the user has just to validate. Wort case, he just has to select the commit he wants as base commit.
The only thing that could happen to the user is that he economize 1 click and some seconds...

Select first parent along with commit grid after image sounded like he set show first parents.

@mstv
Copy link
Member

mstv commented Apr 14, 2023

Select first parent along with commit grid after image sounded like he set show first parents.

Yes, but only for short time. :)

@vbjay
Copy link
Contributor

vbjay commented Apr 14, 2023

How do you know they didn't want to rebase in-between 2 first parents? Forcing them to only select between 1st parents without giving them the option to turn it off is my problem with it.

@pmiossec
Copy link
Member Author

How do you know they didn't want to rebase in-between 2 first parents? Forcing them to only select between 1st parents without giving them the option to turn it off is my problem with it.

In 10 years of using GE, I never tried to do that so it should not happen too often.
So in this case, either they use #10885 or they copy/paste the hash from revision grid should be enough....

@vbjay
Copy link
Contributor

vbjay commented Apr 14, 2023

You are not the only user of ge. All I'm saying is if you are going to only show first parents in the select commit dialog, then show the first parents togle button on dialog to make it clear and to allow the user to have control. I don't mind first parents. I do have a problem with it being forced.

@pmiossec
Copy link
Member Author

pmiossec commented Apr 14, 2023

All I'm saying is if you are going to only show first parents in the select commit dialog

If fact I don't know why you start a discussion on a false subject....
The PR is absolutely not about that (it's just hide stash and preselect another commit)
And looking at the code, what you could have easily done, we do not enable the "view first parent" feature.
So everything is ok....

@vbjay
Copy link
Contributor

vbjay commented Apr 14, 2023

All I'm saying is if you are going to only show first parents in the select commit dialog

If fact I don't know why you start a discussion on a false subject....
The PR is absolutely not about that (it's just hide stash and preselect another commit)
And looking at the code, what you could have easily done, we do not enable the "view first parent" feature.
So everything is ok....

Awesome. It was the description and the image that made me think the select dialog had been altered to only show first parents. I could see a ton of people who use that dialog getting very upset over not being able to select a non 1st parent. Having it automatically go down one commit so we don't have to is another thing entirely. The image made me think it was the first thing. So I made sure.

@pmiossec pmiossec merged commit 9d97624 into gitextensions:release/4.1 Apr 15, 2023
3 checks passed
@pmiossec pmiossec deleted the improve_rebase_onto_commit_selection branch April 15, 2023 08:54
@RussKie RussKie added this to the 4.1 milestone Apr 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants