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

Re: git stash doesn't honor --work-tree or GIT_WORK_TREE

From
Øystein Walle <oystwa@gmail.com>
Date
Nov 30, 2013, 21:22 UTC
Message-ID
<loom.20131130T221443-682@post.gmane.org>
In-Reply-To
<CABL6xpD9jvJWjUj0n+mgC419fGzA2N-b_yJho9zharCD6YTSiw@mail.gmail.com>
Aaron Brooks <aaron <at> brooks1.net> writes:
Show 17 quoted lines
> 
> Unlike other commands, git stash doesn't work outside of the worktree,
> even when --work-tree is specified:
> 
> (...)
> 
> It looks like the "require_work_tree" function should check the
> environment variables in addition to the status of the PWD (via
> git-rev-parse).
> 
> Having looked through several of the other git-*.sh scripts, I think
> other shell based git commands will have similar problems.
> 
> Thanks,
> 
> Aaron
> 

The environment variables are properly exported. I verified this by adding 'echo $GIT_WORK_TREE; echo $GIT_DIR' at the top of git-stash.sh. So these should propagate to "child gits" just fine, and so it shouldn't be necessary to test them explicitly.

The problem seems to be that git rev-parse --is-inside-work-tree does not honor these. In fact it doesn't even honor --git-dir or --work-tree. Judging by the name this may be intentional.

In the mean time, if you are able to use Git 1.8.5, `git -C test-repo stash` will work just fine.

Øsse
Previous: Aaron BrooksNext: Thomas Rast
Message 2 of 7 in “git stash doesn't honor --work-tree or GIT_WORK_TREE”
  1. Aaron BrooksNov 30, 2013
  2. Øystein WalleNov 30, 2013
  3. Thomas RastDec 1, 2013
  4. Duy NguyenDec 1, 2013
  5. Thomas RastDec 1, 2013
  6. Junio C HamanoDec 2, 2013
  7. Øystein WalleDec 1, 2013

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.