Fede wrote: > Jonathan Nieder wrote: >> I had thought -p was only supposed to apply to traditional patches. >> Maybe a documentation update would avoid confusion? >> >> -p<n> >> Remove <n> leading slashes from traditional diff paths. >> The default is 1. > > Currently, if the patch is mode-change only then the filename is taken > from the line "diff --git ...". Ah, found it: commit 79ee194e52a140412da475e102145bad80d5d00a Author: Shawn O. Pearce <spearce@xxxxxxxxxxx> Date: Wed Apr 4 11:19:14 2007 -0400 Honor -p<n> when applying git diffs If the user is trying to apply a Git generated diff file and they have specified a -p<n> option, where <n> is not 1, the user probably has a good reason for doing this. Such as they are me, trying to apply a patch generated in git.git for the git-gui subdirectory to the git-gui.git repository, where there is no git-gui subdirectory present. Users shouldn't supply -p2 unless they mean it. But if they are supplying it, they probably have thought about how to make this patch apply to their working directory, and want to risk whatever results may come from that. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> Signed-off-by: Junio C Hamano <junkio@xxxxxxx> -- 8< -- Subject: Documentation: update description of "git apply -p" The "git apply -p" (strip path components) option has gone through some changes since it was last documented: ec7fc0b (builtin-apply.c: pay attention to -p<n> when..., 2009-11-25) 79ee194 (Honor -p<n> when applying git diffs, 2007-04-04) 3e8a5db (git-apply: guess correct -p<n> value for non-git..., 2007-02-21) 56185f4 (git-apply: require -p<n> when working in a subdirectory, 2007-02-19) Document some of the new rules: - the -p option applies to both traditional and --git format diffs - in traditional diffs, since there is no customary standard -p value, 'git apply' will try to guess - in all cases, the default is 1 Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- Thoughts? Improvements? diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt index 4a74b23..8bb7422 100644 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@ -103,8 +103,11 @@ respectively, and the pathname will be enclosed in double quotes if any of those replacements occurred. -p<n>:: - Remove <n> leading slashes from traditional diff paths. The - default is 1. + Remove <n> leading path components from paths found in the + diff. The default is 1 for --git format diffs. For + traditional diffs, if this option is not supplied, 'git apply' + will try to detect an appropriate -p value, defaulting to 1 + if there is not enough information to guess. -C<n>:: Ensure at least <n> lines of surrounding context match before -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html