From 80170bd73d5d6298ea6d40c66987fcde8148f1e8 Mon Sep 17 00:00:00 2001 From: Antonio Jesus Navarro Perez Date: Fri, 7 Sep 2018 10:50:31 +0200 Subject: Fix fatal corrupt patch in unified diff format Signed-off-by: Antonio Jesus Navarro Perez --- plumbing/format/diff/unified_encoder_test.go | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'plumbing/format/diff/unified_encoder_test.go') diff --git a/plumbing/format/diff/unified_encoder_test.go b/plumbing/format/diff/unified_encoder_test.go index 0e419ca..7736af1 100644 --- a/plumbing/format/diff/unified_encoder_test.go +++ b/plumbing/format/diff/unified_encoder_test.go @@ -150,6 +150,43 @@ var oneChunkPatchInverted Patch = testPatch{ } var fixtures []*fixture = []*fixture{{ + patch: testPatch{ + message: "", + filePatches: []testFilePatch{{ + from: &testFile{ + mode: filemode.Regular, + path: "README.md", + seed: "hello\nworld\n", + }, + to: &testFile{ + mode: filemode.Regular, + path: "README.md", + seed: "hello\nbug\n", + }, + chunks: []testChunk{{ + content: "hello", + op: Equal, + }, { + content: "world", + op: Delete, + }, { + content: "bug", + op: Add, + }}, + }}, + }, + desc: "positive negative number", + context: 2, + diff: `diff --git a/README.md b/README.md +index 94954abda49de8615a048f8d2e64b5de848e27a1..f3dad9514629b9ff9136283ae331ad1fc95748a8 100644 +--- a/README.md ++++ b/README.md +@@ -1,2 +1,2 @@ + hello +-world ++bug +`, +}, { patch: testPatch{ message: "", filePatches: []testFilePatch{{ -- cgit