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

Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter

From
MPmarc PINHEDE <marc.pinhede@gmail.com>
Date
Nov 30, 2017, 07:02 UTC
Message-ID
<CAJsT1ck6dCPLLMLjgq9jrQmOAC-6jF6kFEX6aaRJGw3Hn9He=w@mail.gmail.com>
Hello guys,
I don't know if this is a normal behavior, so I'll just explain it here.
* Behavior:
from a directory OUTSIDE my git repo, I can run this command successfully:
 $ git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path pull origin master
But this one:
 $ git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path stash
Will fails with :
 'fatal: $program_name cannot be used without a working tree.'
(Yes, the error message has been corrected since, but I use debian, so
I'm at least 6 month late).
* A bit of investigation:
I don't know many about git internal functioning, but with a bit of
googleing, I would point out git-sh-setup.sh:204, in function
require_work_tree, called by git-stash.
I could test (from outside my git repo, again):
 git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path rev-parse
--is-inside-work-tree
return:
 false
What surprise me is that 'git-dir' seems to be passed ok to rev-parse:
 git --git-dir=/my/repo/path/.git --work-tree=/my/repo/path rev-parse --git-dir
returns:
 /my/repo/path/.git
* Question
Is this a normal behavior? Stash can only be applied in current
working directory?
If yes, I'll have to change my script to
 (cd && git command)
If not, should I push a bug report somewhere?
Marc
Next: Jacob Keller
Message 1 of 2 in “Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter”
  1. marc PINHEDENov 30, 2017
  2. Jacob KellerDec 4, 2017

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.