Skip to content

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

Open
@lljbash

Description

@lljbash

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions