Reputation: 335
My git push operation finishes in around 25-30 seconds, instead of (more-or-less) immediate return. I am using a quite long post-receive (bash) script that I`ve found here: https://raw.github.com/zma/usefulscripts/master/script/post-receive
Some details:
I did some testing and if the post-receive script contains around 70 lines that are all commented out (so the script does nothing), push has a delay around 5 seconds.
Is this normal? Or is there a way to speed up push? Or I must reduce the script size dramatically?
Update: It is important to mention that:
Upvotes: 1
Views: 1319
Reputation: 1324757
The git hooks page clearly mentions about the post-receive
hook:
This script can’t stop the push process, but the client doesn’t disconnect until it has completed; so, be careful when you try to do anything that may take a long time.
That means, in your case, you need to switch to an asynchronous approach (unless you can fix what takes time, like Sqeezer's answer, upvoted, seems to propose):
That way, the post-receive hook returns as fast as possible, not blocking the client (downstream repo from where the push was initiated)
Upvotes: 1
Reputation: 335
It turned out that the samba share was configured to not to use oplocks with the following options in the smb.conf:
Removing these entries from the share`s configuration reduced the delay of the post-receive execution to around 4-5 seconds, which is reasonable I think.
Upvotes: 1
Reputation: 335
An interesting follow up: I`ve tested the script on another PC and it is working fine. No delay at all. So there are some issues on my PC regarding how git processes remote scripts.
The remote repository is on a samba share. I took a wireshark traces with 2 scenarios:
cat <path_to_the_script>\post-receive
command in the git bashreal
git pushResults (without too much technical details):
Conclusion: git push command reads the post-receive script in 1 byte chunks
Upvotes: 2
Reputation: 1277
From the script description
# An example hook script to mail out commit update information. This hook
# sends emails listing new revisions to the repository introduced by the
# change being reported. The rule is that (for branch updates) each commit
# will appear on one email and one email only.
Then take a look at the bottom of the script. It says:
# Note: change the smtp server to yours
cat $email_tmp_file | mailx -S smtp="smtp://smtp.cse.ust.hk" -s "$emailsubject" -r $senderemail $recipients
I believe you haven't configured your smtp server, therefore your script is waiting for smtp.cse.ust.hk
to connect and then just disconnects by timeout.
Upvotes: 1