-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Allow the fixup helper to return commits on the main branch with a warning. #5193
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
base: master
Are you sure you want to change the base?
feat: Allow the fixup helper to return commits on the main branch with a warning. #5193
Conversation
da39708 to
9328219
Compare
|
This PR now shares a commit with #5201 that moves the creation of the |
9328219 to
dff66dc
Compare
dff66dc to
3ebecf6
Compare
|
I'm against merging this, sorry.
I disagree, I see no reason for ever doing this (except when the fixup is for an unpushed commit on main, but in that case ctrl-f works, since I find the behavior of showing the warning and then selecting the commit anyway confusing, so I'd rather stay with the current behavior of showing an error.
That is true, but it's a different feature, and I wouldn't abuse the ctrl-f command for it. To expand on that: I don't usually use git blame; when I want to do history archeology, I use gitk's "Show origin of this line" command. It allows me to jump to the commit that last changed a given line (and then further back from there if that wasn't yet the change I was looking for). This is super useful functionality, and it would be great to have it in lazygit, however there are lots of challenges to be solved for it. But let's not shoehorn this into the ctrl-f command. |
When I start a new project I normally start developing on Another use case might be the removal of accidental pushed credentials. There are some valid (but maybe rare) reasons to force push main (One of them is if the user just doesn't care about that sort of thing). lazygit shouldn't make that decision for the users. So I disagree with your assessment and will slightly change my argumentation for this change: The function is called "Find base commit for fixup". If a base commit is found it should be shown, regardless of which branch it is on. The decision if a commit should be "fixup-able" should not be done in the "find base commit" function. If you want to prevent fixups of commits that are already on
The "only added lines" case already did this, before. But I arguably ignored/forgot that case with my added PRs. Though I don't want to have two confirmations after another and don't find that warning particularly helpful anyway. I already know the function isn't always perfect. From UX side the confirmation behaves exactly the same as the error in the way, that it opens a popup, with what I would consider useful information to display. But the confirmation additionally gives you the choice if you want to jump to that commit or not depending on the information given in the popup. If you used
Yes, that |
I just ran into this again, and it does not work for repositories that have no remote/are not pushed at all, because then |
|
I can see your point, but I'm still not really convinced.
That's true, and maybe we should consider adding stronger warnings to prevent shooting yourself in the foot when you do these things on a master commit. However, in this case my argument is not that I want to protect the user from doing something stupid, but that I want to make the feature easier to understand, and in my book the current behavior is simpler and easier to understand than your proposed changed behavior. Also, for the use case that you are describing (cleaning up a fresh, not-yet-published repo) there are easy workarounds to allow you to do what you want. For example, you can rename your git:
mainBranches: []Both of these things allow you to fixup your main commits to your heart's content. I know what you will respond: "But I shouldn't have to use those workarounds!" For me, this is a good balance between keeping the feature simple (and the code, which I also find crucial) and still allowing people with special requirements to get their work done. I'll leave this open for now in case others want to chime in. |
|
Because you already envisioned my first response I will give you my second: I would have never thought about changing the main branch temporarily or would know how to set that config. That requires deep knowledge and consideration and switching from thinking about the current (actual) work to thinking about how to circumvent this in lazygit - then it's just easier to use I also don't really see, how this change makes the feature harder to understand or more complicated, tbh. Quite the opposite, I find the current behavior confusing, because "the commit I want to fixup is right there, just bring me to it, why won't you do it 😭". So I also can't think of a way to make it easier to understand or less complicated. Crossing my fingers for more people in support of that feature to chime in. 🙂 🤞 |
|
What do you think about only allowing to find base commits on the main branch if the current checked out branch IS the main branch? |
|
If I may add to this argument: I tried the proposed workaround by removing main branches. 🙃 So basically, whatever the reason I do it for, if I need to simply look up the commit that is the base for the current change, I have to go to a terminal and use log/blame. For example, in UPD: correction. It does work for the span of unpublished commits between HEAD and remote. But the ability to find base commit is so basic, that I hardly can understand any reasoning not to allow it. Fixing up published commits is a different matter, but even this is just a place for a modal warning and per-project rules, IMHO. |
PR Description
Sometimes it is permissible/required to fixup a commit, even though it is already on the
mainbranch. Even if it is not permissible it might be useful information which commit would have to be changed.This PR changes the ctrl-f function to instead of showing an error when the commit is already merged to only show a confirmation warning.
Please check if the PR fulfills these requirements
go generate ./...)