I would like to know how exactly git diff
applies the expression provided to xfuncname to the result and if it is possible to delegate the search for the hunk header text to another program.
Context: I would like to change the xfuncname setting for my git diff
to display a usable output for a xml file. An example xml that would look like this:
<layer1-1>
</layer1-1>
<layer1-2>
<layer2-1>
</layer2-1>
<layer2-2>
</layer2-2>
<layer2-3>
<layer3-1>
[...]
changes
[...]
</layer3-1>
<layer3-2>
</layer3-2>
<layer3-2>
</layer3-2>
</layer2-3>
</layer1-2>
<layer1-3>
</layer1-3>
And ideally, the output with the modified hunk header would look like this
@@ -15 +15 @@ <layer1-2><layer2-3><layer3-1>
[...]
-notchanged
+changed
[...]
My observations imply that git diff
applies the regular expression to the part of the file before the difference, takes the last match and from that the first capture group; and it uses the m
flag. Is that a suitable description?
As RE2 apparently supports neither backreferences nor lookaheads, I'm not sure if what I'm trying to do can be achieved by this method. Is there a way to specify a custom program/script that receives the diff as input so I can specify a hunk header myself?