git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] push: Use sideband channel for hook messages

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Feb 5, 2010, 11:58 UTC
Message-ID
<4B6C07E3.5030705@viscovery.net>
In-Reply-To
<20100205033748.GA19255@spearce.org>
Shawn O. Pearce schrieb:
> Rather than sending hook messages over stderr, and losing them
> entirely on git:// and smart HTTP transports,

I don't think "losing them entirely" is true for the git:// protocol: git-daemon writes receive-pack's stderr to the syslog.

The question is whether hook errors are intended for the remote side or for the repository owner. Generally, I'd say for the latter. But since your patch is about pushing, a repository owner must already trust the remote side, and then it can be argued that in this case errors can be sent to the remote.

Show 23 quoted lines
> diff --git a/run-command.c b/run-command.c
> index cf2d8f7..7d1fd88 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -94,6 +94,9 @@ fail_pipe:
>  		else if (need_err) {
>  			dup2(fderr[1], 2);
>  			close_pair(fderr);
> +		} else if (cmd->err > 1) {
> +			dup2(cmd->err, 2);
> +			close(cmd->err);
>  		}
>  
>  		if (cmd->no_stdout)
> @@ -228,6 +231,8 @@ fail_pipe:
>  
>  	if (need_err)
>  		close(fderr[1]);
> +	else if (cmd->err)
> +		close(cmd->err);
>  
>  	return 0;
>  }
This requires similar adjustments in the Windows part.
Documentation/technical/api-runcommand.txt should be an update, too.
Show 18 quoted lines
> @@ -326,10 +331,19 @@ static unsigned __stdcall run_thread(void *data)
>  int start_async(struct async *async)
>  {
>  	int pipe_out[2];
> +	int proc_fd, call_fd;
>  
>  	if (pipe(pipe_out) < 0)
>  		return error("cannot create pipe: %s", strerror(errno));
> -	async->out = pipe_out[0];
> +
> +	if (async->is_reader) {
> +		proc_fd = pipe_out[0];
> +		call_fd = pipe_out[1];
> +	} else {
> +		call_fd = pipe_out[0];
> +		proc_fd = pipe_out[1];
> +	}
> +	async->out = call_fd;

I don't particularly like this approach because it restricts the async procedures to a one-way communication.

What would you think about passing both channels to the async callback, and the communicating parties must agree on which channel they communicate by closing the unused one? It would require slight changes to all current async users, though. (It also requires in the threaded case that we pass dup()s of the pipe channels.)

-- Hannes
Previous: Junio C HamanoNext: Shawn O. Pearce
Message 3 of 8 in “push: Use sideband channel for hook messages”
  1. push: Use sideband channel for hook messagesShawn O. Pearce, Feb 5, 2010
  2. Junio C HamanoFeb 5, 2010
  3. Johannes SixtFeb 5, 2010
  4. Shawn O. PearceFeb 5, 2010
  5. Johannes SixtFeb 5, 2010
  6. Erik Faye-LundFeb 5, 2010
  7. Shawn O. PearceFeb 5, 2010
  8. Ilari LiusvaaraFeb 5, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.