Re: [PATCH] Teach "git apply" to prepend a prefix with "--root=<root>"
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jul 1, 2008, 16:34 UTC
- Message-ID
- <alpine.LSU.1.00.0807011831130.32725@wbgn129.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <7vvdzqnemk.fsf@gitster.siamese.dyndns.org>
Hi,
On Tue, 1 Jul 2008, Junio C Hamano wrote:
Show 29 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > > > With "git apply --root=<root>", all file names in the patch are prepended > > with <root>. If a "-p" value was given, the paths are stripped _before_ > > prepending <root>. > > > @@ -182,6 +182,10 @@ behavior: > > by inspecting the patch (e.g. after editing the patch without > > adjusting the hunk headers appropriately). > > > > +--root=<root>:: > > + Prepend <root> to all filenames. If a "-p" argument was passed, too, > > + it is applied before prepending the new root. > > + > > I looked for precedence of this concept outside git but did not find > anything that exactly matched. > > The -p<num> came from patch where it is also called --strip=num. This > new option --root is about the reverse operation and it is about > inserting at the beginning --- it is rerooting, in other words, but then > --root is good enough and shorter. mkisofs uses the word "graft" when > it allows tree shifting (enabled with --graft-points), but the word > "graft" means a totally different thing to us, so we would not want to > use that word. > > I am not complaining (--root is fine by me), but just thinking aloud, > hoping somebody's brainwave is provoked while reading this babbling and > comes up with a better wording ;-).
Yeah, I am not too happy, but I saw you and hpa on IRC agreeing on that option name. I would have said "--prefix", but that is too ambiguous, what with "prefix" already meaning "path relative to the working directory root".
Show 12 quoted lines
> > diff --git a/builtin-apply.c b/builtin-apply.c
> > index 9fcfe39..d56d913 100644
> > --- a/builtin-apply.c
> > +++ b/builtin-apply.c
> > @@ -58,6 +58,8 @@ static int whitespace_error;
> > @@ -3240,6 +3252,18 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
> > options |= RECOUNT;
> > continue;
> > }
> > + if (!strncmp(arg, "--root=", strlen("--root="))) {
>
> prefixcmp()?D'oh.
I mean, thanks!
Show 6 quoted lines
> > + arg += strlen("--root=");
> > + root_len = strlen(arg);
> > + if (root_len && arg[root_len + 1] != '/') {
>
> Ah, being nice not to force trailing slash on users --- how unlike you
> ;-)Seems to be the new favorite sports, Dscho bashing.
> but I think you meant "arg[root_len - 1]" there...
I did. An earlier version (as I found out by using the reflogs, as I tend to do a lot these last couple of weeks) even had a "-". Musta been late.
Ciao, Dscho