git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git stash doesn't honor --work-tree or GIT_WORK_TREE
@ 2013-11-30 19:04 Aaron Brooks
  2013-11-30 21:22 ` Øystein Walle
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron Brooks @ 2013-11-30 19:04 UTC (permalink / raw)
  To: git

Unlike other commands, git stash doesn't work outside of the worktree,
even when --work-tree is specified:

abrooks@host:~/tmp$ mkdir test-repo
abrooks@host:~/tmp$ cd !$
cd test-repo
abrooks@host:~/tmp/test-repo$ git init
Initialized empty Git repository in /home/abrooks/tmp/test-repo/.git/
abrooks@host:~/tmp/test-repo$ echo "foo" > foo.txt
abrooks@host:~/tmp/test-repo$ git add foo.txt
abrooks@host:~/tmp/test-repo$ git commit -m "adding foo"
[master (root-commit) 9d0705e] adding foo
 1 file changed, 1 insertion(+)
 create mode 100644 foo.txt
abrooks@host:~/tmp/test-repo$ echo "bar" >> foo.txt
abrooks@host:~/tmp/test-repo$ cd ..
abrooks@host:~/tmp$ git --git-dir=./test-repo/.git --work-tree=./test-repo stash
fatal: /usr/lib/git-core/git-stash cannot be used without a working tree.
abrooks@host:~/tmp$ cd test-repo/
abrooks@host:~/tmp/test-repo$ git stash
Saved working directory and index state WIP on master: 9d0705e adding foo
HEAD is now at 9d0705e adding foo
abrooks@host:~/tmp/test-repo$ cd ../
abrooks@host:~/tmp$ git --git-dir=./test-repo/.git
--work-tree=./test-repo stash list
fatal: /usr/lib/git-core/git-stash cannot be used without a working tree.

The same also does not work when setting GIT_DIR and GIT_WORK_TREE.

As a user, this seems wrong.

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-02 18:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-30 19:04 git stash doesn't honor --work-tree or GIT_WORK_TREE Aaron Brooks
2013-11-30 21:22 ` Øystein Walle
2013-12-01 11:12   ` Thomas Rast
2013-12-01 11:50     ` Duy Nguyen
2013-12-01 15:50       ` Thomas Rast
2013-12-02 18:01         ` Junio C Hamano
2013-12-01 19:12       ` Øystein Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).