-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Non-sticky range diff #3862
Comments
After re-reading this I realize that my use of the term "non-sticky" could be confusing here. I'm using it for describing this new lightweight ad-hoc range selection diff mode, as opposed to the sticky shift-W mode. However, we also use sticky vs. non-sticky for the difference between a |
I like this idea a lot. I also share your intuition that it's better to do ^A..B than to do A..B but it does kinda lock us in to that pattern. If we used A..B everywhere then the logic is simple and consistent: it can be applied in any view that contains commits including the reflog view and the divergence view (e.g. when comparing two commits that are from the two different branches). But, we can just say that that if you want A..B, you can do a sticky diff. In answer to your questions:
If the purpose is to show the combined diff of all selected commits, then that's not something anybody will need in the reflog view, so I'd just stick to master's behaviour
Hmm. Wonder if there's a command to literally show a combined diff of N commits rather than specifying the two terminals. That might make this easier to implement for edge cases like that.
Agreed on keeping the master behaviour in that case. I don't think an error is necessary: diffing mode takes precedent over the non-diffing mode diff and that can be true whether a range is selected or not. |
Good that you bring this up, I had missed that. This would also be an error condition like the others below.
I agree.
Would you be opposed to an error message though? I would find that less confusing, and I think it will also be easier to implement.
I don't think there is, and I'm also not sure how that could possibly work in case there are conflicts.
Same here, would you be opposed to an error in that case? |
Good point, I forgot that git's diffs are based on snapshots, not patches. As for errors: with the reflog view it feels over-the-top to me: the fact we show a combined diff is a nice bonus imo. It seems weird that if you are in fact just using the multi-select to perform some bulk action, we're going to show an error in case you're actually trying to see a combined diff. With sticky diff mode, I think it's more appropriate to show an error because it would be especially strange to do anything with a range select in that case. |
Good point, this makes sense. Too bad, this will make the implementation trickier. I'll see if I can solve this somehow. |
PR is here: #3869. |
I often want to see the diff of a range of commits. The two main use cases are:
z
to undo; however, that doesn't work well with stacked branches.Both of these can be solved today using diffing mode (navigate down to one end of the range (one after the end, that is), hit
shift-W
, navigate up to the other end). This results in exactly what I want to see (including being able to hit enter to see the files of the diff, even being able to create a custom patch from it). However, this is too many key-presses, it's not very easy to discover, and it's too sticky (it happens too often that I forget I'm in this mode, and then I move the selection around looking at diffs that make absolutely no sense).I would find it totally intuitive if, whenever I range-select several commits (either a sticky range using
v
, or a non-sticky range using shift-arrow), I would see a diff of the range of those commits. This would perfectly match the general concept of "show me details of whatever is selected in the side panel", and it would solve the use cases above perfectly for me. I also want to be able to hit enter to work on the files of this range diff, like in diffing mode.Other git clients have a similar feature, but it works slightly differently:
I understand that selecting one commit below the start of the range makes sense because it is closer to what you do on the command line. If you have commits A, B and C, then
git diff A..C
displays the combined diff of B and C, but doesn't include A's changes. That's what Fork and Sublime Merge (and shift-W in lazygit) try to emulate, it seems. But for a range selection of commits I find this very unintuitive: I want to see the combined diff of all the commits that I have selected, so I'm strongly proposing to do agit diff A^..C
if A, B, and C are selected.Note that I'm not proposing to replace diffing mode with this new non-sticky diff mode; diffing mode is probably still useful for diffing two things from different panels, e.g. a tag against a commit, or a commit against a branch.
I'm pretty far along implementing this, but I have a few questions that I'm unsure about:
The text was updated successfully, but these errors were encountered: