git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] parse-options: expand $HOME on filename options

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 22, 2018, 09:26 UTC
Message-ID
<CACsJy8BsUsT6iO9_68+rHnZG5B-tcaXZAXR88nh8DgR65zvVKw@mail.gmail.com>
In-Reply-To
<87wozffavp.fsf@evledraar.gmail.com>

On Thu, Feb 15, 2018 at 5:46 AM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 9 quoted lines
> In general I'm mildly negative on adding this, for every user like Doron
> who'll be less confused by a hack like this, you'll have other users
> who'll be confused about git inexplicably working with ~ in the middle
> of strings, even though;
>
>     $ echo git init --template ~/path
>     git init --template /home/avar/path
>     $ echo git init --template=~/path
>     git init --template=~/path

If you have a directory named '~', I expect you are already used to prefixing it with './' because '~' will be expanded in many places where you might want to avoid.

Show 12 quoted lines
> I think it makes more sense to just leave such expansion to the shell,
> and not try to magically expand it after the fact, since it's both
> confusing (user: why does this work with git and not this other
> program?), and as shown above changes existing semantics.
>
> We'll also be setting ourselves up for more disappointed users who'll
> notice that e.g. `git clone file://~/path` doesn't work, but `git clone
> file://$HOME/path` does, requiring more hacks to expand ~ in more
> codepaths. Will they also expact `git log -G~` to find references to
> their homedir in their dotfiles.git?
>
> I think this way lies madness, and it's better to just avoid it.

Well. That's a bit extreme, I think if we add this then we handle case by case in future when it makes sense, not blindly expanding '~' everywhere.

The problem I have with this --template=~/path is tab-completion actually completes the path, which (mis)leads me to think the command will accept '~/' too. But this looks like a bug in git-completion.bash though, it's a bit eager in completing stuff (or maybe it completes "--template ~/path" and "--template=~/path" the same way).

I don't feel strongly about this. I'm OK with dropping these patches if people think it's not a good idea (then I will try to fix git-completion.bash not to complete '~' in this case).

> But I think that if we're going to keep it it needs some tests & docs to
> point confused users to.
-- 
Duy
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 9 of 11 in “[BUG] git init doesn't respect `--template` like configuration variable init.templateDir and $GIT_TEMPLATE_DIR”
  1. Doron BeharFeb 14, 2018
  2. 1/2 parse-options: expand $HOME on filename optionsNguyễn Thái Ngọc Duy, Feb 14, 2018
  3. 2/2 init-db: change --template type to OPTION_FILENAMENguyễn Thái Ngọc Duy, Feb 14, 2018
  4. Jeff KingFeb 14, 2018
  5. Jeff KingFeb 14, 2018
  6. Junio C HamanoFeb 14, 2018
  7. Ævar Arnfjörð BjarmasonFeb 14, 2018
  8. Junio C HamanoFeb 15, 2018
  9. Duy NguyenFeb 22, 2018
  10. Ævar Arnfjörð BjarmasonFeb 22, 2018
  11. Duy NguyenFeb 23, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.