# Weirdness with port-update hook and local push

5 messages from 2005-12-05 to 2005-12-06. Participants: Daniel Barkalow, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/2750

## Daniel Barkalow, 2005-12-05 20:36

Subject: Weirdness with port-update hook and local push
Message-ID: <Pine.LNX.4.64.0512051530560.25300@iabervon.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0512051530560.25300%40iabervon.org

```
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, 2005-12-05 20:40

Subject: Re: Weirdness with port-update hook and local push
Message-ID: <Pine.LNX.4.63.0512052138560.6554@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0512052138560.6554%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <Pine.LNX.4.64.0512051530560.25300@iabervon.org>

```
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*.)

Hth,
Dscho

```

## Daniel Barkalow, 2005-12-05 22:01

Subject: Re: Weirdness with port-update hook and local push
Message-ID: <Pine.LNX.4.64.0512051651050.25300@iabervon.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0512051651050.25300%40iabervon.org
In-Reply-To: <Pine.LNX.4.63.0512052138560.6554@wbgn013.biozentrum.uni-wuerzburg.de>

```
On Mon, 5 Dec 2005, Johannes Schindelin wrote:

> 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, 2005-12-05 22:11

Subject: Re: Weirdness with port-update hook and local push
Message-ID: <7vk6ej9otl.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vk6ej9otl.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.64.0512051651050.25300@iabervon.org>

```
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, 2005-12-06 01:12

Subject: Re: Weirdness with port-update hook and local push
Message-ID: <Pine.LNX.4.64.0512051945330.25300@iabervon.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0512051945330.25300%40iabervon.org
In-Reply-To: <Pine.LNX.4.63.0512052318290.3406@wbgn013.biozentrum.uni-wuerzburg.de>

```
On Mon, 5 Dec 2005, Johannes Schindelin wrote:

> 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*

```
