summaryrefslogtreecommitdiff
path: root/devdocs/git/git-check-attr.html
blob: 999617324a5d256ce86bcfe07952c2150806295a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<h1>git-check-attr</h1>  <h2 id="_name">Name</h2> <div class="sectionbody">  <p>git-check-attr - Display gitattributes information</p>  </div>   <h2 id="_synopsis">Synopsis</h2> <div class="sectionbody"> <div class="verseblock"> <pre class="content" data-language="shell">git check-attr [--source &lt;tree-ish&gt;] [-a | --all | &lt;attr&gt;…​] [--] &lt;pathname&gt;…​
git check-attr --stdin [-z] [--source &lt;tree-ish&gt;] [-a | --all | &lt;attr&gt;…​]</pre> </div> </div>   <h2 id="_description">Description</h2> <div class="sectionbody">  <p>For every pathname, this command will list if each attribute is <code>unspecified</code>, <code>set</code>, or <code>unset</code> as a gitattribute on that pathname.</p>  </div>   <h2 id="_options">Options</h2> <div class="sectionbody"> <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-attr.txt--a--all"> -a, --all </dt> <dd> <p>List all attributes that are associated with the specified paths. If this option is used, then <code>unspecified</code> attributes will not be included in the output.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---cached"> --cached </dt> <dd> <p>Consider <code>.gitattributes</code> in the index only, ignoring the working tree.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---stdin"> --stdin </dt> <dd> <p>Read pathnames from the standard input, one per line, instead of from the command line.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt--z"> -z </dt> <dd> <p>The output format is modified to be machine-parsable. If <code>--stdin</code> is also given, input paths are separated with a NUL character instead of a linefeed character.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---sourcelttree-ishgt"> --source=&lt;tree-ish&gt; </dt> <dd> <p>Check attributes against the specified tree-ish. It is common to specify the source tree by naming a commit, branch, or tag associated with it.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt---"> -- </dt> <dd> <p>Interpret all preceding arguments as attributes and all following arguments as path names.</p> </dd> </dl> </div>  <p>If none of <code>--stdin</code>, <code>--all</code>, or <code>--</code> is used, the first argument will be treated as an attribute and the rest of the arguments as pathnames.</p>  </div>   <h2 id="_output">Output</h2> <div class="sectionbody">  <p>The output is of the form: &lt;path&gt; COLON SP &lt;attribute&gt; COLON SP &lt;info&gt; LF</p>   <p>unless <code>-z</code> is in effect, in which case NUL is used as delimiter: &lt;path&gt; NUL &lt;attribute&gt; NUL &lt;info&gt; NUL</p>   <p>&lt;path&gt; is the path of a file being queried, &lt;attribute&gt; is an attribute being queried, and &lt;info&gt; can be either:</p>  <div class="dlist"> <dl> <dt class="hdlist1" id="Documentation/git-check-attr.txt-emunspecifiedem"> <em>unspecified</em> </dt> <dd> <p>when the attribute is not defined for the path.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt-emunsetem"> <em>unset</em> </dt> <dd> <p>when the attribute is defined as false.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt-emsetem"> <em>set</em> </dt> <dd> <p>when the attribute is defined as true.</p> </dd> <dt class="hdlist1" id="Documentation/git-check-attr.txt-ltvaluegt"> &lt;value&gt; </dt> <dd> <p>when a value has been assigned to the attribute.</p> </dd> </dl> </div>  <p>Buffering happens as documented under the <code>GIT_FLUSH</code> option in <a href="git">git[1]</a>. The caller is responsible for avoiding deadlocks caused by overfilling an input buffer or reading from an empty output buffer.</p>  </div>   <h2 id="_examples">Examples</h2> <div class="sectionbody">  <p>In the examples, the following <code>.gitattributes</code> file is used:</p>  <div class="listingblock"> <div class="content"> <pre>*.java diff=java -crlf myAttr
NoMyAttr.java !myAttr
README caveat=unspecified</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing a single attribute:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr diff org/example/MyClass.java
org/example/MyClass.java: diff: java</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing multiple attributes for a file:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ 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</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing all attributes for a file:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr --all -- org/example/MyClass.java
org/example/MyClass.java: diff: java
org/example/MyClass.java: myAttr: set</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Listing an attribute for multiple files:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java
org/example/MyClass.java: myAttr: set
org/example/NoMyAttr.java: myAttr: unspecified</pre> </div> </div> <div class="ulist"> <ul> <li> <p>Not all values are equally unambiguous:</p> </li> </ul> </div> <div class="listingblock"> <div class="content"> <pre data-language="shell-session">$ git check-attr caveat README
README: caveat: unspecified</pre> </div> </div> </div>   <h2 id="_see_also">See also</h2> <div class="sectionbody">  <p><a href="gitattributes">gitattributes[5]</a>.</p>  </div><div class="_attribution">
  <p class="_attribution-p">
    &copy; 2012&ndash;2024 Scott Chacon and others<br>Licensed under the MIT License.<br>
    <a href="https://git-scm.com/docs/git-check-attr" class="_attribution-link">https://git-scm.com/docs/git-check-attr</a>
  </p>
</div>