vim-fugitive icon indicating copy to clipboard operation
vim-fugitive copied to clipboard

Include git notes in commit buffers

Open a-m-s opened this issue 6 years ago • 8 comments

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.

a-m-s avatar Nov 21 '19 23:11 a-m-s

I updated the commit message. Is it acceptable now?

a-m-s avatar Nov 25 '19 14:11 a-m-s

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.

tpope avatar Nov 26 '19 01:11 tpope

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.

a-m-s avatar Nov 26 '19 09:11 a-m-s

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.

a-m-s avatar Nov 26 '19 15:11 a-m-s

You can use fugitive#GitVersion(1, 7) to check for a Git version with %N support.

tpope avatar Nov 26 '19 20:11 tpope

You can use fugitive#GitVersion(1, 7) to check for a Git version with %N support.

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.

a-m-s avatar Nov 27 '19 09:11 a-m-s

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.

tpope avatar Nov 27 '19 09:11 tpope

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.

a-m-s avatar Nov 27 '19 09:11 a-m-s