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

Include git notes in commit buffers #1406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

a-m-s
Copy link

@a-m-s a-m-s commented Nov 21, 2019

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
Copy link
Author

a-m-s commented Nov 25, 2019

I updated the commit message. Is it acceptable now?

@tpope
Copy link
Owner

tpope commented Nov 26, 2019

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.

@a-m-s
Copy link
Author

a-m-s commented Nov 26, 2019

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.

Issue tpope#912

Add any existing git notes into commit views, between the commit message
and the patch itself.  This is similar to what "git show" does, albeit
without any indent.

This should work for older versions of git, without the notes feature,
provided that the '%N' directive is passed through as-is.
@a-m-s
Copy link
Author

a-m-s commented Nov 26, 2019

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.

@tpope
Copy link
Owner

tpope commented Nov 26, 2019

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

@a-m-s
Copy link
Author

a-m-s commented Nov 27, 2019

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.

@tpope
Copy link
Owner

tpope commented Nov 27, 2019

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.

@a-m-s
Copy link
Author

a-m-s commented Nov 27, 2019

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.

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

Successfully merging this pull request may close these issues.

None yet

2 participants