[git-users] Re: post-receive not able to execute git checkout

2013-07-29 Thread Andreas Dvorak
Hi Krishna,
 
unfortunately that did not help. The output is the same.
DATE_STAMP=$(date +%Y%m%d%H%M)
LOG=/var/tmp/git.log
echo checkout $DATE_STAMP $LOG
cd /var/tmp/test2_clone
GIT_TRACE=1
git fetch origin

git push
Enter passphrase for key '/home/user1/.ssh/id_rsa': 
Counting objects: 5, done.
Delta compression using up to 32 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 293 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: fatal: Not a git repository: '.'
To git@rh6-puppet-master:/data/git/test2.git
   3358239..e636eca  master - master
Best regards
Andreas

Am Samstag, 27. Juli 2013 03:25:47 UTC+2 schrieb krishna chaitanya kurnala:

 Hello 

 Try adding GIT_TRACE=1 before the checkout for some additional debug info 
 ...

 -Krishna

 On Friday, July 26, 2013 7:28:16 AM UTC-7, Andreas Dvorak wrote: 

 Hi,
 I would like to sync the central bare repository to an other directory.
 After a git push on a local repository my post-receive hook is executed.
  
 DATE_STAMP=$(date +%Y%m%d%H%M)
 LOG=/var/tmp/git.log
 echo checkout $DATE_STAMP $LOG
 cd /var/tmp/test2_clone
 ls -la 
 git checkout *
 The log file is written and ls shows the destination directory, but git 
 checkout * does not work.
  
 git push
 Enter passphrase for key '/home/user1/.ssh/id_rsa': 
 Counting objects: 5, done.
 Delta compression using up to 32 threads.
 Compressing objects: 100% (2/2), done.
 Writing objects: 100% (3/3), 292 bytes, done.
 Total 3 (delta 0), reused 0 (delta 0)
 remote: total 12
 remote: drwxr-xr-x  3 git  git  4096 26. Jul 16:12 .
 remote: drwxrwxrwt. 4 root root 4096 26. Jul 16:08 ..
 remote: drwxrwxr-x  8 git  git  4096 26. Jul 16:12 .git
 remote: fatal: Not a git repository: '.'
 To g...@rh6-puppet-master:/data/git/test2.git
ca4950c..6a00a47  master - master
  
 If I execute git checkout * manually it does work. Can somebody please 
 help me?
  
 Best regards,
 Andreas
  



-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [git-users] Re: post-receive not able to execute git checkout

2013-07-29 Thread Konstantin Khomoutov
On Mon, 29 Jul 2013 03:50:56 -0700 (PDT)
Andreas Dvorak andreas.dvo...@googlemail.com wrote:

 Hi Krishna,
  
 unfortunately that did not help. The output is the same.
 DATE_STAMP=$(date +%Y%m%d%H%M)
 LOG=/var/tmp/git.log
 echo checkout $DATE_STAMP $LOG
 cd /var/tmp/test2_clone
 GIT_TRACE=1
 git fetch origin

^^^ There has been `git checkout *` in your original message;
what's the matter with this change?

 git push
 Enter passphrase for key '/home/user1/.ssh/id_rsa': 
 Counting objects: 5, done.
 Delta compression using up to 32 threads.
 Compressing objects: 100% (2/2), done.
 Writing objects: 100% (3/3), 293 bytes, done.
 Total 3 (delta 0), reused 0 (delta 0)
 remote: fatal: Not a git repository: '.'

My take on this is that when server-side Git process executes your
hook it sets several environment variables which affect the execution
of the hook script; when you run `git checkout` (or whatever else),
there's no such variables.
These variables are explained in [1], and the easiest way to see what
they are is to add something like

set /tmp/hook.envvars

at the beginning of your hook script then perform push to trigger the
hook and examine the generated file.

And by the way, doing `git checkout *` in your script might not do
what you really mean: the asterisk will be expanded by the shell to
the list of files in the current directory, not passed to the
`git checkout` command as is to be interpreted by Git, so supposedly
you want to protect that character from being expanded by the shell.

1. https://www.kernel.org/pub/software/scm/git/docs/git.html

P.S.
Instead of reinventing the wheel (what you appear to be doing) I'd just
google for git+web+deploy and study ready-made solutions.  Beleive me,
while Git developers are tireless in explaining that Git is not a
deployment tool, every second web developer disagrees and embarks on
exactly this task.  StackOverflow receives at least one question per
day asking about how to do web deployment with Git, so you're
definitely not the first, and the internets are abundant with
information on how to do this with various degrees of lameness, so I'd
do some recearch and try out various solutions.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [git-users] Re: post-receive not able to execute git checkout

2013-07-29 Thread Konstantin Khomoutov
On Mon, 29 Jul 2013 06:06:32 -0700 (PDT)
Andreas Dvorak andreas.dvo...@googlemail.com wrote:

 I found the solution. With env -i to unset the environment the git
 command does work
 #!/bin/sh
 DATE_STAMP=$(date +%Y%m%d%H%M)
 LOG=/var/tmp/git.log
 echo checkout $DATE_STAMP $LOG
 cd /var/tmp/test2_clone
 env -i git fetch origin
 env -i git reset --hard origin/master
 env -i git clean -f -d

The probem here is that you have no idea why this fixed your problem.
Please try to understand why happens using the approach I proposed in
my other mail and invent a proper (read: thought-out) fix to your
problem.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [git-users] Re: post-receive not able to execute git checkout

2013-07-29 Thread Dale R. Worley
The problem seems to be that the Git process on the remote end has a
current working directory that it doesn't think is a Git reponsitory.

Most likely this is because the Git remote link has directed the
remote process to be in a directory that *isn't* a Git repository.  Is
there any way that you can verify what the remote directory is?  Also,
what actually is in that directory?  Have you verified that everything
in that directory is readable/writable by the UID under which the
remote Git is executing?

What is the remote link that the near-end Git is using to perform the
push?

One thing I notice in an early message is that the ls -la shows:

remote: total 12
remote: drwxr-xr-x  3 git  git  4096 26. Jul 16:12 .
remote: drwxrwxrwt. 4 root root 4096 26. Jul 16:08 ..
remote: drwxrwxr-x  8 git  git  4096 26. Jul 16:12 .git

This suggests that the current working directory is not the .git
directory, but the woking copy directory that contains it.  I don't
know the official specification (and it's not likely to have been
written down anywhere), but it is possible that the directory for
remote operations *must* be a *bare* repository.  Try adding a /.git
to the end of the remote URL for the remote link.

Dale

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [git-users] Re: post-receive not able to execute git checkout

2013-07-29 Thread Konstantin Khomoutov
On Mon, 29 Jul 2013 11:22:38 -0400
wor...@alum.mit.edu (Dale R. Worley) wrote:

[...]
 I don't know the official specification (and it's not likely to have
 been written down anywhere), but it is possible that the directory for
 remote operations *must* be a *bare* repository.
[...]

To my knowledge, the only restriction Git has on remote (in the sense
we're considering there) repositories, is that it's not possible to
update a branch in them which is currently checked out (to not make
HEAD different from the index and the work tree in a drastic way).
And Git produces a meaningful and lengthy error message when this
condition is hit by the sending side.

Moreover, the OP had proved the different environments
hypothesis by getting expected results when running each call to Git in
their hook wrapped in a call to `env -i`.

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.