context hunk merging in diff
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
使用 -U1 和 -U2 透過 shopping-old.txt 與 shopping-new.txt 範例重現問題,然後將 unified hunk 與官方 diff 工具進行比較。未指定來源檔案或測試;追蹤 unified-diff hunk 的產生與合併入口,並在重疊或相鄰的內容產生一個合併後的 hunk 時,將該 issue 視為完成。
由索引模型根據 Issue 內容生成。
描述
In playing with diffutils in the uutils playground web page, I noticed that -U1 on the shopping files was outputting a second hunk that has no prior context line. The official diff utility joins hunks together when the context overlaps or even just abuts.
My test:
uutils $ diff shopping-old.txt shopping-new.txt -U1
--- shopping-old.txt 2026-08-09 03:43:13.212000000 +0000
+++ shopping-new.txt 2026-08-09 03:43:13.212000000 +0000
@@ -2,2 +2,3 @@
eggs
+yogurt
bread
@@ -4,2 +5,2 @@
-butter
+honey
apples
As another test, I added another line of context between the chunks:
uutils $ sed shopping-old.txt >s1 -e 's/bread/bread\nrolls/'
uutils $ sed shopping-new.txt >s2 -e 's/bread/bread\nrolls/'
Now the 1-line context is present on hunk 2, but the normal diff util would join them together since they abut:
uutils $ diff s1 s2 -u1
--- s1 1970-01-01 00:00:00.000000000 +0000
+++ s2 1970-01-01 00:00:00.000000000 +0000
@@ -2,2 +2,3 @@
eggs
+yogurt
bread
@@ -4,3 +5,3 @@
rolls
-butter
+honey
apples
At this point -U2 has the missing context in the same manner as in the first example.
- 主要語言
- Rust
- 星號
- 276
- 分支
- 44
- 平均合併
- 1 天 18 小時
- 30 天內合併 PR
- 9
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
uutils/diffutils 的其他 Issue
-
cmp: quiet mode compares full file sizes before applying -n可能已有人在做 @SichenLiang 於 12 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
diff: `-y --tabsize=<huge>` overflows the column arithmetic (overflow-checks only)可能已有人在做 @sami-daniel 於 63 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
diff panics on an oversized inline context count (`-c`/`-u`/`-C`/`-U`): parse overflow and capacity overflow可能已有人在做 @MsfPablo 於 58 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
uutils/diffutils#245 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
sdiff: fix the layout of unchanged rows, blank lines and cut tabs可能已有人在做 @sami-daniel 於 9 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 28/100
維護者通常 1 天內回覆
相似的 Issue
-
agent:triaged bug bughunt pm:bundler priority:p1
難度 2/5 1-3 小時 新手友好度 70/100
SocketDev/socket-patch#1573 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
bytecodealliance/rustix#1706 · 1 則留言 ·
維護者通常 11 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
-
難度 2/5 1-3 小時 新手友好度 72/100
wormhole-foundation/wormhole#5062 ·
維護者通常 1 天內回覆
-
LaunchOrFocusPlugin switches to the wrong tab after tabs are reordered (tab id used as position)可能已有人在做 @olegator888 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
zellij-org/zellij#5719 ·
維護者通常 1 天內回覆