AndyAO
V2EX  ›  问与答

在文档上没有的情况下,如何得知 Git 配置项的默认值?

  •  2
     
  •   AndyAO · Jun 17, 2021 · 1304 views
    This topic created in 1816 days ago, the information mentioned may be changed or developed.

    有关行尾符号自动转换的三个配置core.autocrlfcore.safecrlfcore.eol,只有最后那个在 git config 帮助文档上提到默认值为native,其他几个没有找到'default'相关的说明。

    除了「手动测试」这种最笨和「看源代码」这种最暴力的方法之外,有没有什么办法能够准确的知道这个配置项的默认值?

    3 replies    2021-06-17 19:13:30 +08:00
    AndyAO
        1
    AndyAO  
    OP
       Jun 17, 2021
    通过 environment.c 查到 enum auto_crlf auto_crlf = AUTO_CRLF_FALSE; 和 int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN; ,从而判断 core.safecrlf 的默认值是 WARN,而 core.autocrlf 的是 FALSE 。

    感觉很可能是直接硬编码到代码当中的,不清楚是否判断正确,也不清楚是否有其他的查询接口。
    AndyAO
        2
    AndyAO  
    OP
       Jun 17, 2021
    还有就是 Windows for git 会带有自己的默认 system 和 global config 文件,其中在 gitconfig 中将 autocrlf 设为 true,但这两个文件在 linux 版本中并不存在。
    delacey
        3
    delacey  
       Jun 17, 2021
    提 issue,让官方更新文档?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2853 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 04:54 · PVG 12:54 · LAX 21:54 · JFK 00:54
    ♥ Do have faith in what you're doing.