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

Show diff in file-visiting buffer #2952

Open
tarsius opened this issue Jan 11, 2017 · 0 comments
Open

Show diff in file-visiting buffer #2952

tarsius opened this issue Jan 11, 2017 · 0 comments
Labels
area: diff enhancement New feature or request

Comments

@tarsius
Copy link
Member

tarsius commented Jan 11, 2017

Some packages exist for displaying diff information directly in file-visiting buffers. diff-hl is the one I use.

This is certainly very nice, since you can see which lines were added or modified and that some line(s) before some remaining line were removed. But this does not give you the full story, since you cannot see the old versions, for that you have to look at the actual diff.

Diffs a certainly nice, since you can see the context of a change, including the old version. Sometimes you need a little more context, and then arguments such as --function-context come in handy. But sometimes you want even more context, and for that you have to switch back to the file-visiting buffer. Also it currently isn't possible to edit a diff directly (but see #2938), so here too you have to switch back to the diff.

Then again you might not want to see all the context... more on that later.

In a sense there already exists support for showing diffs inside a file-visiting buffer, or rather there exists a package smerge that prettifies diffs that are shown inside such buffers because the visited file contains them. That is the case when a merge conflict occurs and git puts both (or all three) versions into the file.

But while there are some similarities between smerge and the feature I am proposing here - in both cases commands such as "go to next change" are highly desirable, for example - they are also very different.

Most importantly in the case of smerge the diff markup is actual text that is part of the buffer and file, while in the case of the feature proposed here, the diff stuff has to be kept out of the file and only be displayed using overlays (that's only one implementation strategy). That makes this quite a bit harder.

The "diff overlay" feature proposed here, lets give it the nickname sdiff, should be implemented as a minor-mode. Lets think about some of its features:

  • Conflicts should be collapsible like in Magit buffers.
    • But unlike in Magit buffers it probably makes less sense to collapse complete hunks and more sense to collapse only "sides" of the change.
    • At times it might also be nice to collapse the "additional context", which you don't get in actual diffs. After collapsing the "context" and fully expanding the "hunks", the buffer would look similar to how the diff itself would look in Magit; there are just some additional "context headings" sprinkled in between.
  • (more to come)

Big open questions:

  • What is the relationship to packages such as diff-hl? Do we contribute to that, fork it, implement an alternative?
  • (more to come)
@tarsius tarsius added the enhancement New feature or request label Jan 11, 2017
@tarsius tarsius mentioned this issue Feb 13, 2017
12 tasks
@tarsius tarsius added this to the 2.14.0 milestone Mar 29, 2018
@tarsius tarsius removed this from the 2.93.0 milestone Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: diff enhancement New feature or request
Development

No branches or pull requests

1 participant