- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 631
Open
Labels
Description
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.
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
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
extrawurst commentedon Apr 17, 2025
Still happy to take a PR that adds the diff into the commit template
lljbash commentedon May 9, 2025
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?
git commit --verbose
template in external editor #2640