{ "about": "A file's content and a unified diff for it → the new content, or the error the model is told (apply_patch's second format; LLeMbas's file_edit). Line numbers are a hint: the context is found within 200 lines of it, and must be unique there; CRLF is kept; a blank context line may lack its space; hunks apply in order, all or nothing.", "cases": [ { "content": "a\nb\nc\nd\ne\nf\ng\n", "patch": "@@ -2,3 +2,3 @@\n b\n-c\n+C\n d\n", "expect": { "content": "a\nb\nC\nd\ne\nf\ng\n" } }, { "content": "a\nb\nc\nd\ne\nf\ng\n", "patch": "@@ -40,3 +40,3 @@\n b\n-c\n+C\n d\n", "expect": { "content": "a\nb\nC\nd\ne\nf\ng\n" } }, { "content": "x\ny\nx\ny\n", "patch": "@@ -9,2 +9,2 @@\n x\n-y\n+Y\n", "expect": { "error": "Hunk 1 did not apply. Those context lines appear 2 times in the file, and the line numbers in the hunk header do not point at any of them, so there is no way to tell which was meant. Include more unchanged lines around the change. Nothing was written." } }, { "content": "a\r\nb\r\nc\r\n", "patch": "@@ -1,3 +1,3 @@\n a\n-b\n+B\n c\n", "expect": { "content": "a\r\nB\r\nc\r\n" } }, { "content": "a\n\nc\n", "patch": "@@ -1,3 +1,3 @@\n a\n\n-c\n+C\n", "expect": { "content": "a\n\nC\n" } }, { "content": "a\nb\n", "patch": "@@ -1,0 +2,1 @@\n+inserted\n", "expect": { "content": "a\ninserted\nb\n" } }, { "content": "a\nb\nc\nd\ne\nf\ng\n", "patch": "just some text\n", "expect": { "error": "That patch has no hunks. A unified diff needs at least one `@@ -old,count +new,count @@` header, followed by the lines: ' ' for context, '-' to remove, '+' to add." } }, { "content": "a\nb\nc\nd\ne\nf\ng\n", "patch": "diff --git a/f.txt b/f.txt\nindex 1234..5678 100644\n--- a/f.txt\n+++ b/f.txt\n@@ -1,2 +1,2 @@\n-a\n+A\n b\n", "expect": { "content": "A\nb\nc\nd\ne\nf\ng\n" } }, { "content": "a\nb\n", "patch": "@@ -1,2 +1,2 @@\n a\n-b\n+B\n\\ No newline at end of file\n", "expect": { "content": "a\nB" } }, { "content": "a\nb\nc\nd\ne\nf\ng\n", "patch": "@@ -3,2 +3,2 @@\n nothing\n-like this\n+here\n", "expect": { "error": "Hunk 1 did not apply. It expects line 3 to be\n nothing\nbut the file has\n 1 a\n 2 b\n-> 3 c\n 4 d\n 5 e\n 6 f\nand those lines are nowhere else nearby either. Nothing was written. Send a patch whose context matches what is printed above." } }, { "content": "a\nb\nc\nd\ne\nf\ng\n", "patch": "@@ -1,2 +1,2 @@\n-a\n+A\n b\n@@ -6,2 +6,2 @@\n f\n-g\n+G\n", "expect": { "content": "A\nb\nc\nd\ne\nf\nG\n" } }, { "content": "a\nb\nc\n", "patch": "@@ -1,2 +1,2 @@\n-a\n+A\n b\n@@ -1,2 +1,2 @@\n-a\n+A\n b\n", "expect": { "error": "Hunk 2 did not apply. It expects line 1 to be\n a\nbut the file has\n-> 1 a\n 2 b\n 3 c\nand those lines are nowhere else nearby either. Nothing was written. Send a patch whose context matches what is printed above." } } ] }