context hunk merging in diff
まだ誰も着手していません。
評価
調査の方向性
-U1 と -U2 を使用して shopping-old.txt と shopping-new.txt の例で問題を再現し、その後、unified hunk を公式の diff ユーティリティと比較します。ソースファイルもテストも指定されていません。unified-diff hunk の生成とマージのエントリポイントを追跡し、重複する、または隣接するコンテキストによって 1 つのマージ済み 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
- フォーク
- 39
- 平均マージ
- 3時間 27分
- マージ済み PR(30日)
- 3
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
uutils/diffutils のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 64/100
uutils/diffutils の issue をすべて見る
似ている issue
-
risk:low runtime status:in-progress type:test
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
EricSpencer00/Resilient#4835 · コメント 1 件 ·
-
agent:ready documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
cesarferreira/stax#890 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 90/100