许多svn存储库要求新文件具有svn:eol-style属性.有没有办法确保git-svn发生这种情况?
sil*_*ilk 12
您可以尝试在subversion配置中设置autoproperties([ 1 ] [ 2 ]).它将确保在新文件的添加操作期间svn:eol-style设置正确.
AFAIU git-svn只是在内部工作中使用svn,它应该加载subversion配置,并为新文件设置auto-props.
好的,我测试了它,它的工作原理.
示例.subversion/config:
[miscellany]
enable-auto-props = yes
[auto-props]
*.cpp = svn:keywords=Id Revision;svn:eol-style=native
*.cs = svn:keywords=Id Revision;svn:eol-style=native
Run Code Online (Sandbox Code Playgroud)
@ silk上面的答案只是部分解决方案.完整的解决方案还包括配置git以在提交时将CRLF转换为LF.所以,除了@silk所建议的,你还应该这样做:
git config --global core.autocrlf input
git config --global core.safecrlf warn
Run Code Online (Sandbox Code Playgroud)
要么:
git config --global core.safecrlf warn
git config --global core.attributesfile ~/.gitattributes
echo '* text=auto' >> ~/.gitattributes
Run Code Online (Sandbox Code Playgroud)
说明:
根据我的经验,git-svn将svn:eol-style=native在提交时设置属性,如@silk描述的那样,但在提交之前实际上不会将提交的文件转换为LF行结尾.因此,任何CRLF行结尾都将完整地提交给subversion repo,但是subversion期望所有svn:eol-style=native属性文件都以LF行结尾存储.最终结果是,第一次有人编辑并从subversion工作副本提交这样的文件时,diff将包括CRLF到LF的转换.
因此,一个完整的解决方案应该包括强制git在提交之前将文件转换为LF行结尾.您可以通过设置来执行此操作core.autocrlf=input,这意味着"在提交时将所有CRLF转换为LF,但在结帐时不执行反向转换",core.safecrlf=warn或者core.safecrlf=true,当您尝试提交具有CRLF行结尾的文件时,它会警告或阻止您.该autocrlf设置将确保这些CRLF转换,因此safecrlf=true可能过多.见git help config.
或者,您可以使用git属性通过设置text=auto所有文件来强制转换.要在全局范围内执行此操作,您需要在其中指定属性文件core.attributesfile.见git help attributes.
| 归档时间: |
|
| 查看次数: |
3657 次 |
| 最近记录: |