threads / discuss / 34003

git daemon --access-hook problem

Subject: git daemon --access-hook problem

## tl;dr

6 messages between May 31, 2013 and Jun 3, 2013.

replies: 5people: 2as markdown or json

Eugene Sajine· May 31, 2013, 20:22 UTC · lore
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· Jun 3, 2013, 00:33 UTC · re: Eugene Sajine · lore

Re: git daemon --access-hook problem

Anybody? Any ideas?
Thanks in advance!
Eugene
On Fri, May 31, 2013 at 4:22 PM, Eugene Sajine <euguess@gmail.com> wrote:
Show 40 quoted lines
> 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· Jun 3, 2013, 17:20 UTC · re: Eugene Sajine · lore

Re: git daemon --access-hook problem

On Fri, May 31, 2013 at 10:22 PM, Eugene Sajine <euguess@gmail.com> wrote:
Show 6 quoted lines
> 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· Jun 3, 2013, 18:02 UTC · re: Antoine Pelisse · lore

Re: git daemon --access-hook problem

> - 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· Jun 3, 2013, 19:05 UTC · re: Eugene Sajine · lore

Re: git daemon --access-hook problem

On Mon, Jun 3, 2013 at 8:02 PM, Eugene Sajine <euguess@gmail.com> wrote:
Show 7 quoted lines
> 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· Jun 3, 2013, 20:00 UTC · re: Antoine Pelisse · lore

Re: git daemon --access-hook problem

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:
Show 14 quoted lines
> 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,

← back to recent threads