diff options
Diffstat (limited to 'parse-options.c')
-rw-r--r-- | parse-options.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/parse-options.c b/parse-options.c index a1ec932f0f..f8a155ee13 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1,9 +1,11 @@ #include "git-compat-util.h" #include "parse-options.h" -#include "cache.h" +#include "abspath.h" #include "config.h" #include "commit.h" #include "color.h" +#include "gettext.h" +#include "strbuf.h" #include "utf8.h" static int disallow_abbreviated_options; @@ -59,12 +61,12 @@ static enum parse_opt_result get_arg(struct parse_opt_ctx_t *p, return 0; } -static void fix_filename(const char *prefix, const char **file) +static void fix_filename(const char *prefix, char **file) { - if (!file || !*file || !prefix || is_absolute_path(*file) - || !strcmp("-", *file)) - return; - *file = prefix_filename(prefix, *file); + if (!file || !*file) + ; /* leave as NULL */ + else + *file = prefix_filename_except_for_dash(prefix, *file); } static enum parse_opt_result opt_command_mode_error( @@ -177,7 +179,7 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p, err = get_arg(p, opt, flags, (const char **)opt->value); if (!err) - fix_filename(p->prefix, (const char **)opt->value); + fix_filename(p->prefix, (char **)opt->value); return err; case OPTION_CALLBACK: @@ -702,8 +704,7 @@ static struct option *preprocess_options(struct parse_opt_ctx_t *ctx, if (!nr_aliases) return NULL; - ALLOC_ARRAY(newopt, nr + 1); - COPY_ARRAY(newopt, options, nr + 1); + DUP_ARRAY(newopt, options, nr + 1); /* each alias has two string pointers and NULL */ CALLOC_ARRAY(ctx->alias_groups, 3 * (nr_aliases + 1)); |