Make apply accept the -pNUM option like patch does.

This only applies to traditional diffs, not to git diffs.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Daniel Barkalow
2006-01-31 00:36:24 -05:00
committed by Junio C Hamano
parent c8568e139e
commit e36f8b6034
2 changed files with 11 additions and 3 deletions

View File

@ -10,7 +10,7 @@ SYNOPSIS
-------- --------
[verse] [verse]
'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply] 'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
[--no-add] [--index-info] [--allow-binary-replacement] [-z] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM]
[<patch>...] [<patch>...]
DESCRIPTION DESCRIPTION
@ -68,6 +68,10 @@ OPTIONS
backslash characters replaced with `\t`, `\n`, and `\\`, backslash characters replaced with `\t`, `\n`, and `\\`,
respectively. respectively.
-p<n>::
Remove <n> leading slashes from traditional diff paths. The
default is 1.
--apply:: --apply::
If you use any of the options marked ``Turns off If you use any of the options marked ``Turns off
"apply"'' above, git-apply reads and outputs the "apply"'' above, git-apply reads and outputs the

View File

@ -19,6 +19,7 @@
static const char *prefix; static const char *prefix;
static int prefix_length = -1; static int prefix_length = -1;
static int p_value = 1;
static int allow_binary_replacement = 0; static int allow_binary_replacement = 0;
static int check_index = 0; static int check_index = 0;
static int write_index = 0; static int write_index = 0;
@ -31,7 +32,7 @@ static int no_add = 0;
static int show_index_info = 0; static int show_index_info = 0;
static int line_termination = '\n'; static int line_termination = '\n';
static const char apply_usage[] = static const char apply_usage[] =
"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] <patch>..."; "git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM] <patch>...";
/* /*
* For "diff-stat" like behaviour, we keep track of the biggest change * For "diff-stat" like behaviour, we keep track of the biggest change
@ -217,7 +218,6 @@ static char * find_name(const char *line, char *def, int p_value, int terminate)
*/ */
static void parse_traditional_patch(const char *first, const char *second, struct patch *patch) static void parse_traditional_patch(const char *first, const char *second, struct patch *patch)
{ {
int p_value = 1;
char *name; char *name;
first += 4; // skip "--- " first += 4; // skip "--- "
@ -1799,6 +1799,10 @@ int main(int argc, char **argv)
excludes = x; excludes = x;
continue; continue;
} }
if (!strncmp(arg, "-p", 2)) {
p_value = atoi(arg + 2);
continue;
}
if (!strcmp(arg, "--no-add")) { if (!strcmp(arg, "--no-add")) {
no_add = 1; no_add = 1;
continue; continue;