How to read diff result: Difference between revisions

From 清冽之泉
Jump to navigation Jump to search
No edit summary
Tag: Reverted
No edit summary
 
(39 intermediate revisions by the same user not shown)
Line 1: Line 1:
<graphviz>
在各类代码阅读过程中,diff 结果可谓至关重要。本图讲述怎样读懂 diff 后生成的结果。其中 git diff 形式是最应该引起注意的。
graph {
randir = LR;


5c7 [shape=record, label="{<1> 5 | <2> c | <3> 7}"]
[[File:读懂 diff 20250117.png|1200px]]
5c7:1 -- 第几行有变动
5c7:2 -- 具体变动
5c7:3 -- 变动后是第几行
 
}
</graphviz>
 
<graphviz>
digraph G {
    rankdir=TB;
    node [shape=plaintext];
 
    "2" [label="2\nProud version\nBump when you are\nproud of the release", fontsize=14];
    "7" [label="7\nDefault version\nJust normal/okay\nreleases", fontsize=14];
    "123" [label="123\nShame version\nBump when fixing things\ntoo embarrassing to admit", fontsize=14];
 
    "Pride versioning" [shape=none, fontsize=18, label="Pride versioning"];
 
    "Pride versioning" -> "2";
    "Pride versioning" -> "7";
    "Pride versioning" -> "123";
}
</graphviz>
 
 
<graphviz>
digraph G {
    rankdir=TB; // 设置方向为从上到下
    node [shape=record, fontsize=14];
 
    // 定义 Pride versioning 的节点
    title [shape=none, label="Pride versioning", fontsize=20, fontname="Helvetica-Bold"];
 
    // 定义版本号节点,使用 port 标记
    version [label="{<proud> 2 | <default> 7 | <shame> 123}", fontsize=16, fontname="Helvetica"];
 
    // 定义解释文字节点
    proud [shape=plaintext, label="Proud version\nBump when you are\nproud of the release"];
    default [shape=plaintext, label="Default version\nJust normal/okay releases"];
    shame [shape=plaintext, label="Shame version\nBump when fixing things\ntoo embarrassing to admit"];
 
    // 添加连接
    title -> version;
    version:proud -> proud [arrowhead=none];  // 连接 proud 部分
    version:default -> default [arrowhead=none]; // 连接 default 部分
    version:shame -> shame [arrowhead=none];  // 连接 shame 部分
}
</graphviz>

Latest revision as of 09:07, 17 January 2025

在各类代码阅读过程中,diff 结果可谓至关重要。本图讲述怎样读懂 diff 后生成的结果。其中 git diff 形式是最应该引起注意的。