=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/pch.c,v retrieving revision 1.56 retrieving revision 1.57 diff -c -r1.56 -r1.57 *** src/usr.bin/patch/pch.c 2017/03/26 15:28:12 1.56 --- src/usr.bin/patch/pch.c 2017/05/26 20:27:02 1.57 *************** *** 1,4 **** ! /* $OpenBSD: pch.c,v 1.56 2017/03/26 15:28:12 deraadt Exp $ */ /* * patch - a program to apply diffs to original files --- 1,4 ---- ! /* $OpenBSD: pch.c,v 1.57 2017/05/26 20:27:02 tedu Exp $ */ /* * patch - a program to apply diffs to original files *************** *** 254,259 **** --- 254,260 ---- char *s, *t; int indent, retval; struct file_name names[MAX_FILE]; + int piece_of_git = 0; memset(names, 0, sizeof(names)); ok_to_create_file = false; *************** *** 298,311 **** if (!stars_last_line && strnEQ(s, "*** ", 4)) names[OLD_FILE].path = fetchname(s + 4, &names[OLD_FILE].exists, strippath); ! else if (strnEQ(s, "--- ", 4)) ! names[NEW_FILE].path = fetchname(s + 4, &names[NEW_FILE].exists, strippath); ! else if (strnEQ(s, "+++ ", 4)) /* pretend it is the old name */ ! names[OLD_FILE].path = fetchname(s + 4, &names[OLD_FILE].exists, strippath); ! else if (strnEQ(s, "Index:", 6)) names[INDEX_FILE].path = fetchname(s + 6, &names[INDEX_FILE].exists, strippath); else if (strnEQ(s, "Prereq:", 7)) { --- 299,318 ---- if (!stars_last_line && strnEQ(s, "*** ", 4)) names[OLD_FILE].path = fetchname(s + 4, &names[OLD_FILE].exists, strippath); ! else if (strnEQ(s, "--- ", 4)) { ! size_t off = 4; ! if (piece_of_git && strippath == 957) ! off = 6; ! names[NEW_FILE].path = fetchname(s + off, &names[NEW_FILE].exists, strippath); ! } else if (strnEQ(s, "+++ ", 4)) { /* pretend it is the old name */ ! size_t off = 4; ! if (piece_of_git && strippath == 957) ! off = 6; ! names[OLD_FILE].path = fetchname(s + off, &names[OLD_FILE].exists, strippath); ! } else if (strnEQ(s, "Index:", 6)) names[INDEX_FILE].path = fetchname(s + 6, &names[INDEX_FILE].exists, strippath); else if (strnEQ(s, "Prereq:", 7)) { *************** *** 320,326 **** free(revision); revision = NULL; } ! } if ((!diff_type || diff_type == ED_DIFF) && first_command_line >= 0 && strEQ(s, ".\n")) { --- 327,334 ---- free(revision); revision = NULL; } ! } else if (strnEQ(s, "diff --git ", 11)) ! piece_of_git = 1; if ((!diff_type || diff_type == ED_DIFF) && first_command_line >= 0 && strEQ(s, ".\n")) {