path/diff files folding/highlighting

René J.V. Bertin rjvbertin at gmail.com
Thu Oct 24 09:30:49 BST 2019


Hi,

I work a lot with patch files, some generated by `git diff`, others by `git show`. The former fold fine ("fold all toplevel nodes"), which is extremely helpful for larger ones (though I often miss an option to fold all level-1 nodes, which correspond to individual patch hunks).

The latter, `git show` patchfiles are left with a header containing the git commit data unfolded. That's not so much of a problem when there is only one header. When the file was obtained with `git show FROM...TO` the headers of commits further down the file are folded along with the preceding file patch.
I get around that by piping such `git show` commands or the resulting files through

sed 's=^commit \(.*\)=diff --git COMMIT \1\nindex \1\n--- /dev/null\n+++ /dev/null\n@@ -0,0 +0,0\n=g'

but that's a bit awkward and will probably confuse the patch command.

Isn't there a better solution, IOW, is there already support for treating the git commit header as a foldable node by changing it in a more subtle fashion (instead of making it look like an actual diff)?

BTW, patch files fetched from Qt's gerrit interface contain a list of the modified files in the header, which confuses the toplevel folding algorithm.

Thanks,
R.


More information about the KWrite-Devel mailing list