Fossil Forum
Post: Newlines disappearing from commit messages
Found a bug present in at least 2.23. Did several commits in test repo. First was like fossil commit -m "Line 1\nline2\nline 3" and it is shown exactly as typed, with all "\n"'s.
Another commit was done with just fossil commit by proper multi-line message in vim with shell commands to reproduse and comment to them. It is shown, however, as one single long line in both CLI and in Web timeline of fossil ui so that plain copypaste will mess those shell commands. I've asked AI to check what's in repo, answer was (till end of post):
fossil sql "SELECT length(comment) AS len, instr(comment, char(10)) AS has_lf_pos, quote(comment) AS quoted FROM event e JOIN blob b ON b.rid=e.objid WHERE e.type='ci' AND b.uuid GLOB '4cb867545*' LIMIT 1;"
388,42,'''Baseline: sources state after ./configure
Done by the following commands:
cd /usr/src/mlnx-ofed-kernel-25.10.OFED.25.10.1.7.1.1
KERNEL_VERSION=$(uname -r)
KERNEL_SOURCE="/lib/modules/${KERNEL_VERSION}/build"
sudo ./configure --kernel-sources="${KERNEL_SOURCE}" --default --build-dummy-mods
Most produced binary files were added to ignore setting, and some others to
unversioned files.'''
Model: GPT-5.3-codex.
I'll check comment check-in 4cb867545: first by fossil info, then via SQL I'll check if there are any line breaks (char(10)) inside to distinguish UI collapse from a real single line.
[2 tools called]
Model: GPT-5.3-codex.
Checked: there are line breaks inside the comment.
According to the raw data for 4cb867545:
- length(comment)=388
- instr(comment, char(10))=42 (meaning the first \n is present)
- quote(comment) shows multi-line text.
So this is a display issue: in fossil info/timeline/web, your comment is collapsed into a single line, but in the database, it's stored as multi-line text.
First was like fossil commit -m "Line 1\nline2\nline 3" and it is shown exactly as typed, with all "n"'s.
That shouldn't be what you see at all with input like that. What you should see is:
15:21:44 [f6a65fcd7c] CURRENT Line1\nline 2\nline 3 (user: amb tags: trunk)
Notice that Fossil preserved the backslashes precisely as backslashes. This is because to Fossil, the comment string
"Line 1\nline 2\nline 3"
has no newlines in it at all, only a backslash followed by an 'n' character.
The authoritative answer comes from the actual manifest:
C Line1\nline\s2\nline\s3
Here you'll see that Fossil preserved the characters exactly as you entered them (it escaped the backslashes to preserve them as backslashes).
If your shell had automatically expanded the "\n" into newlines before giving it to Fossil, then it would look more like:
15:27:07 [e9ae045095] CURRENT Line 1 Line 2 Line 3 (user: amb tags: trunk)
This is because as you have found, the newlines are suppressed from display, but again the manifest would hold the encoded data:
C Line\s1\nLine\s2\nLine\s3
Notice that now the newline is preserved.
I don't see a bug.
First was like
fossil commit -m "Line 1\nline2\nline 3"and it is shown exactly as typed, with all "\n"'s.
Shell escaping doesn't quite work that way. You can use "Line 1"$'\n'"Line 2"$'\n'"Line 3" to get the intended effect (though it's probably better to use a real interactive editor for proper multi-line comments).
Another commit was done with just
fossil commitby proper multi-line message invimwith shell commands to reproduse and comment to them. It is shown, however, as one single long line in both CLI and in Web timeline offossil uiso that plain copypaste will mess those shell commands.
They're probably being interpreted as Fossil wiki and messing up with your expectations. There's two options that might apply to remedy this, and they're both on the Admin→Timeline page (/setup_timeline):
* “Plaintext comments on timelines” would disable all wiki and HTML processing and display comments as-is,
* and “Break comments at newline characters” that can allow wiki and HTML processing, but all newlines are treated as a line break character.
If you aren't trying to format your comments as wiki/HTML, selecting both these options will likely achieve what you want. If you do want to use wiki/HTML markup, just the second option might apply. Z f79fa26
I failed to mention that Fossil will output the preserved newlines on the command line if you use the "comment-format" setting and use only even-numbered combinations of the values (e.g. no 1 in the bitwise combination of the numbers):
https://fossil-scm.org/home/help/comment-format
For the UI there is the timeline-hard-newlines setting:
https://fossil-scm.org/home/help/timeline-hard-newlines