threads / discuss / 2750

Weirdness with port-update hook and local push

Subject: Weirdness with port-update hook and local push

## tl;dr

5 messages between Dec 5, 2005 and Dec 6, 2005.

replies: 4people: 3as markdown or json

Daniel Barkalow· Dec 5, 2005, 20:36 UTC · lore
I have the following post-update hook:

----- #!/bin/sh

unset GIT_DIR
cd /home/barkalow/auto-working/web
if ! git pull /home/barkalow/git/web.git/
then
  exit 1  
fi
make
-----
>From that "git pull", I'm getting:
/home/barkalow/bin/git-pull: line 108: 30608 Broken pipe      git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head

It works fine when pushing over ssh, and when I just run the hook directly. (It does a fast forward merge without any trouble.) Any ideas on what's confusing it?

	-Daniel
*This .sig left intentionally blank*
Johannes Schindelin· Dec 5, 2005, 20:40 UTC · re: Daniel Barkalow · lore

Re: Weirdness with port-update hook and local push

Hi,
On Mon, 5 Dec 2005, Daniel Barkalow wrote:
Show 19 quoted lines
> I have the following post-update hook:
> 
> -----
> #!/bin/sh
> 
> unset GIT_DIR
> cd /home/barkalow/auto-working/web
> if ! git pull /home/barkalow/git/web.git/
> then
>   exit 1  
> fi
> make
> -----
> 
> >From that "git pull", I'm getting:
> 
> /home/barkalow/bin/git-pull: line 108: 30608 Broken pipe      git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head
> 
> It works fine when pushing over ssh,

Maybe it runs as a different user? (Sorry if this sounds dumb, but that's exactly the kind of solution I usually find after *days*.)

Hth, Dscho

Daniel Barkalow· Dec 5, 2005, 22:01 UTC · re: Johannes Schindelin · lore

Re: Weirdness with port-update hook and local push

On Mon, 5 Dec 2005, Johannes Schindelin wrote:
Show 26 quoted lines
> Hi,
> 
> On Mon, 5 Dec 2005, Daniel Barkalow wrote:
> 
> > I have the following post-update hook:
> > 
> > -----
> > #!/bin/sh
> > 
> > unset GIT_DIR
> > cd /home/barkalow/auto-working/web
> > if ! git pull /home/barkalow/git/web.git/
> > then
> >   exit 1  
> > fi
> > make
> > -----
> > 
> > >From that "git pull", I'm getting:
> > 
> > /home/barkalow/bin/git-pull: line 108: 30608 Broken pipe      git-merge $no_summary $no_commit $strategy_args "$merge_name" HEAD $merge_head
> > 
> > It works fine when pushing over ssh,
> 
> Maybe it runs as a different user? (Sorry if this sounds dumb, but that's 
> exactly the kind of solution I usually find after *days*.)

I think it's an environment thing of some sort, most likely, but it can't be the user; nothing's setuid and I'm only one user.

The thing that confuses me is that it works when run from ssh or directly, but not when run from a local push. I'd expect the two that work to be most different.

	-Daniel
*This .sig left intentionally blank*
Junio C Hamano· Dec 5, 2005, 22:11 UTC · re: Daniel Barkalow · lore

Re: Weirdness with port-update hook and local push

Daniel Barkalow <barkalow@iabervon.org> writes:
> The thing that confuses me is that it works when run from ssh or directly, 
> but not when run from a local push. I'd expect the two that work to be 
> most different.

One suspicion and one suggestion (without knowing exactly where that suggestion might lead us to).

 - your stdout/stderr might be connected to somewhere that your
   output gets stuck ("broken pipe"), when your script is run
   from the hook.
 - your environment might be different from what you are
   assuming.
How about doing something like this?
	  #!/bin/sh
	+ exec >/var/tmp/hook-out.$$ 2>/var/tmp/hook-err.$$
	+ echo "** env **"
	+ env
	+ echo "** vars **"
	+ i=0
	+ for v
	+ do
	+	 echo "$i: $v"
	+	 i=$(($i+1))
	+ done
	+ echo "** pwd etc **"
	+ pwd
	+ id -a
	  unset GIT_DIR
	  cd /home/barkalow/auto-working/web
	  if ! git pull /home/barkalow/git/web.git/
and then next replace the whole thing with:
	exec >/dev/null 2>&1
        
Daniel Barkalow· Dec 6, 2005, 01:12 UTC · lore

Re: Weirdness with port-update hook and local push

On Mon, 5 Dec 2005, Johannes Schindelin wrote:
Show 9 quoted lines
> Hi,
> 
> On Mon, 5 Dec 2005, Daniel Barkalow wrote:
> 
> > I think it's an environment thing of some sort, most likely, but it can't 
> > be the user; nothing's setuid and I'm only one user.
> 
> Can you insert "env > /tmp/env.$$.out", execute both without and with ssh, 
> and compare?

Actually, "ls -l /proc/$$/fd" shows that stdin and stdout are sockets with ssh, pipes with local, and ttys when just running the script.

The hooks probably ought to be run with something different for stdin/stdout than the connection to the source of the data. /dev/null, maybe? Or a log file? Maybe dup stderr, which still seems to be going to the pusher's terminal?

	-Daniel
*This .sig left intentionally blank*

← back to recent threads