diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-03-20 01:03:12 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-03-20 01:03:12 +0300 |
commit | 95de3763498a5a092a454bb548d40e918c2870c1 (patch) | |
tree | ed82119d97b88465de12360cc27db9933b04df4e /parse-options.c | |
parent | 12201fd756bad12c137343d5fd65200f4d0f192d (diff) | |
parent | 0bbe10313e0b61812082d47431e8648f9df48f15 (diff) |
Merge branch 'jk/bundle-use-dash-for-stdfiles'
"git bundle" learned that "-" is a common way to say that the input
comes from the standard input and/or the output goes to the
standard output. It used to work only for output and only from the
root level of the working tree.
* jk/bundle-use-dash-for-stdfiles:
parse-options: use prefix_filename_except_for_dash() helper
parse-options: consistently allocate memory in fix_filename()
bundle: don't blindly apply prefix_filename() to "-"
bundle: document handling of "-" as stdin
bundle: let "-" mean stdin for reading operations
Diffstat (limited to 'parse-options.c')
-rw-r--r-- | parse-options.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/parse-options.c b/parse-options.c index fd4743293f..6dd4c090e0 100644 --- a/parse-options.c +++ b/parse-options.c @@ -59,12 +59,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 +177,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: |