diff 版本 git 使用什么? diff2 还是 diff3?

What is the diff version git uses? diff2 or diff3?

有谁知道git使用的是哪个diff版本?

This article 例如详细解释了假人的 diff 算法,但实际使用的算法是什么?

这里是 diff2 and diff3.

的规格,供您了解一般知识

我知道您可以配置 git 以使用 diff2diff3

git config --global merge.conflictstyle diff3

我在config documentation中找到了答案:
git 默认为 diff2

merge.conflictStyle

Specify the style in which conflicted hunks are written out to working tree files upon merge.

The default is "merge", which shows a <<<<<<< conflict marker,
changes made by one side, a ======= marker,
changes made by the other side,
and then a >>>>>>> marker. An alternate style,

"diff3", adds a ||||||| marker and the original text before the ======= marker.

你似乎混淆了 3 个不同的东西

  1. GNU diffutils
  2. 提供的unix命令行工具diff3
  3. git提供的diff输出格式(其中diff3为非默认选项)
  4. git 用于生成差异的算法

Git 支持 4 种不同的差异算法。

可以通过命令行指定为git diff

  --minimal
       Spend extra time to make sure the smallest possible diff is produced.

   --patience
       Generate a diff using the "patience diff" algorithm.

   --histogram
       Generate a diff using the "histogram diff" algorithm.

   --diff-algorithm={patience|minimal|histogram|myers}
       Choose a diff algorithm. The variants are as follows:
   default, myers
       The basic greedy diff algorithm. Currently, this is the default.

   minimal
       Spend extra time to make sure the smallest possible diff is produced.

   patience
       Use "patience diff" algorithm when generating patches.

   histogram
       This algorithm extends the patience algorithm to "support low-occurrence common elements".

或通过 git 配置。

  diff.algorithm
   Choose a diff algorithm. The variants are as follows:

   default, myers
       The basic greedy diff algorithm. Currently, this is the default.

   minimal
       Spend extra time to make sure the smallest possible diff is produced.

   patience
       Use "patience diff" algorithm when generating patches.

   histogram
       This algorithm extends the patience algorithm to "support low-occurrence common elements".

你原来问题中的 diff2 pdf-link 是对 myers 算法的描述,似乎与 2-way 冲突标记无关 git 在 merge.conflictStyle.

中调用 diff2

同样,unix 工具 diff3 与 3 向冲突标记 git 调用无关 diff3