Skip to content

Use git commit --verbose when opening the external editor on a commit message #2619

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

Open
lljbash opened this issue Apr 17, 2025 · 2 comments · May be fixed by #2640
Open

Use git commit --verbose when opening the external editor on a commit message #2619

lljbash opened this issue Apr 17, 2025 · 2 comments · May be fixed by #2640

Comments

@lljbash
Copy link

lljbash commented Apr 17, 2025

Describe the solution you'd like
Opening the external editor is actually not done by git commit command, so we may need to manually put the diff into the created COMMIT_EDITMSG file.

gitui/src/popups/commit.rs

Lines 160 to 187 in e08d954

pub fn show_editor(
&mut self,
changes: Vec<StatusItem>,
) -> Result<()> {
let file_path = sync::repo_dir(&self.repo.borrow())?
.join("COMMIT_EDITMSG");
{
let mut file = File::create(&file_path)?;
file.write_fmt(format_args!(
"{}\n",
self.input.get_text()
))?;
file.write_all(
strings::commit_editor_msg(&self.key_config)
.as_bytes(),
)?;
file.write_all(b"\n#\n# Changes to be committed:")?;
for change in changes {
let status_char =
Self::item_status_char(change.status);
let message =
format!("\n#\t{status_char}: {}", change.path);
file.write_all(message.as_bytes())?;
}
}

Describe alternatives you've considered
Or horner commit.verbose configuration variable. (#900)

Additional context
It would be useful to have a full diff in context when I edit commit messages in an external editor. This would allow me to benefit from completions and copilot, etc.

@extrawurst
Copy link
Collaborator

Still happy to take a PR that adds the diff into the commit template

@lljbash
Copy link
Author

lljbash commented May 9, 2025

Still happy to take a PR that adds the diff into the commit template

I'm working on a PR for this. Just want to check: is it acceptable to call external git commands, or should everything be implemented purely in Rust?

@lljbash lljbash linked a pull request May 13, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants