# git daemon --access-hook problem

6 messages from 2013-05-31 to 2013-06-03. Participants: Eugene Sajine, Antoine Pelisse.
Thread: https://gitlist.dev/t/34003

## Eugene Sajine, 2013-05-31 20:22

Subject: git daemon --access-hook problem
Message-ID: <CAPZPVFZDHHGyHhzBVVK6jS=XhEd2+JpmBT8ofiGOww8vuLUWWw@mail.gmail.com>
URL: https://gitlist.dev/e/CAPZPVFZDHHGyHhzBVVK6jS%3DXhEd2%2BJpmBT8ofiGOww8vuLUWWw%40mail.gmail.com

```
Hi,

I'm trying to test this new feature and having problems getting any
results in the following scenario:

i have a repo in local folder

/home/users/myuser/repos/projectA/.git

i start the daemon with the following:

git daemon --export-all --base-path=/home/users/myuser/repos
--enable=receive-pack --access-hook=/home/users/myuser/test_hook.bash

test_hook.bash has the following:

#!/bin/bash
echo $@ >> test_hook_out.txt
echo $REMOTE_ADDR >> test_hook_out.txt

the hook is set to be executable - otherwise it complains when i do
anything via git protocol, which proves that it seems to or check the
hook:

then i did:

cd ~/tmp/

git clone git://myhost/projectA projectA
cd projectA

and trying to perform some operations like fetch or push. It is cloned
and fetches and pushes successfully.
The problem is that the file test_hook_out.txt doesn't have anything
in it after the execution, So the hook doesn't seem to work.

What might be the issue here?

Thanks,
Eugene

```

## Eugene Sajine, 2013-06-03 00:33

Subject: Re: git daemon --access-hook problem
Message-ID: <CAPZPVFboSH_4ehpu0WMPOz86w1Ak5L5FWOyM8M43fStGqU5sGg@mail.gmail.com>
URL: https://gitlist.dev/e/CAPZPVFboSH_4ehpu0WMPOz86w1Ak5L5FWOyM8M43fStGqU5sGg%40mail.gmail.com
In-Reply-To: <CAPZPVFZDHHGyHhzBVVK6jS=XhEd2+JpmBT8ofiGOww8vuLUWWw@mail.gmail.com>

```
Anybody? Any ideas?

Thanks in advance!

Eugene

On Fri, May 31, 2013 at 4:22 PM, Eugene Sajine <euguess@gmail.com> wrote:
> Hi,
>
> I'm trying to test this new feature and having problems getting any
> results in the following scenario:
>
> i have a repo in local folder
>
> /home/users/myuser/repos/projectA/.git
>
> i start the daemon with the following:
>
> git daemon --export-all --base-path=/home/users/myuser/repos
> --enable=receive-pack --access-hook=/home/users/myuser/test_hook.bash
>
> test_hook.bash has the following:
>
> #!/bin/bash
> echo $@ >> test_hook_out.txt
> echo $REMOTE_ADDR >> test_hook_out.txt
>
> the hook is set to be executable - otherwise it complains when i do
> anything via git protocol, which proves that it seems to or check the
> hook:
>
> then i did:
>
> cd ~/tmp/
>
> git clone git://myhost/projectA projectA
> cd projectA
>
> and trying to perform some operations like fetch or push. It is cloned
> and fetches and pushes successfully.
> The problem is that the file test_hook_out.txt doesn't have anything
> in it after the execution, So the hook doesn't seem to work.
>
> What might be the issue here?
>
> Thanks,
> Eugene

```

## Antoine Pelisse, 2013-06-03 17:20

Subject: Re: git daemon --access-hook problem
Message-ID: <CALWbr2ypPCoftVLfP9uKeKStg3TWwLDchkUaL1d9s9O3kcuPwA@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2ypPCoftVLfP9uKeKStg3TWwLDchkUaL1d9s9O3kcuPwA%40mail.gmail.com
In-Reply-To: <CAPZPVFZDHHGyHhzBVVK6jS=XhEd2+JpmBT8ofiGOww8vuLUWWw@mail.gmail.com>

```
On Fri, May 31, 2013 at 10:22 PM, Eugene Sajine <euguess@gmail.com> wrote:
> and trying to perform some operations like fetch or push. It is cloned
> and fetches and pushes successfully.
> The problem is that the file test_hook_out.txt doesn't have anything
> in it after the execution, So the hook doesn't seem to work.
>
> What might be the issue here?

I have no idea what the issue might be, but here's how I usually debug
this kind of situations:
- Exit with a non-zero value will make it an error, try "exit 1" at
the end of your script, you will know if it's executed or not
- Your log file might not be located where you expect, you should use
absolute path to dump text
- Dump the cwd to know where it's executed from
- The documentation says you can print one line before a failure, also
try this to show the cwd

Hope that helps,
Antoine,

```

## Eugene Sajine, 2013-06-03 18:02

Subject: Re: git daemon --access-hook problem
Message-ID: <CAPZPVFYdeuusW3=iBTBC+iPuOeAekvtMx6d_dozB9tsDCg3C8Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAPZPVFYdeuusW3%3DiBTBC%2BiPuOeAekvtMx6d_dozB9tsDCg3C8Q%40mail.gmail.com
In-Reply-To: <CALWbr2ypPCoftVLfP9uKeKStg3TWwLDchkUaL1d9s9O3kcuPwA@mail.gmail.com>

```
> - Your log file might not be located where you expect, you should use
> absolute path to dump text

You were right! The problem was with the script itself - the log file
not being specified with absolute path! Stupid me!

...
> - The documentation says you can print one line before a failure, also
> try this to show the cwd

Would you be able to advise how this should be done?
I don't get the error message (i mean the output of pwd) if i do this:

echo `pwd`
exit 1

What should it be?

Thanks!
Eugene



>
> Hope that helps,
> Antoine,

```

## Antoine Pelisse, 2013-06-03 19:05

Subject: Re: git daemon --access-hook problem
Message-ID: <CALWbr2ynF425qfCNr_NGH8z9UiX2G2CRrWiCo2XrgBLBbyPHMw@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2ynF425qfCNr_NGH8z9UiX2G2CRrWiCo2XrgBLBbyPHMw%40mail.gmail.com
In-Reply-To: <CAPZPVFYdeuusW3=iBTBC+iPuOeAekvtMx6d_dozB9tsDCg3C8Q@mail.gmail.com>

```
On Mon, Jun 3, 2013 at 8:02 PM, Eugene Sajine <euguess@gmail.com> wrote:
> Would you be able to advise how this should be done?
> I don't get the error message (i mean the output of pwd) if i do this:
>
> echo `pwd`
> exit 1
>
> What should it be?

Actually, after digging into the code, it looks like you need to call
git-daemon with "--informative-errors" if you want to allow custom
errors. Maybe there is place for improvement in the documentation.

Cheers,

```

## Eugene Sajine, 2013-06-03 20:00

Subject: Re: git daemon --access-hook problem
Message-ID: <CAPZPVFaJ0qOhxMYDxhq4+qnWQjjhFRUjzGAemqjwAAoxC8-EDQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAPZPVFaJ0qOhxMYDxhq4%2BqnWQjjhFRUjzGAemqjwAAoxC8-EDQ%40mail.gmail.com
In-Reply-To: <CALWbr2ynF425qfCNr_NGH8z9UiX2G2CRrWiCo2XrgBLBbyPHMw@mail.gmail.com>

```
Right, --informative-errors does make it better;)

Actually the CWD for the access-hook is not where the hook script is,
but inside the .git folder of the target repo. GTK.

and yes, definitely some documentation improvements needed;)

Thanks!

On Mon, Jun 3, 2013 at 3:05 PM, Antoine Pelisse <apelisse@gmail.com> wrote:
> On Mon, Jun 3, 2013 at 8:02 PM, Eugene Sajine <euguess@gmail.com> wrote:
>> Would you be able to advise how this should be done?
>> I don't get the error message (i mean the output of pwd) if i do this:
>>
>> echo `pwd`
>> exit 1
>>
>> What should it be?
>
> Actually, after digging into the code, it looks like you need to call
> git-daemon with "--informative-errors" if you want to allow custom
> errors. Maybe there is place for improvement in the documentation.
>
> Cheers,

```
