Skip to contentSkip to conversation

Unix-mode newlines

DISCUSSION Patrick Williams 2 participants 2 messages Nov 12, 2021

lore
Share & tools
lore
#0 lore raw

Hello,

Generally we've had a preference for Unix-style newlines (\n) and not DOS-style newlines (\r\n), but it has never been documented. I've recently found a small number of files that are either DOS-style or mixed-styles and I've been fixing them as I've ran into them.

I recently discovered that clang-format has options that allow us to force Unix-style newlines. I've pushed up a commit to docs that makes two changes to our C++ style guidelines:

1) Document expectation of using Unix-style newlines.
2) Update .clang-format to enforce Unix-style newlines.

See https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/48770 .

I'll leave this commit open until early next week and then merge it if I don't hear any concerns.

Signature · 1 line
Patrick Williams
#1 lore raw
Quoted 4 lines · Patrick Williams

Generally we've had a preference for Unix-style newlines (\n) and not DOS-style newlines (\r\n), but it has never been documented. I've recently found a small number of files that are either DOS-style or mixed-styles and I've been fixing them as I've ran into them.

Check out "man gitattributes"

You create a file like:
% cat .gitattributes
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted

# to native line endings on checkout.
*.yang text
*.txt text
*.md text
*.mkd text

...

and then git translates in/out.
Which is the default in the "repo" is up to you.
It takes a hit where many files with the "wrong" line endings have to tweaked, but then it's done.

--

]               Never tell me the odds!                 | ipv6 mesh networks [
]   Michael Richardson, Sandelman Software Works        |    IoT architect   [
]     [email protected]  http://www.sandelman.ca/        |   ruby on rails    [