ok/jj
1
0
Fork 0
forked from mirrors/jj

git_backend: use lossy conversion to decode non-UTF-8 commit message

If message() returned None, it doesn't mean the commit message is empty. I
originally mapped it to an error, but that made import of linux repo fail.

https://docs.rs/git2/latest/git2/struct.Commit.html#method.message
This commit is contained in:
Yuya Nishihara 2023-10-30 06:33:14 +09:00
parent 06c254e742
commit 847adc832f

View file

@ -316,7 +316,9 @@ fn commit_from_git_without_root_parent(
} else {
MergedTreeId::Legacy(tree_id)
};
let description = commit.message().unwrap_or("<no message>").to_owned();
// Use lossy conversion as commit message with "mojibake" is still better than
// nothing.
let description = String::from_utf8_lossy(commit.message_bytes()).into_owned();
let author = signature_from_git(commit.author());
let committer = signature_from_git(commit.committer());