From: Jonathan Nieder <jrnieder@gmail.com>
To: Fede <fedux@lugmen.org.ar>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH] Fix git-apply with -p greater than 1
Date: Fri, 22 Oct 2010 10:38:03 -0500 [thread overview]
Message-ID: <20101022153803.GD9224@burratino> (raw)
In-Reply-To: <4CC194DF.9040803@lugmen.org.ar>
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@spearce.org>
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@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
-- 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@gmail.com>
---
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
next prev parent reply other threads:[~2010-10-22 15:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 22:12 [PATCH] Fix git-apply with -p greater than 1 Federico Cuello
2010-10-22 5:01 ` Junio C Hamano
2010-10-22 5:31 ` Jonathan Nieder
2010-10-22 13:42 ` Fede
2010-10-22 15:38 ` Jonathan Nieder [this message]
2010-10-22 18:41 ` Junio C Hamano
2010-10-22 18:51 ` Federico Cuello
2010-10-25 14:11 ` Federico Cuello
2010-10-22 18:40 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101022153803.GD9224@burratino \
--to=jrnieder@gmail.com \
--cc=fedux@lugmen.org.ar \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).