Hello,

The following snippet reproduces the issue for me (note the
remote: line in its output):

    git --version

    rm -rf a b

    git init a
    cd a
    echo first >data
    git add data
    git commit -m initial
    cat >>.git/hooks/post-receive <<EOF
    #!/bin/sh
    pwd
    EOF
    chmod +x .git/hooks/post-receive
    cd ..

    git clone a b
    cd b
    echo second >>data
    git add data
    git commit -m test
    git push origin master:not-master

According to man githooks "Before Git invokes a hook, it changes
its working directory to either the root of the working tree in a
non-bare repository, [...]". In this case "a" is non-bare and I
expected the command to be run in the working tree; but instead
it's run inside .git. (This caused some confusion in my case
because I ran "git merge" in the hook which put files in the .git
directory and I didn't notice it at first. I know running merge
in receive-hooks is "bad practice" but it works fine in my
setup.)

The same happens for all hooks executed by git-receive-pack:
pre-receive, update, post-receive, post-update.

Is this a documentation issue or unexpected behavior?

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

Attachment: signature.asc
Description: PGP signature

Reply via email to