gpt4 book ai didi

git - 将模式附加到默认差异 header 模式 (diff.cpp.xfuncname)

转载 作者:太空狗 更新时间:2023-10-29 13:27:11 28 4
gpt4 key购买 nike

我想扩展(但不替换)C 文件的默认差异 header 模式。根据这个post :

you are stuck with extracting the builtin value (which annoyingly, you cannot even get without looking at the source code!), and repeating it in your config file.

然而,内置值在 C 中看起来像这样:

PATTERNS("cpp",
/* Jump targets or access declarations */
"!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n"
/* functions/methods, variables, and compounds at top level */
"^((::[[:space:]]*)?[A-Za-z_].*)$",
/* -- */
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*"
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),

我不确定如何在 .gitconfig 文件中呈现。

我试过了

xfuncname = "(!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n)|(^((::[[:space:]]*)?[A-Za-z_].*)$\n)|([a-zA-Z_][a-zA-Z0-9_]*)|([-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*)|([-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*)"

这给了我 fatal: Invalid regexp to look for hunk header: (!^[ ]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]] *($|/[/*]) 运行 git diff 时。

双反斜杠也不起作用:

xfuncname = "(!^[ \\t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\\n)|(^((::[[:space:]]*)?[A-Za-z_].*)$\\n)|([a-zA-Z_][a-zA-Z0-9_]*)|([-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*)|([-+*/<>%&^|=!]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\||::|->\\\\*?|\\\\.\\\\*)"

没有错误,但是差异 header 是空白的,即它无法匹配任何内容。

最佳答案

至少尝试将 \ 加倍。
gitattributes确实提到:

[diff "tex"]
xfuncname = "^(\\\\(sub)*section\\{.*)$"

Note. A single level of backslashes are eaten by the configuration file parser, so you would need to double the backslashes; the pattern above picks a line that begins with a backslash, and zero or more occurrences of sub followed by section followed by open brace, to the end of line.

关于git - 将模式附加到默认差异 header 模式 (diff.cpp.xfuncname),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39481258/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com