Closed LussacZheng closed 5 years ago
Keywords: line endings, git, batch, gitattributes
执行 Deploy.bat
-> [6] 高级设置
-> [1] 选择语言
后,脚本提示:
执行系统找不到指定的批处理标签 - Config_Language
之后再重新打开脚本,菜单选项文本全部无法显示。且 res\deploy.settings
文件内容被清空。
而 高级设置
中的其他选项没有出现类似问题。
脚本的 高级设置
功能在本地测试时没有发现问题,只有通过 GitHub 项目主页 "Download ZIP" 下载的脚本会出现该问题。经分析,此 Bug 与 Issue #2 属于同一种情况。为 Git的换行符问题 。
Config_Language
方法属于 res\scripts\Config.bat
,而 Config.bat
的换行符(Line endings)为 LF
并非 CRLF
。且 Config_Language
方法中引用了 res\scripts\lang_*.bat
,这就涉及到 “以 LF
作为换行符的 .bat
批处理文件,包含中文字符时会出现不可预期的错误” 的问题。
而换行符同样被错误地设置为 LF
的还有: (res\scripts\
目录下的) DoDeploy.bat
, GenerateDownloadBatch.bat
, GenerateWgetOptions.bat
, Log.bat
, SourcesSelector.bat
,和(res\dev\
目录下的) SourcesListsDiff.bat
。加上 Config.bat
,总计7个文件的换行符被错误地设置为 LF
。
除了 Config.bat
,其他脚本并不涉及到中文字符(Chinese character),因此能够正常运行,并没有表现出明显的错误。
依照 Reference ,记录具体解决办法和操作步骤如下,以防下次出现相同的问题。
git config --global core.autocrlf
为 true ;git clone
;.gitattributes
中过时的 -crlf
属性修改为等价的 -text
;暂存更改,然后显示所有需要改变换行符的文件(7个):
$ git add . -u
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: .gitattributes
modified: res/dev/SourcesListsDiff.bat
modified: res/scripts/Config.bat
modified: res/scripts/DoDeploy.bat
modified: res/scripts/GenerateDownloadBatch.bat
modified: res/scripts/GenerateWgetOptions.bat
modified: res/scripts/Log.bat
modified: res/scripts/SourcesSelector.bat
$ git config commit.gpgsign true
提交并推送:
$ git commit -m "Fix: Line endings problem of Git again"
[master 9b1f4a2] Fix: Line endings problem of Git again
8 files changed, 668 insertions(+), 663 deletions(-)
rewrite .gitattributes (64%)
$ git push origin master
English translation is NOT provided for this record. Please translate it by yourself.