tnie / printlog Goto Github PK
View Code? Open in Web Editor NEW为了试验 git submodule 特性,作为公共类库使用。封装标准输出
为了试验 git submodule 特性,作为公共类库使用。封装标准输出
针对 msvc 可能是需要限定 msvc 的版本;针对 g++ 应该是指定编译参数。
之前在 windows 环境下,全局配置了
#提交时(准确来说是 git add 时)转换为LF,检出时转换为CRLF
git config --global core.autocrlf true
#拒绝提交(准确来说是 git add)包含混合换行符的文件
git config --global core.safecrlf true
针对传统的 msvc 项目(使用 msvc 编写代码、编译工程),上述配置适用且兼容了跨平台检出源文件。(msvc 管理的项目打算跨平台,笑话)
使用普通文本编辑器(notepad++、UltraEdit 等)&& cmake 构建工具时也适用 就可能出现问题——如果文本文件(源文件、头文件以及 CMakelists.txt)使用了 linux 格式(即 LF 换行符)
新建 Notepad++ Document,默认 windows 格式(CRLF 换行符)
除非使用文本编辑器显式地进行“文档格式转换”,在 windows 平台新建的文本文件理论上都是 windows 格式。
使用 vim(比如 git 伴随的 mingw)创建的文本,使用 linux 格式
如果是从 github 检出的库,也适用。github 仓库大多使用 linux 格式(LF 换行符),但在上述配置下 windows 平台检出时会自动转换为 CRLF 格式。
上述配置最严重的的影响就是无法提交git add
linux 格式(LF)的文本。不过从前面的描述来看,除了显式修改文档格式(或者在 windows 下使用 vim 建立的文件),版本库中应该不会出现 LF 格式的内容才对
使用 git submodule add [email protected]:tnie/printlog.git
,会报错:
fatal: LF would be replaced by CRLF in .gitmodules
原因:git 自动生成的 .gitmodule
,以及使用 TortoiseGit 右击选项生成的 .gitignore
、通过 vim 手工添加的 .gitignore
(使用 windows 平台文本编辑器创建的例外)在 git add
时都会报上述错误。
包括 .gitattributes
在内的自动生成的文件都可能出现上述问题。(还没了解 .gitattributes
是什么作用)
因为上述 .gitxxx
都是在本地直接生成的 LF 格式文件,并非从上游仓库检出,所以不会自动转换成 CRLF 格式。
为什么 lF 格式的文档 git add
会报错“ 失败:LF 将转换成 CRLF”?什么机制?
我个人觉得这个锅是 core.autocrlf = true
的,可是 网上的解决方案 怎么是针对 core.safecrlf = true
的呢?
core.autocrlf 配置,需要手动翻到“Formatting and Whitespace”小节。由其中的描述可以看出,理想情况是在 windows 平台下工作区不会存在 LF 格式文档。也就是说 core.autocrlf
未考虑 windows 平台工作区出现 LF 格式文档的情况。
跨平台项目,windows 平台使用 core.autocrlf=true
配合 linux/mac 平台使用 core.autocrlf=input
This setup should leave you with CRLF endings in Windows checkouts, but LF endings on Mac and Linux systems and in the repository.
core.safecrlf 配置 中这句话怎么理解啊?
If
core.safecrlf
is set to "true" or "warn", Git verifies if the conversion is reversible for the current setting ofcore.autocrlf
.
Windows 上 Git bash 客户端自带了以下工具
nielo@DESKTOP-3JOBDNN MINGW64 ~
$ ls /usr/bin/ | grep ^u | grep 2
u2d.exe*
unix2dos.exe*
unix2mac.exe*
nielo@DESKTOP-3JOBDNN MINGW64 ~
$ ls /usr/bin/ | grep ^d | grep 2
d2u.exe*
docx2txt*
docx2txt.pl*
dos2unix.exe*
在 notepad++ 打开文档时,使用 d2u.exe/u2d.exe 进行文档格式转换能够成功。notepad++ 会提示“内容有变更,是否重新加载”,但是在 notepad++ 底部状态栏中的文档格式并不会刷新,需要关闭文档重新打开才会看到变化。
printlog-demo 的 CMakeLists.txt 为什么可以语法高亮?
https://github.com/tnie/printlog-demo/blob/master/CMakeLists.txt
grpc 的也可以
cmake --build .
刷出大量乱码,不可见文字A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.