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

Annotations perhaps needed #5

Open
svenssonaxel opened this issue Nov 4, 2022 · 1 comment
Open

Annotations perhaps needed #5

svenssonaxel opened this issue Nov 4, 2022 · 1 comment

Comments

@svenssonaxel
Copy link
Owner

There is a case for adding syntax to annotate content lines, hunks, file comparisons and diff files.

First, there is the use case of diff tools that need to communicate more semantic information than what is possible using just content and snippet lines. This might be necessary in order to make a generic merge tool that takes hintful diffs as input, for example to override the default indentation handling. It would probably be necessary to allow annotations for individual content lines.

Second, it would be good if the format could be made useful for next-generation version control software. Even if we don't expect it will be common to produce patches that work in more than one version control system, at least some consumers such as visualizers and highlighters would not care about the version control system.

Since we don't necessarily know what features might be needed for this, we might want to aim for extensibility. Unified diff format is already extensible, since comments can be inserted at least between file comparisons - this is what the compat format uses. Taking pijul as an example, it seems that it would be necessary to annotate the diff file, as well as hunks.

Proposal:

  • Before the first file comparison, lines beginning with anything else than diff are considered annotations for the diff file. Check how this agrees with unified diff format.
  • After a comparison header and before the first hunk, any line not beginning with @ or one of the standard extended header words is considered an annotation for that file comparison.
  • Before a hunk header, lines beginning with @ but not @@ are considered annotations for that hunk.
  • Before a content or snippet line, lines beginning with @ but not @@ are considered annotations for that line.
  • The three latter types of annotations must have matching prefix.
@svenssonaxel
Copy link
Owner Author

Perhaps an annotation @=<snippet-name> for more succinct tagging of individual content lines as equal to a named snippet.

This could make it efficient to e.g. tag all changed uses and the definition for an identifier, at least in order to create merge conflicts where otherwise automatic merges produce the wrong result, and perhaps even produce correct merges. Example: One change renames a variable, another change adds a use of that variable.

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

No branches or pull requests

1 participant