From: Junio C Hamano Date: Wed, 9 Jul 2008 23:58:21 +0000 (-0700) Subject: Merge branch 'js/apply-root' X-Git-Tag: v1.6.0-rc0~94 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e9a9d6edeeafa53a203c7ae379373af5394d4fde;p=git.git Merge branch 'js/apply-root' * 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=" --- e9a9d6edeeafa53a203c7ae379373af5394d4fde diff --cc Documentation/git-apply.txt index e9f724b2f,3cd3179ff..feb51f124 --- a/Documentation/git-apply.txt +++ b/Documentation/git-apply.txt @@@ -9,12 -9,12 +9,12 @@@ git-apply - Apply a patch on a git inde SYNOPSIS -------- [verse] -'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] +'git apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--build-fake-ancestor ] [-R | --reverse] [--allow-binary-replacement | --binary] [--reject] [-z] - [-pNUM] [-CNUM] [--inaccurate-eof] [--cached] + [-pNUM] [-CNUM] [--inaccurate-eof] [--recount] [--cached] [--whitespace=] - [--exclude=PATH] [--verbose] [...] + [--exclude=PATH] [--directory=] [--verbose] [...] DESCRIPTION ----------- @@@ -177,11 -177,14 +177,19 @@@ behavior 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=:: + Prepend 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 c0f867dae,c242bbd83..b3fc290ff --- a/builtin-apply.c +++ b/builtin-apply.c @@@ -3233,13 -3127,21 +3245,25 @@@ int cmd_apply(int argc, const char **ar 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);