All of lore.kernel.org
 help / color / mirror / Atom feed
* error: cannot run hooks/pre-receive: No such file or directory
@ 2011-03-30 13:27 Mathieu Malaterre
  2011-03-30 18:35 ` Computer Druid
  2011-03-30 20:04 ` Jeff King
  0 siblings, 2 replies; 4+ messages in thread
From: Mathieu Malaterre @ 2011-03-30 13:27 UTC (permalink / raw)
  To: git

Hi all,

  I am trying to use a ruby script to reject commit with non-linear
history (*). However it keeps failing with the following message:

$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 304 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
error: cannot run hooks/pre-receive: No such file or directory
To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to
'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'

I tried with something as simple as :

% cat pre-receive
#!/usr/bin/ruby
% which ruby
/usr/bin/ruby

Do I need to do something special with ruby ?

Thanks,
-- 
Mathieu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error: cannot run hooks/pre-receive: No such file or directory
  2011-03-30 13:27 error: cannot run hooks/pre-receive: No such file or directory Mathieu Malaterre
@ 2011-03-30 18:35 ` Computer Druid
  2011-03-30 20:04 ` Jeff King
  1 sibling, 0 replies; 4+ messages in thread
From: Computer Druid @ 2011-03-30 18:35 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: git

On Wed, Mar 30, 2011 at 9:27 AM, Mathieu Malaterre
<mathieu.malaterre@gmail.com> wrote:
> Hi all,
>
>  I am trying to use a ruby script to reject commit with non-linear
> history (*). However it keeps failing with the following message:
>
> $ git push
> Counting objects: 5, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (3/3), done.
> Writing objects: 100% (3/3), 304 bytes, done.
> Total 3 (delta 2), reused 0 (delta 0)
> error: cannot run hooks/pre-receive: No such file or directory
> To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old
>  ! [remote rejected] master -> master (pre-receive hook declined)
> error: failed to push some refs to
> 'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'
>
> I tried with something as simple as :
>
> % cat pre-receive
> #!/usr/bin/ruby
> % which ruby
> /usr/bin/ruby
Check that hooks/pre-receive is executable? (chmod +x)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error: cannot run hooks/pre-receive: No such file or directory
  2011-03-30 13:27 error: cannot run hooks/pre-receive: No such file or directory Mathieu Malaterre
  2011-03-30 18:35 ` Computer Druid
@ 2011-03-30 20:04 ` Jeff King
  2011-03-31  7:20   ` Mathieu Malaterre
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff King @ 2011-03-30 20:04 UTC (permalink / raw)
  To: Mathieu Malaterre; +Cc: git

On Wed, Mar 30, 2011 at 03:27:14PM +0200, Mathieu Malaterre wrote:

> $ git push
> Counting objects: 5, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (3/3), done.
> Writing objects: 100% (3/3), 304 bytes, done.
> Total 3 (delta 2), reused 0 (delta 0)
> error: cannot run hooks/pre-receive: No such file or directory
> To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old
>  ! [remote rejected] master -> master (pre-receive hook declined)
> error: failed to push some refs to
> 'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'

We won't try to execute a hook that doesn't exist, so the "no such file
or directory" almost certainly means the #! interpreter is missing.

> I tried with something as simple as :
> 
> % cat pre-receive
> #!/usr/bin/ruby
> % which ruby
> /usr/bin/ruby

This might be a stupid question, but which machine is that output from?
The pre-receive hook runs on the server, so you must have ruby there. I
ask mainly because I didn't realize sourceforge would give people
arbitrary shell access on the git boxes.

My next guess would be that the git process runs in some kind of chroot
that doesn't have ruby in it.

> Do I need to do something special with ruby ?

>From git's perspective, no, but it may depend on how the server is
configured.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: error: cannot run hooks/pre-receive: No such file or directory
  2011-03-30 20:04 ` Jeff King
@ 2011-03-31  7:20   ` Mathieu Malaterre
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Malaterre @ 2011-03-31  7:20 UTC (permalink / raw)
  Cc: git

On Wed, Mar 30, 2011 at 10:04 PM, Jeff King <peff@peff.net> wrote:
> On Wed, Mar 30, 2011 at 03:27:14PM +0200, Mathieu Malaterre wrote:
>
>> $ git push
>> Counting objects: 5, done.
>> Delta compression using up to 4 threads.
>> Compressing objects: 100% (3/3), done.
>> Writing objects: 100% (3/3), 304 bytes, done.
>> Total 3 (delta 2), reused 0 (delta 0)
>> error: cannot run hooks/pre-receive: No such file or directory
>> To ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old
>>  ! [remote rejected] master -> master (pre-receive hook declined)
>> error: failed to push some refs to
>> 'ssh://malat@gdcm.git.sourceforge.net/gitroot/gdcm/gdcm.old'
>
> We won't try to execute a hook that doesn't exist, so the "no such file
> or directory" almost certainly means the #! interpreter is missing.
>
>> I tried with something as simple as :
>>
>> % cat pre-receive
>> #!/usr/bin/ruby
>> % which ruby
>> /usr/bin/ruby
>
> This might be a stupid question, but which machine is that output from?
> The pre-receive hook runs on the server, so you must have ruby there. I
> ask mainly because I didn't realize sourceforge would give people
> arbitrary shell access on the git boxes.
>
> My next guess would be that the git process runs in some kind of chroot
> that doesn't have ruby in it.

Makes complete sense now. I thought initially that the "no such file"
refered to the actual hooks script. I naively assumed my ssh
connection on sf.net gave me access to the actual git boxes (or maybe
it is executed from a chroot).

In any case rewriting the script in pure shell script (no bash either)
seems to work ok now (*).

However I am now being told that this script should rather go in the
update hooks...


(*)
read rev_old rev_new refname

ref_to_check="refs/heads/master"

if [ "$refname" == "$ref_to_check" ]
then
  merge_bases=`git merge-base ${rev_old} ${rev_new}`
  if [ "$merge_bases" != "$rev_old" ]
  then
    echo "Non fastward is disallowed"
    exit 1
  fi
  # non-fast-forward case:
  git rev-list --parents $merge_bases..$rev_new \
    | while read x; do
      set -- $x
      if [ "$#" != "2" ]
      then
        echo "Multiple parents: $x";
        exit 1
      fi;
    done
  [ $? -ne 0 ] && exit 1
fi
exit 0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-31  7:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30 13:27 error: cannot run hooks/pre-receive: No such file or directory Mathieu Malaterre
2011-03-30 18:35 ` Computer Druid
2011-03-30 20:04 ` Jeff King
2011-03-31  7:20   ` Mathieu Malaterre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.