author | Junio C Hamano <gitster@pobox.com> | |
Wed, 9 Jul 2008 23:58:21 +0000 (16:58 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 9 Jul 2008 23:58:21 +0000 (16:58 -0700) |
* js/apply-root:
git-apply --directory: make --root more similar to GNU diff
apply --root: thinkofix.
Teach "git apply" to prepend a prefix with "--root=<root>"
git-apply --directory: make --root more similar to GNU diff
apply --root: thinkofix.
Teach "git apply" to prepend a prefix with "--root=<root>"
1 | 2 | |||
---|---|---|---|---|
Documentation/git-apply.txt | patch | | diff1 | | diff2 | | blob | history |
builtin-apply.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc Documentation/git-apply.txt
index e9f724b2fa35cf18978dbcba9dcef7ed28a1b19d,3cd3179ff17f45ec0c0cbd3687fdf8020cd8e5f4..feb51f124ac8a806e65d41f6274c58de64d2991f
SYNOPSIS
--------
[verse]
-'git-apply' [--stat] [--numstat] [--summary] [--check] [--index]
+'git apply' [--stat] [--numstat] [--summary] [--check] [--index]
[--apply] [--no-add] [--build-fake-ancestor <file>] [-R | --reverse]
[--allow-binary-replacement | --binary] [--reject] [-z]
- [-pNUM] [-CNUM] [--inaccurate-eof] [--cached]
+ [-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached]
[--whitespace=<nowarn|warn|fix|error|error-all>]
- [--exclude=PATH] [--verbose] [<patch>...]
+ [--exclude=PATH] [--directory=<root>] [--verbose] [<patch>...]
DESCRIPTION
-----------
current patch being applied will be printed. This option will cause
additional information to be reported.
+--recount::
+ Do not trust the line counts in the hunk headers, but infer them
+ by inspecting the patch (e.g. after editing the patch without
+ adjusting the hunk headers appropriately).
+
+ --directory=<root>::
+ Prepend <root> to all filenames. If a "-p" argument was passed, too,
+ it is applied before prepending the new root.
+ +
+ For example, a patch that talks about updating `a/git-gui.sh` to `b/git-gui.sh`
+ can be applied to the file in the working tree `modules/git-gui/git-gui.sh` by
+ running `git apply --directory=modules/git-gui`.
+
Configuration
-------------
diff --cc builtin-apply.c
index c0f867daed351d4b32f871941e14773a44508eaf,c242bbd83bd0f154ccf5d4a8be7f85386216cebc..b3fc290ff33e6388b25b6cb046ad97856d81169d
--- 1/builtin-apply.c
--- 2/builtin-apply.c
+++ b/builtin-apply.c
continue;
}
if (!strcmp(arg, "--inaccurate-eof")) {
- inaccurate_eof = 1;
+ options |= INACCURATE_EOF;
+ continue;
+ }
+ if (!strcmp(arg, "--recount")) {
+ options |= RECOUNT;
continue;
}
+ if (!prefixcmp(arg, "--directory=")) {
+ arg += strlen("--directory=");
+ root_len = strlen(arg);
+ if (root_len && arg[root_len - 1] != '/') {
+ char *new_root;
+ root = new_root = xmalloc(root_len + 2);
+ strcpy(new_root, arg);
+ strcpy(new_root + root_len++, "/");
+ } else
+ root = arg;
+ continue;
+ }
if (0 < prefix_length)
arg = prefix_filename(prefix, prefix_length, arg);