【问题标题】:How to adjust SVN settings to convert line endlings on Windows?如何调整 SVN 设置以在 Windows 上转换行尾?
【发布时间】:2012-04-27 04:38:01
【问题描述】:

我需要在 Windows 上使用 SVN,并希望将其设置为始终以 Windows 样式检出行结尾并始终以 Unix 样式提交,无论使用哪个存储库。

  1. 这是可能的还是我必须为每个 repo 编写一个配置文件?

    如果我必须为每个 repo 编写一个配置文件,我应该把它放在哪里,正确的文件名是什么,文件中的内容以及它会对 repo 的其他用户产生什么影响?

  2. 我对全局 SVN 配置文件进行了以下更改,但没有任何效果。我还需要做什么?或者我是否必须使用某些特定参数调用 SVN 才能使更改在 Windows 上生效?

    enable-auto-props = yes
    [auto-props]
    *.c = svn:eol-style=native
    *.cpp = svn:eol-style=native
    *.cxx = svn:eol-style=native
    *.h = svn:eol-style=native
    *.hpp = svn:eol-style=native
    *.hxx = svn:eol-style=native
    *.txt = svn:eol-style=native
    *.tex = svn:eol-style=native
    *.bib = svn:eol-style=native
    

【问题讨论】:

    标签: windows svn eol


    【解决方案1】:

    这个命令行 android 工具对我有用:

    cd <install_dir>/adt-bundle-mac-x86_64-20140702/sdk/tools
    ./android list target 
    

    确保为下面的--target 开关选择上面列出的目标。

    ./android create project --target 1 --name MyFirstApp \
      --path ~/projects/android/MyFirstApp --activity MainActivity \
      --package com.example.myfirstapp
    

    这记录在https://developer.android.com/training/basics/firstapp/creating-project.html

    然后打开eclipse,导入上面创建的项目。

    【讨论】:

      【解决方案2】:

      Daniel Roethisberger 已经给了你correct answer。但是,您可能希望以某种方式确保所有文件都将 svn:eol-style 设置为 `native。

      我有一个pre-commit hook,它可以确保所有相关文件上的svn:eol-style 属性设置为native,然后才能进行提交。您可能需要查看它以确保您的政策得到遵守。

      【讨论】:

      • 您的“预提交挂钩”链接与“正确答案”链接匹配。你的意思是要发布别的东西吗?也许它没有正确复制到您的剪贴板。
      【解决方案3】:

      您需要为存储库中的所有文件将svn:eol-style 属性设置为native。 Autoprops 将为新添加到存储库的文件设置属性,但对于现有文件,您需要手动添加属性:

      svn propset svn:eol-style native example.c
      svn commit
      

      【讨论】:

      • 感谢您阐明现有文件和新添加文件之间的区别!此解决方案特定于存储库和文件类型。有没有办法告诉 subversion 总是这样做,不管 repo 的设置和文件类型如何(只要它不是二进制文件)?
      • 我不知道这样的选择,不。但是由于属性是作为存储库的一部分进行跟踪的,因此检出代码的其他人也会得到它们,并且可以正确转换行尾,而无需以特殊方式配置其 Subversion 客户端。
      猜你喜欢
      • 2011-04-22
      • 2021-06-07
      • 2012-03-07
      • 1970-01-01
      • 2010-10-25
      • 2014-05-18
      • 1970-01-01
      • 2013-07-08
      • 1970-01-01
      相关资源
      最近更新 更多