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

feature: inline diff select commit/branch to diff #1855

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ta946
Copy link

@ta946 ta946 commented Jan 17, 2024

Inline diff currently compares the file's current state vs the last commit, then you can cycle through previous states using n/p.
My usecase is usually current state vs last commit or completely different branch/commit so I've come up with a workaround.

image

Manual commit id entry
image

Branches
fetches the branch list then it will compare against the lastest commit in that branch
image

Commits
fetches the last N commits (default is 20) along with the commit message
image

Theres probably a better way of integrating the idea with the graph view, but this was good enough for me to whip up quickly. Thought id share incase it can be adapted and be a useful idea/addition

@kaste
Copy link
Collaborator

kaste commented Jan 26, 2024

Not sure what to do with this one. Did you even pushed the correct version? I don't see how having a normal WindowCommand in class SelectInlineDiffCommitCommand(WindowCommand): can call git e.g. commit_text_list = self.git('log',.... The code is not very aligned with what we have, the checks are also red here.

I do like the idea to some extend. T.i. I can imagine being in an inline-diff view to hit maybe [t] which will open a quick panel to set a different target. Or is it base, I never remember these correctly.

You're correct that there aren't any obvious other ways to open a "historical" inline-diff. I think you can add normal diffs between branches and/or commits, e.g. from the graph or branches views. And then when you're seeing such a diff you can open the inline diff which will copy the target and base correctly. That's a rather indirect feature.

We could have it in the menu of a File History. Inline diffs show only one file at a time, that's why we don't have links for them in say the branches view or the standard graph view. It just doesn't fit as long as you're not in a context of a file. From that perspective one could add a command to the file revision views to then compare that file revision with the current HEAD/working dir state.

@ta946
Copy link
Author

ta946 commented Jan 27, 2024

you're right, i forgot to push the commit which allows calling git, I'm using different code on my machine that doesn't modify gitsavvy so it can update without me losing this functionality. pushed now.

Tbh, this was a low quality PR that doesn't make proper use of gitsavvy's codebase and features, i haven't delved into it enough to contribute correctly. Just wanted to share the idea and if it was something you guys liked, then I could try spending time on fixing it, with some direction

yea wrt using the graph, as there is no context of a file I couldn't think of an easy way to get this functionality without having to go through a few steps that might seem abit convoluted. Maybe a command that when selecting to compare with another commit, a quick panel can open to select a file?

As for while in File History, I assume it only follows the current branch? That covers my use case 90% of the time, but sometimes I want to compare against a different branch that is newer

So yea, please let me know if this idea seems useful, maybe abit more brainstorming is needed for workflow, and I can give it more attention

@kaste
Copy link
Collaborator

kaste commented Jan 30, 2024

I don't forget you, I'm just a bit busy, okay?

@ta946
Copy link
Author

ta946 commented Jan 30, 2024

no problem at all, there's no rush

tai added 2 commits March 5, 2024 15:59
fix: add GitCommand inheritance
fix: git branches should be git branch
fix: window command needs window active view instead of self.view
fix: get base_commit from git instead of view settings
@ta946 ta946 force-pushed the 20230117_choose_inline_diff_commit branch from a198d7a to 88426fd Compare March 5, 2024 05:00
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.

2 participants