# # # patch "diff_patch.cc" # from [9683e035dc2e1ab8d9dd17a002ab808e5b40d792] # to [2d75afbcc07d318c789eaf3697f46821e7d1de62] # # patch "tests/calculation_of_unidiffs_start_of_file/__driver__.lua" # from [10acd94d2d039e77061d78040e0761a7774055d1] # to [942ae4233f2927b43f5cb2ddb4f8e0d145881871] # ============================================================ --- diff_patch.cc 9683e035dc2e1ab8d9dd17a002ab808e5b40d792 +++ diff_patch.cc 2d75afbcc07d318c789eaf3697f46821e7d1de62 @@ -1128,12 +1128,12 @@ void unidiff_hunk_writer::advance_to(siz void unidiff_hunk_writer::advance_to(size_t newpos) { - if (a_begin + a_len + (2 * ctx) < newpos) + if (a_begin + a_len + (2 * ctx) < newpos || hunk.empty()) { flush_hunk(newpos); // insert new leading context - if (newpos - ctx < a.size()) + if (newpos < a.size() + ctx) { for (size_t i = ctx; i > 0; --i) { ============================================================ --- tests/calculation_of_unidiffs_start_of_file/__driver__.lua 10acd94d2d039e77061d78040e0761a7774055d1 +++ tests/calculation_of_unidiffs_start_of_file/__driver__.lua 942ae4233f2927b43f5cb2ddb4f8e0d145881871 @@ -21,7 +21,7 @@ rename("monodiff", "stdin") -- see if patch likes that rename("monodiff", "stdin") -xfail({"patch", "firstfile"}, 0, false, false, true) +check({"patch", "firstfile"}, 0, false, false, true) -- see if the resulting file has been properly patched check(samefile("firstfile", "secondfile"))