The Joyent Community

A place where the Joyent community can gather, help each other out, and stay informed.

You are not logged in.

#1 2008-06-19 11:13:07

gk
New member
Registered: 2007-08-17
Posts: 3
Expertise

Git: push error

Hi

I am hoping someone could point me in the right direction or perhaps suggest a better solution.

I was having trouble pushing my local git repository to my repos hosted on my git accelerator until I resorted to a "temporary" fix after much googling and as far as I know this issue has not come up on Joyent forums either.

I added the server as a remote location and pushed:

Code:

git remote add origin ssh://me@my_joyent_box/repos/playground.git
git push origin master


the error is as follows:

Code:

hooks/update: syntax error at line 40: `allowunannotated=$' unexpected
error: hooks/update exited with error code 2
error: hook declined to update refs/heads/master


As far as I can tell this is caused by the update hook script using /bin/sh and barfing when using the $() call.
I couldn't really get anywhere reading about the different shells and none of the general suggested solutions worked.

So I decided to replace /bin/sh with /bin/bash in the hook shell scripts like so:

Code:

cd playground.git
perl -e "s/\/bin\/sh/\/bin\/bash/g;" -pi $(find hooks -type f)
cd /opt/local/share/git-core/templates
perl -e "s/\/bin\/sh/\/bin\/bash/g;" -pi $(find hooks -type f)


It all works groovy now, but somehow this has left me with the feeling like it isn't really the "right" solution.

For reference:

I compiled git like so:

Code:

cd git-1.5.5.4/
./configure --prefix=/opt/local
sudo gmake AR=gar NO_ICONV=1 NO_TCLTK=1 SHELL_PATH=/usr/bin/bash CFLAGS="-Wall -O2 -I/opt/csw/include" LDFLAGS="-L/opt/csw/lib"

Last edited by gk (2008-06-19 11:43:17)

Offline

 

#2 2008-06-19 12:29:15

chrispoole
Member
From: England
Registered: 2006-02-26
Posts: 118
Website  Expertise

Re: Git: push error

1.5.6 is just out and may have some fix?

Other than that, have you tried using the git protocol, as opposed to ssh?

Offline

 

#3 2008-06-19 12:59:57

gk
New member
Registered: 2007-08-17
Posts: 3
Expertise

Re: Git: push error

chrispoole wrote:

1.5.6 is just out and may have some fix?

Other than that, have you tried using the git protocol, as opposed to ssh?


thnx for the reply.

the problem will remain even with higher versions as the hook scripts use #!/bin/sh(which is correct and works on all other OSes I have tested). I use both ssh(push) and git(pull) protocol but the afore mentioned problem still occurs due to the hook being executed after a push. This is my assumption but it seems Solaris(my accelerator at least) is using what seems to be a Bourne Shell as /bin/sh.

I suppose if /bin/sh was symlinked to bash I wouldn't have these problems, but that solution under Solaris is quite dangerous based on what is being said on the net.

I don't suffer this issue under my OSX or Ubuntu(which uses dash as /bin/sh).

Last edited by gk (2008-06-19 13:02:43)

Offline

 

#4 2008-12-23 23:06:56

Harry
Member
From: Seattle, WA
Registered: 2005-01-21
Posts: 497
Website  Expertise

Re: Git: push error

This is happening to me when I create a new git repo with git init --bare and then try to push to it. It's happening on two different shared Accelerators. No problems when I try the exact same process on a dedicated Accelerator.

Offline

 

#5 2008-12-23 23:26:25

Andy
Dabbler
From: London
Registered: 2005-01-15
Posts: 1177
Website  Expertise

Re: Git: push error

I ran across thie problem a few days ago (I'm on a Shared Accelerator). Comparing older git repositories on that SA with ones that have just been created shows that in the older ones, none of the hooks were turned on (chmod +x). On the new repositories, all of the hooks are chmod +x, so the hooks are trying to execute and are running across the error above. The solution for me was to just chmod -x ~/git/*/hooks/*.


— Andy (andrewlkho)

Offline

 

#6 2008-12-24 15:02:58

unglued
Member
From: philly
Registered: 2005-10-18
Posts: 222
Website  Expertise

Re: Git: push error

Thanks for the detective work Andy -- that fix worked perfectly. I had the same problem (on shared, though i guess we're in the wrong forum).

Offline

 

#7 2008-12-26 07:07:16

stmpjmpr
New member
Registered: 2004-10-20
Posts: 27
Expertise

Re: Git: push error

I too am on Shared and had this problem. Thanks, Andy!

Offline

 

#8 2009-02-08 05:41:20

poswald
New member
From: Brooklyn, NY
Registered: 2005-03-17
Posts: 22
Website  Expertise

Re: Git: push error

I am also getting this on drake (shared accelerator). Your solution will work but the script given in the wiki explicitly enables one of the hooks:

http://wiki.joyent.com/shared:kb:git

It says:

Code:

# Make the repository accessible over http
chmod +x "$1/hooks/post-update"


I think that script could use something like the following command in there as well:

  1. Make the repository accessible over http

chmod -x "$1/hooks/*"

I don't know why this hook didn't need the script changed to /bin/bash. I've done commits and pushes since then without any errors. Perhaps it only gets run the first time...

Offline

 

#9 2009-06-26 22:11:25

brianolpin
New member
From: Seattle
Registered: 2008-11-20
Posts: 1
Expertise

Re: Git: push error

I had the same problem as gk. I was getting the same errors when uploading a local git repository:

hooks/update: syntax error at line 40: `allowunannotated=$' unexpected

etc.

The fix was to NOT use the convenience script at the bottom of the "Git on Shared Accelerators" wiki page, as I had used initially, but rather to setup the repository on the server by hand and do the chmod +x, etc. by hand. Then everything worked just fine.

Offline

 

#10 2009-08-12 12:51:16

mamash
I Just Work Here
From: Prague
Registered: 2004-06-01
Posts: 2164
Website  Expertise

Re: Git: push error

This problem of hooks being pre-enabled on init is fixed in the 2009Q1 package set (for Accelerators). We'll fix it with the next maintenance on Shared Accelerators. We're also working around the fact that the Git developers use /bin/sh as the interpreter in these, but assume it's a Korn or Bash shell in their code in fact (whereas /bin/sh denotes a Bourne shell).


The things you can't remember tell the things you can't forget.

Offline

 

#11 2009-09-09 20:13:57

minimal design
Member
From: NYC
Registered: 2006-02-11
Posts: 91
Website  Expertise

Re: Git: push error

Just ran into same exact problem on Donahue... Thanks Andy!

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson