threads / discuss / 44189

Impossible to change working directory

Subject: Impossible to change working directory

## tl;dr

3 messages between Sep 29, 2016 and Oct 1, 2016.

replies: 2people: 3as markdown or json

Sebastian Feldmann· Sep 29, 2016, 19:30 UTC · lore
Hi there,

I have a problem executing a pre-commit hook. The hook script has to change the working directory to work and if I use plain

git commit
it works as expected, the script executes without errors, but if I use
git commit —only file.x file.y

the script fails because changing the current working directory fails. If I echo the current working directory it always echoes the root repository path

Is this expected behavior? Thanks for your feedback.

Cheers Sebastian
Junio C Hamano· Sep 29, 2016, 23:24 UTC · re: Sebastian Feldmann · lore

Re: Impossible to change working directory

Sebastian Feldmann <sf@sebastian-feldmann.info> writes:
> the script fails because changing the current working directory fails.
> If I echo the current working directory it always echoes the root repository path
>
> Is this expected behavior?
Yes, we always go to the top before doing anything.

If you echo environment variables Git may set up for you, what do you see? Do you see GIT_PREFIX that you can use to tell where you came from, or something like that?

Torsten Bögershausen· Oct 1, 2016, 15:34 UTC · re: Sebastian Feldmann · lore

Re: Impossible to change working directory

On 29.09.16 21:30, Sebastian Feldmann wrote:
Show 16 quoted lines
> Hi there,
>
> I have a problem executing a pre-commit hook.
> The hook script has to change the working directory to work and if I use plain
>
> git commit
>
> it works as expected, the script executes without errors, but if I use
>
> git commit —only file.x file.y
>
> the script fails because changing the current working directory fails.
> If I echo the current working directory it always echoes the root repository path
>
> Is this expected behavior?
> Thanks for your feedback.

Is there any chance to send us the content of the script ? (Or a demo example, which doesn't work)

← back to recent threads