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

Add Support for custom patch hunk headers (with some builtins) #194

Open
paulcavallaro opened this issue Feb 9, 2022 · 1 comment
Open

Comments

@paulcavallaro
Copy link

From gitattributes(5) documentation: https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header

Each group of changes (called a "hunk") in the textual diff output is prefixed with a line of the form:

@@ -k,l +n,m @@ TEXT

This is called a hunk header. The "TEXT" portion is by default a line that begins with an alphabet, an underscore or a dollar sign; this matches what GNU diff -p output uses. This default selection however is not suited for some contents, and you can use a customized pattern to make a selection.

git diff seems to ship with a number of built-in patterns for a good number of common languages.

While I am less interested in the exact format, the ability for the hunk to be prefixed with helpful contextual information, e.g., the function name where the change takes place is quite useful, for example:

@@ -107,6 +109,7 @@ class ConsoleDiff(object):
         self.highlight = highlight
         self.strip_trailing_cr = strip_trailing_cr
         self.truncate = truncate
+        self.ignore_case = ignore_case

The prefix line with class ConsoleDiff(object): gives us valuable context clues when looking at the subsequent diff.

Filing this as a potential feature request to add if someone has time to look at this more deeply.

@jeffkaufman
Copy link
Owner

Thanks for the suggestion! I'd be happy to have something along these lines, though I don't think I will get around to implementing it

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

2 participants