* Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter
@ 2017-11-30 7:02 marc PINHEDE
2017-12-04 10:55 ` Jacob Keller
0 siblings, 1 reply; 2+ messages in thread
From: marc PINHEDE @ 2017-11-30 7:02 UTC (permalink / raw)
To: git
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter
2017-11-30 7:02 Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter marc PINHEDE
@ 2017-12-04 10:55 ` Jacob Keller
0 siblings, 0 replies; 2+ messages in thread
From: Jacob Keller @ 2017-12-04 10:55 UTC (permalink / raw)
To: marc PINHEDE, git
On November 29, 2017 11:02:10 PM PST, marc PINHEDE <marc.pinhede@gmail.com> wrote:
>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
It's possible that is-inside-worktree is testing if current dir is inside work tree, and not if the work tree variable is... Thus I wouldn't expect this to behave as you seem to expect.
>
>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
It doesn't sound like normal behavior to me... Does "git -C" work?
Either way id expect setting the work tree and got dir to work for most commands.
However, it may not of the command expects current dir to matter. That's where using -C comes into play. Try that and see if it fixes your problem.
That is, git -C <path to work tree> stash
Thanks,
Jake
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-12-04 10:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-30 7:02 Git stash (or git rev-parse) doesn't inherit the '--work-tree' parameter marc PINHEDE
2017-12-04 10:55 ` Jacob Keller
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).