Repository: gitui-org/gitui (language: rust)

Issue:
Commit messages that begin with a hash (#) are ignored
**Describe the bug**
When using gitui to create a commit, commit messages that start with a # are ignored. This is the default behaviour of git however setting the config value `core.commentChar` makes the commit message work when using git on the command line, however commiting through gitui the commit message is still stripped out

**To Reproduce**
Steps to reproduce the behavior:
1. Go to a project and make some changes
2. Open git UI
3. Commit the changes
4. In the commit message dialog, use the message "#5123 test"
5. Go to the log and the message for that commit is blank
6. Make more changes
7. Run `git config --global core.commentChar ";"``
8. Repeat the above steps
9. Same outcome

**Expected behavior**
The behaviour should match commiting with the command line, where changing the core.commentChar is respected

**Screenshots**
![image](https://github.com/extrawurst/gitui/assets/10167467/5313bce9-ffc1-4351-9a65-a82b791a839f)
![image](https://github.com/extrawurst/gitui/assets/10167467/60d2fb99-67a5-47ac-85ce-534177a6ac1f)
![image](https://github.com/extrawurst/gitui/assets/10167467/45456c3d-7147-4f00-a3c1-1b05b8699019)

**Context (please complete the following information):**
 - OS/Distro + Version: Windows 11, 23h2, 22631.3296
 - GitUI Version: 0.24.3
 - Rust version: 1.75.0



Discussion / hints:
should be fairly simple to implement: see https://github.com/extrawurst/gitui/commit/1a1c948020be636d2df5dde145a2189b9e6d50ae

add `commit_message_prettify` into `asyncgit` and handle the config loading and forwarding of the configured comment-char

Fix patch:
diff --git a/asyncgit/src/sync/commit.rs b/asyncgit/src/sync/commit.rs
index b2b7a47440..36884a0bb5 100644
--- a/asyncgit/src/sync/commit.rs
+++ b/asyncgit/src/sync/commit.rs
@@ -1,9 +1,12 @@
+//! Git Api for Commits
 use super::{CommitId, RepoPath};
 use crate::{
 	error::Result,
 	sync::{repository::repo, utils::get_head_repo},
 };
-use git2::{ErrorCode, ObjectType, Repository, Signature};
+use git2::{
+	message_prettify, ErrorCode, ObjectType, Repository, Signature,
+};
 use scopetime::scope_time;
 
 ///
@@ -119,6 +122,20 @@ pub fn tag_commit(
 	Ok(c)
 }
 
+/// Loads the comment prefix from config & uses it to prettify commit messages
+pub fn commit_message_prettify(
+	repo_path: &RepoPath,
+	message: String,
+) -> Result<String> {
+	let comment_char = repo(repo_path)?
+		.config()?
+		.get_string("core.commentChar")
+		.map(|char_string| char_string.chars().next())?
+		.unwrap_or('#') as u8;
+
+	Ok(message_prettify(message, Some(comment_char))?)
+}
+
 #[cfg(test)]
 mod tests {
 	use crate::error::Result;
diff --git a/asyncgit/src/sync/mod.rs b/asyncgit/src/sync/mod.rs
index c188f28c63..dcc3419ec7 100644
--- a/asyncgit/src/sync/mod.rs
+++ b/asyncgit/src/sync/mod.rs
@@ -5,7 +5,7 @@
 
 pub mod blame;
 pub mod branch;
-mod commit;
+pub mod commit;
 mod commit_details;
 pub mod commit_files;
 mod commit_filter;
diff --git a/src/popups/commit.rs b/src/popups/commit.rs
index cb68bd1f7c..36cef4e33f 100644
--- a/src/popups/commit.rs
+++ b/src/popups/commit.rs
@@ -11,8 +11,9 @@ use crate::{
 	ui::style::SharedTheme,
 };
 use anyhow::{bail, Ok, Result};
+use asyncgit::sync::commit::commit_message_prettify;
 use asyncgit::{
-	cached, message_prettify,
+	cached,
 	sync::{
 		self, get_config_string, CommitId, HookResult,
 		PrepareCommitMsgSource, RepoPathRef, RepoState,
@@ -195,7 +196,8 @@ impl CommitPopup {
 		drop(file);
 		std::fs::remove_file(&file_path)?;
 
-		message = message_prettify(message, Some(b'#'))?;
+		message =
+			commit_message_prettify(&self.repo.borrow(), message)?;
 		self.input.set_text(message);
 		self.input.show()?;
 
@@ -254,8 +256,8 @@ impl CommitPopup {
 			}
 		}
 
-		//TODO: honor `core.commentChar`
-		let mut msg = message_prettify(msg, Some(b'#'))?;
+		let mut msg =
+			commit_message_prettify(&self.repo.borrow(), msg)?;
 
 		if verify {
 			// run commit message check hook - can reject commit


Test patch: