Re: [PATCH] Teach "git apply" to prepend a prefix with "--root=<root>"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> 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 ;-).

> 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()?

> +			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 ;-)
but I think you meant "arg[root_len - 1]" there...

Other than that, the change looks fine.  Thanks.
--
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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux