Skip to content

Commit fb6cdb9

Browse files
author
Stephan Dilly
committed
fix whitespace at commit-msg start breaking revlog alignment (closes #158)
1 parent b54e90a commit fb6cdb9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

asyncgit/src/sync/commits_info.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::utils::repo;
22
use crate::error::Result;
33
use git2::{Commit, Error, Oid};
44
use scopetime::scope_time;
5-
use std::borrow::Cow;
65

76
/// identifies a single commit
87
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
@@ -93,19 +92,20 @@ pub fn get_message(
9392
message_length_limit: Option<usize>,
9493
) -> String {
9594
let msg = String::from_utf8_lossy(c.message_bytes());
95+
let msg = msg.trim_start();
9696

9797
if let Some(limit) = message_length_limit {
98-
limit_str(msg, limit)
98+
limit_str(msg, limit).to_string()
9999
} else {
100100
msg.to_string()
101101
}
102102
}
103103

104-
fn limit_str(s: Cow<'_, str>, limit: usize) -> String {
104+
fn limit_str(s: &str, limit: usize) -> &str {
105105
if let Some(first) = s.lines().next() {
106-
first.chars().take(limit).collect::<String>()
106+
&first[0..limit.min(first.len())]
107107
} else {
108-
String::new()
108+
""
109109
}
110110
}
111111

0 commit comments

Comments
 (0)