diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-02-27 10:49:30 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-27 10:49:30 -0800 |
commit | 9813725002ed50a35db33e6294c3778d2e2584e5 (patch) | |
tree | 4d3407458d08c5629bd8ffe11775eb7a04401b95 /gitattributes.html | |
parent | 613334cb5a7643a40c588048c6fb84dddd3c287c (diff) | |
download | git-htmldocs-9813725002ed50a35db33e6294c3778d2e2584e5.tar.gz |
Autogenerated HTML docs for v2.40.0-rc0-32-ga0f05f
Diffstat (limited to 'gitattributes.html')
-rw-r--r-- | gitattributes.html | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/gitattributes.html b/gitattributes.html index 3073b41d2..ee3d74b84 100644 --- a/gitattributes.html +++ b/gitattributes.html @@ -1528,6 +1528,40 @@ parameters, just like <code>GIT_EXTERNAL_DIFF</code> program is called. See <a href="git.html">git(1)</a> for details.</p></div>
</div>
<div class="sect3">
+<h4 id="_setting_the_internal_diff_algorithm">Setting the internal diff algorithm</h4>
+<div class="paragraph"><p>The diff algorithm can be set through the <code>diff.algorithm</code> config key, but
+sometimes it may be helpful to set the diff algorithm per path. For example,
+one may want to use the <code>minimal</code> diff algorithm for .json files, and the
+<code>histogram</code> for .c files, and so on without having to pass in the algorithm
+through the command line each time.</p></div>
+<div class="paragraph"><p>First, in <code>.gitattributes</code>, assign the <code>diff</code> attribute for paths.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><code>*.json diff=<name></code></pre>
+</div></div>
+<div class="paragraph"><p>Then, define a "diff.<name>.algorithm" configuration to specify the diff
+algorithm, choosing from <code>myers</code>, <code>patience</code>, <code>minimal</code>, or <code>histogram</code>.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><code>[diff "<name>"]
+ algorithm = histogram</code></pre>
+</div></div>
+<div class="paragraph"><p>This diff algorithm applies to user facing diff output like git-diff(1),
+git-show(1) and is used for the <code>--stat</code> output as well. The merge machinery
+will not use the diff algorithm set through this method.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">If <code>diff.<name>.command</code> is defined for path with the
+<code>diff=<name></code> attribute, it is executed as an external diff driver
+(see above), and adding <code>diff.<name>.algorithm</code> has no effect, as the
+algorithm is not passed to the external diff driver.</td>
+</tr></table>
+</div>
+</div>
+<div class="sect3">
<h4 id="_defining_a_custom_hunk_header">Defining a custom hunk-header</h4>
<div class="paragraph"><p>Each group of changes (called a "hunk") in the textual diff output
is prefixed with a line of the form:</p></div>
@@ -2202,7 +2236,7 @@ frotz unspecified</code></pre> <div id="footer">
<div id="footer-text">
Last updated
- 2023-01-04 22:32:44 PST
+ 2023-02-27 10:47:08 PST
</div>
</div>
</body>
|