git-check-attr
命令名称 - 显示 gitattributes 信息
概要
bash
[verse]
'git check-attr' [--source <tree-ish>] [-a | --all | <attr>...] [--] <pathname>...
'git check-attr' --stdin [-z] [--source <tree-ish>] [-a | --all | <attr>...]描述
对于每个路径名,此命令将列出每个属性在该路径名上是"未指定"、"已设置"还是"已取消设置"作为 gitattribute。
选项
-a/--all- 列出与指定路径关联的所有属性。如果使用此选项,则"未指定"的属性不会包含在输出中。--cached- 仅考虑索引中的.gitattributes,忽略工作树。--stdin- 从标准输入读取路径名,每行一个,而不是从命令行读取。-z- 输出格式被修改为机器可解析格式。如果同时给定了--stdin,输入路径将以 NUL 字符而非换行符分隔。--source=<tree-ish>- 对照指定的 tree-ish 检查属性。通常通过命名与其关联的提交、分支或标签来指定源树。\--- 将所有前面的参数解释为属性,将所有后面的参数解释为路径名。
如果未使用 --stdin、--all 或 -- 中的任何一个,第一个参数将被视为属性,其余参数被视为路径名。
输出
输出格式为:
<path> COLON SP <attribute> COLON SP <info> LF除非 -z 生效,此时使用 NUL 作为分隔符:
<path> NUL <attribute> NUL <info> NUL<path> 是被查询文件的路径,<attribute> 是被查询的属性,<info> 可以是:
unspecified- 当属性未为该路径定义时。unset- 当属性被定义为 false 时。set- 当属性被定义为 true 时。<value>- 当已为属性分配了值时。
缓冲按照 git(1) 中 GIT_FLUSH 选项下的文档进行。调用者负责避免因输入缓冲区溢出或从空输出缓冲区读取而导致的死锁。
示例
在示例中,使用了以下 .gitattributes 文件:
*.java diff=java -crlf myAttr
NoMyAttr.java !myAttr列出单个属性:
$ git check-attr diff org/example/MyClass.java org/example/MyClass.java: diff: java列出文件的多个属性:
$ git check-attr crlf diff myAttr -- org/example/MyClass.java org/example/MyClass.java: crlf: unset org/example/MyClass.java: diff: java org/example/MyClass.java: myAttr: set列出文件的所有属性:
$ git check-attr --all -- org/example/MyClass.java org/example/MyClass.java: diff: java org/example/MyClass.java: myAttr: set列出多个文件的属性:
$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java org/example/MyClass.java: myAttr: set org/example/NoMyAttr.java: myAttr: unspecified并非所有值都同样明确:
$ git check-attr caveat README README: caveat: unspecified
另请参阅
Git
git(1) 套件的一部分
