diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-02-14 17:51:48 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-14 10:21:21 -0800 |
commit | f812cd94a2c31a059f44d1c98db0287af1295b39 (patch) | |
tree | dafde58f33407b3b17c682d8ecd89303f76f2e69 | |
parent | 8279ed033f703d4115bee620dccd32a9ec94d9aa (diff) | |
download | git-f812cd94a2c31a059f44d1c98db0287af1295b39.tar.gz |
parse-options: expand $HOME on filename options
When you specify "--path ~/foo", the shell will automatically expand
~/foo to $HOME/foo before it's passed to git. The expansion is not done
on "--path=~/foo". An experienced user sees the difference but it could
still be confusing for others (especially when tab-completion still
works on --path=~/foo).
Support $HOME expansion for all filename options. There are about seven
of them.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | parse-options.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/parse-options.c b/parse-options.c index fca7159646..3717acef08 100644 --- a/parse-options.c +++ b/parse-options.c @@ -38,10 +38,13 @@ static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt, static void fix_filename(const char *prefix, const char **file) { - if (!file || !*file || !prefix || is_absolute_path(*file) - || !strcmp("-", *file)) + if (!file || !*file || is_absolute_path(*file) || + !strcmp("-", *file)) return; - *file = prefix_filename(prefix, *file); + if (**file == '~') + *file = expand_user_path(*file, 0); + else if (prefix) + *file = prefix_filename(prefix, *file); } static int opt_command_mode_error(const struct option *opt, |