diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-02-03 14:16:04 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-02-03 14:16:04 -0800 |
commit | c167a96e68b9fb49cab7eb1f2814d7b32f7c0a1a (patch) | |
tree | 9cd4964f51f8c32133d5e5cce34bedd86e11ee4d /diff.c | |
parent | 465c30a9c6f68c3bac25cd875624286baa37b41c (diff) | |
parent | a97262c62f1a31fcc7edf7629d313058bc7d66b5 (diff) | |
download | git-c167a96e68b9fb49cab7eb1f2814d7b32f7c0a1a.tar.gz |
Merge branch 'nd/diff-with-path-params'
A few options of "git diff" did not work well when the command was
run from a subdirectory.
* nd/diff-with-path-params:
diff: make -O and --output work in subdirectory
diff-no-index: do not take a redundant prefix argument
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -3693,12 +3693,16 @@ static int parse_ws_error_highlight(struct diff_options *opt, const char *arg) return 1; } -int diff_opt_parse(struct diff_options *options, const char **av, int ac) +int diff_opt_parse(struct diff_options *options, + const char **av, int ac, const char *prefix) { const char *arg = av[0]; const char *optarg; int argcount; + if (!prefix) + prefix = ""; + /* Output format options */ if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch") || opt_arg(arg, 'U', "unified", &options->context)) @@ -3915,7 +3919,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) else if (!strcmp(arg, "--pickaxe-regex")) options->pickaxe_opts |= DIFF_PICKAXE_REGEX; else if ((argcount = short_opt('O', av, &optarg))) { - options->orderfile = optarg; + const char *path = prefix_filename(prefix, strlen(prefix), optarg); + options->orderfile = xstrdup(path); return argcount; } else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) { @@ -3954,9 +3959,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) else if (!strcmp(arg, "--no-function-context")) DIFF_OPT_CLR(options, FUNCCONTEXT); else if ((argcount = parse_long_opt("output", av, &optarg))) { - options->file = fopen(optarg, "w"); + const char *path = prefix_filename(prefix, strlen(prefix), optarg); + options->file = fopen(path, "w"); if (!options->file) - die_errno("Could not open '%s'", optarg); + die_errno("Could not open '%s'", path); options->close_file = 1; return argcount; } else |