context hunk merging in diff
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Riproduci il problema con gli esempi shopping-old.txt e shopping-new.txt usando -U1 e -U2, quindi confronta gli hunk unificati con l’utility diff ufficiale. Non viene indicato alcun file sorgente né alcun test; segui il punto di ingresso della generazione e dell’unione degli hunk di unified diff e considera il problema risolto quando un contesto sovrapposto o adiacente produce un unico hunk unito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 276
- Fork
- 39
- Merge medio
- 3h 27m
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di uutils/diffutils
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
Tutte le issue di uutils/diffutils
Issue simili
-
Replayed reasoning items send "content": null, which the Responses API schema does not permit Apertabug CLI custom-model
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
rust-bitcoin/rust-bitcoin#6930 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
fulcrumgenomics/ferro-hgvs#2251 ·
-
A-allocators A-docs C-enhancement T-libs
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100