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
Improve rebase onto commit selection #10879
Conversation
GitUI/CommandsDialogs/FormRebase.cs
Outdated
|
||
try | ||
{ | ||
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true); | ||
AppSettings.ShowStashes = false; | ||
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~"); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)
GitUI/CommandsDialogs/FormRebase.cs
Outdated
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var preSelectedCommit = string.IsNullOrEmpty(txtFrom.Text) ? firstParent?.ToString() ?? string.Empty : txtFrom.Text; | |
string preSelectedCommit = string.IsNullOrEmpty(txtFrom.Text) ? firstParent?.ToString() ?? string.Empty : txtFrom.Text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
GitUI/CommandsDialogs/FormRebase.cs
Outdated
|
||
try | ||
{ | ||
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true); | ||
AppSettings.ShowStashes = false; | ||
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~"); |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 😉
GitUI/CommandsDialogs/FormRebase.cs
Outdated
|
||
try | ||
{ | ||
using FormChooseCommit chooseForm = new(UICommands, txtFrom.Text, showCurrentBranchOnly: true); | ||
AppSettings.ShowStashes = false; | ||
ObjectId firstParent = UICommands.GitModule.RevParse(Currentbranch.Text + "~"); |
There was a problem hiding this comment.
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)
There was a problem hiding this 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
74ad450
to
4370d91
Compare
GitUI/CommandsDialogs/FormRebase.cs
Outdated
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; |
There was a problem hiding this comment.
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...
4370d91
to
400d6e9
Compare
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. |
Select first parent along with commit grid after image sounded like he set show first parents. |
Yes, but only for short time. :) |
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. |
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. |
If fact I don't know why you start a discussion on a false subject.... |
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. |
Improvement over #9686
Proposed changes
Screenshots
Before
We see stashes and the selection is on the tip of the branch:
After
Stashes are not displayed and the 2nd commit of the branch is selected
Test methodology
Test environment(s)
Merge strategy
Rebase merge.
✒️ I contribute this code under The Developer Certificate of Origin.