Git“配对损坏”是怎么回事?和“未知”;状态的含义以及它们何时发生?

发布于 2024-11-08 13:56:11 字数 421 浏览 3 评论 0原文

git diff 中的某些选项(例如 --name-status)会导致在文件名旁边输出状态字母。他们是:

A、C、D、M、R、T、U、X、B

……它们的意思是

添加 (A)、复制 (C)、删除 (D)、修改 (M)、重命名 (R)、 类型(即常规文件、符号链接、子模块等)已更改 (T), 未合并 (U)、未知 (X) 或配对损坏 (B)。

问题XB 状态应该如何解释,以及哪些情况会导致它们的出现?您能否提供导致此类状态出现在 git-diff 输出中的一系列步骤,以及可能的修复方法?

Some options in git diff, for instance --name-status, cause the output of a status letter next to a file name. They are:

A, C, D, M, R, T, U, X, B

… and they mean

Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R),
type (i.e. regular file, symlink, submodule, …) changed (T),
Unmerged (U), Unknown (X), or pairing Broken (B).

Question: how should the X and B statuses be interpreted, and which circumstances lead to their appearance? Can you provide a series of steps leading to such statuses appearing in the output of git-diff, and possibly ways to fix them?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安穩 2024-11-15 13:56:11

B “断开对”状态永远不会直接出现在 --name-status 输出中,它仅作为选项 --diff-filter 的参数有用 当同时使用选项 -B (--break-rewrites) 时。使用它作为过滤器可以选择至少已删除或更改一定比例内容的文件。

这种“破坏”对于 --name-status 来说并不是很有用,因为“破坏”的目的主要是改变 diff 文本的生成方式:它消除了上下文中的上下文行(未更改的行)。 diff 输出,而不是生成 diff 算法碰巧找到的任何“随机”公共子序列所需的添加和删除行。

git init broken-pairs
cd broken-pairs
nums() { seq "$1" "$2" 2>/dev/null || jot $(($2 - $1 + 1)) "$1"; }
nums   0  99 > a
nums 100 199 > b
git add a b
git commit -ma=0-99,b=100-199
nums 200 299 > a
{ nums 100 149; nums 350 399; } > b
git diff --name-status --diff-filter=B             # selects nothing
git diff --name-status --diff-filter=B -B          #         M100    a
git diff --name-status --diff-filter=B -B/50       #         M100    a M050    b

X“未知”状态实际上不应该出现。如果它确实出现,则意味着既没有取消合并、添加、删除、修改也没有更改其类型(实际上:未更改)的路径名意外地使其成为内部差异机制的核心;错误 feeding unmodified还将生成 diffcore

它似乎是一些旧的操作模式遗留下来的。

The B “broken pair” status never appears directly in --name-status output, it is only useful as an argument to the option --diff-filter when also using the option -B (--break-rewrites). Using it as a filter selects files that have had at least a certain percentage of their content deleted or changed.

This “breaking” is not be terribly useful with --name-status since the point of “breaking” is mostly to change how the diff text is generated: it eliminates context lines (unchanged lines) from the diff output instead of generating the add and remove lines that would be required around whatever “random” common subsequences the diff algorithm happened to find.

git init broken-pairs
cd broken-pairs
nums() { seq "$1" "$2" 2>/dev/null || jot $(($2 - $1 + 1)) "$1"; }
nums   0  99 > a
nums 100 199 > b
git add a b
git commit -ma=0-99,b=100-199
nums 200 299 > a
{ nums 100 149; nums 350 399; } > b
git diff --name-status --diff-filter=B             # selects nothing
git diff --name-status --diff-filter=B -B          #         M100    a
git diff --name-status --diff-filter=B -B/50       #         M100    a M050    b

The X “unknown” status should never actually appear. If it does appear, it means a pathname that is neither unmerged, added, deleted, modified or had its type changed (effectively: unchanged) unexpectedly made it to the core of the internal diff machinery; the error feeding unmodified <pathname> to diffcore will also be generated.

It appears to be left over from some old mode of operation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文