• Junio C Hamano's avatar
    builtin-apply.c: pay attention to -p<n> when determining the name · ec7fc0b1
    Junio C Hamano authored
    The patch structure has def_name component that is used to validate the
    sanity of a "diff --git" patch by checking pathnames that appear on the
    patch header lines for consistency.  The git_header_name() function is
    used to compute this out of "diff --git a/... b/..." line, but the code
    always stripped one level of prefix (i.e. "a/" and "b/"), without paying
    attention to -p<n> option.  Code in find_name() function that parses other
    lines in the patch header (e.g. "--- a/..." and "+++ b/..." lines) however
    did strip the correct number of leading paths prefixes, and the sanity
    check between these computed values failed.
    Teach git_header_name() to honor -p<n> option like find_name() function
    Found and reported by Steven J. Murdoch who also wrote tests.
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
t4128-apply-root.sh 2.37 KB