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

Re: [RFC/PATCH] git: expand user path in --git-dir

From
Jeff King <peff@peff.net>
Date
Sep 24, 2012, 14:52 UTC
Message-ID
<20120924145208.GB10349@sigill.intra.peff.net>
In-Reply-To
<fdeaa78c0a520ce80e6d2cb09978dab348104eaf.1348491039.git.git@drmicha.warpmail.net>
On Mon, Sep 24, 2012 at 02:57:20PM +0200, Michael J Gruber wrote:
Show 22 quoted lines
> Currently, all paths in the config file are subject to tilde expansion
> for user paths while the argument to --git-dir is not expanded, and
> neither are paths in the environment such as GIT_DIR. From the user
> perspective, though, the two commands
> 
> GIT_DIR=~user/foo git command
> git --git-dir=~user/foo command
> 
> currently behave differently because in the first case the shell would
> perform tilde expansion, but not in the second. Also, one may argue that
> specifying '--git-dir=' is like specifying a config variable (which
> cannot exist for this purpose).
> 
> Thus, make arguments to '--git-dir' undergo tilde expansion.
> ---
> So, here's a simple patch implementing tilde expansion for --git-dir. It passes
> all tests. It's done doing the expansion on the setting side.
> 
> Alternatively, one might do it on the getting side, i.e. when reading GIT_DIR,
> so that paths passed directly through the environment undergo tilde expansion
> as well. We don't do this for any environment variable yet, so I didn't go
> that far.

Keep in mind that every layer of expansion you add is a layer of quoting somebody else must do in order to pass through certain paths. I will admit that putting a "~" into a path is relatively uncommon, but this patch is a regression for anybody who does so with --git-dir (they will now need to quote the "~" against not just their shell, but against git). Expanding environment variables like GIT_DIR means that we would also need to quote things we put into GIT_DIR.

-Peff
Previous: Michael J GruberNext: Michael J Gruber
Message 7 of 17 in “GIT_DIR vs. --git-dir”
  1. Michael J GruberSep 24, 2012
  2. Nguyen Thai Ngoc DuySep 24, 2012
  3. Michael J GruberSep 24, 2012
  4. Nguyen Thai Ngoc DuySep 24, 2012
  5. Michael J GruberSep 24, 2012
  6. git: expand user path in --git-dirMichael J Gruber, Sep 24, 2012
  7. Jeff KingSep 24, 2012
  8. Michael J GruberSep 24, 2012
  9. Junio C HamanoSep 24, 2012
  10. Jan EngelhardtSep 25, 2012
  11. Michael J GruberSep 25, 2012
  12. Andreas SchwabSep 24, 2012
  13. Junio C HamanoSep 24, 2012
  14. Michael J GruberSep 24, 2012
  15. Jeff KingSep 24, 2012
  16. Michael J GruberSep 24, 2012
  17. Andreas SchwabSep 24, 2012

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.