gitui
gitui copied to clipboard
Not able to commit with predefined (template) commit message
Describe the bug
The recording below demonstrates the problem.
I have a commit message template in a gitconfig like this:
[commit]
template = ~/.config/git/custom-template
and gitui can also read it. So far everything as expected. When I try to commit something (c
) it opens up the text area with my predefined commit message. But I am not able to immediately commit (⏎
) because the option is greyed out. I need to remove or add a character in order to be able to commit.
To Reproduce Steps to reproduce the behavior:
- Try to commit a change (
c
). - See the predefined commit message in the text area.
- Try to commit (
⏎
). - It doesn't work because the option is greyed out.
Expected behavior
- Try to commit a change (
c
). - See the predefined commit message in the text area.
- Try to commit (
⏎
). - Changes are commited.
Screenshots
Context (please complete the following information):
- OS/Distro + Version: Ubuntu 23.04
- GitUI Version 0.24.3
- Rust version: not installed
I believe this might have been an intended behavior, with intention that git templates serve as templates.
// impl CommitComponent
fn can_commit(&self) -> bool {
!self.is_empty() && self.is_changed()
}
fn is_changed(&self) -> bool {
Some(self.input.get_text().trim())
!= self.commit_template.as_ref().map(|s| s.trim())
}
Not sure whether it should stay this way or allow no changes if commit_template
is not None
. If latter, should be a pretty easy fix.
Interesting, I didn't even think of this. I have multiple commit templates, some of which are used for private/automated projects where the message inside the template is not meant to be changed (something like "No commit message"). Funny thing is that I actually started to add these templates as a workaround, because gitui does not support empty commit messages.
i guess its fair to commit the template unchanged. shell will allow the same i assume
... shell will allow the same i assume
I wanted to tackle this issue, so I tested the behavior of the git CLI. It does not allow the commit with the template message, outputting "Aborting commit; you did not edit the message." (source)
Nevertheless, I went ahead and created a PR. If the intent is still to match the behavior of the git CLI, it can be rejected
no lets stay consistent with the shell then. @magical-heyrovsky if the CLI allows empty commit messages then feel free to open an issue to fix gitui be compatible
So lets summarize:
- git does not allow to commit with a unedited template message
- git does does allow to commit with with an empty commit message but only when using
--allow-empty
I will close this issue. I no longer believe that my initially proposed behavior would make much sense in GitUI. Shortly after I created this issue, I discovered the "reuse previous commit message" feature and have been using it ever since.