vim-fugitive
vim-fugitive copied to clipboard
Include git notes in commit buffers
Issue #912
Calling "git notes list" serves both to suppress the "Notes:" prefix when a commit does not have any notes, and to avoid using notes formats in older versions of git.
I updated the commit message. Is it acceptable now?
The commit message failure is because I require the body to be wrapped to 72 characters, not 80.
My hesitation, though, is that I've bent over backwards to keep this to a single git execution for performance reasons (especially on win32 where shelling out has a massive overhead), and it's hard to justify tossing that out the window for a niche feature like notes. I'd be more amenable if it did always used the notes format and then deleted the Notes header after the fact.
But I also don't want to encourage you to spend more time on this because I plan to scrap the current implementation entirely and replace it with something closer to the new :Gstatus. This would likely manifest itself by parsing the output of git show rather than blindly shoving it into the buffer, which would make removing that Notes header downright trivial. This change is pretty high up on my todo list, but it's not quite at the top.
Do you happen to know what an old git would do with the %N? If it's harmless then I can figure that out, I think.
The patch is now updated. As is the commit message.
I imagine you know a better way to do the text editing; my vim-script experience is fairly limited. This works though. There's no Notes: prefix when no notes exist. Nor when notes are not supported.
I tested that %Z is just passed through, so I'm presuming that old git would do the same with %N.
You can use fugitive#GitVersion(1, 7) to check for a Git version with %N support.
You can use
fugitive#GitVersion(1, 7)to check for a Git version with%Nsupport.
OK, that's been in Git about 5 years longer than I thought it might! We shouldn't need to check; the patterns should work anyway. I tested it with %Z (which isn't defined right now), and it did the right thing.
I bring it up as a possible simplification because I haven't deciphered what FuGiTiVeEnDmArKeR is for but it's raising all my alarm bells.
I needed a way to remove Notes: when there is no note there, without running any other git command to check. It seems likely that Notes: could appear in the commit message or in the commit diff itself, so a unique marker was helpful at the start. I also needed an end marker, and ^diff ... didn't seem appropriate.
You may well know a better way.