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

Quitting commit with co-authored actually commits #65

Open
dewyze opened this issue Apr 27, 2018 · 2 comments
Open

Quitting commit with co-authored actually commits #65

dewyze opened this issue Apr 27, 2018 · 2 comments
Labels

Comments

@dewyze
Copy link

dewyze commented Apr 27, 2018

If I run git dci without GIT_DUET_CO_AUTHORED_BY set, and then run :qa in vim. It will not commit.

If I run git commit/dci with GIT_DUET_CO_AUTHORED_BY set (and GIT_DUET_GLOBAL set), and then run :qa in vim, it will still make the commit either way.

@dewyze
Copy link
Author

dewyze commented Apr 27, 2018

I am on git 2.11.0 and git duet 0.6.0

@jszwedko
Copy link
Member

jszwedko commented Apr 30, 2018

Thanks for the report!

This appears to be a regrettable side-effect of writing the trailer as part of the commit preparation (the prepare-commit-msg hook). Specifically with vim you can workaround it by doing :ca (exit nonzero), but I believe we should take further steps to address this.

Some half-baked ideas/thoughts:

  • Adding a comment during the commit preparation above the trailers with something like # delete these trailers if you want to write an empty commit message
  • Add a commit-msg hook that looks for commit messages that only have the Co-authored-by: trailers and exit 1 (this is the status code it currently aborts with for empty commit messages). Consider the implications of how this works with --no-verify which would skip this hook.
  • Move this logic from a prepare-commit-msg hook to a commit-msg hook. The former seems to be theoretically the better place for it to live, but perhaps the latter is better from a practical stand point. Not crazy about this idea.
  • Worst-case: document this new behavior in the README

I was initially confused that the Signed-off-by trailer didn't do the same thing, but it looks like git explicitly ignores these when looking for empty commit messages: https://github.com/git/git/blob/master/sequencer.c#L753-L789 . If only we could add some more to ignore.

I'll mark this as a bug since it is technically a regression in behavior.

@jszwedko jszwedko added the bug label Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants