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

Re: [PATCH v3 2/3] git-core: Support retrieving passwords with GIT_ASKPASS

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Mar 2, 2010, 12:17 UTC
Message-ID
<4B8D01D2.9060406@viscovery.net>
In-Reply-To
<1267530657-4848-1-git-send-email-lznuaa@gmail.com>
Frank Li schrieb:
> +	memset(&pass, 0, sizeof(pass));
> +	pass.argv = args;
> +	pass.out = -1;
> +	pass.use_shell = 1;

I thought that the conclusion was to follow how openssh treats SSH_ASKPASS, and it *does not* treat it as a command with arguments. Do not set use_shell.

> +	if (start_command(&pass)) {
> +		error("could not run %s\n", askpass);
As I said, this error message is redundant. No big deal, though.
Show 6 quoted lines
> +		exit(1);
> +	}
> +
> +	strbuf_read(&buffer, pass.out, 20);
> +	close(pass.out);
> +	finish_command(&pass);
You must check for errors here as well. No error message is needed, either.
Show 6 quoted lines
> +
> +	for (i = 0; i < buffer.len; i++)
> +		if (buffer.buf[i] == '\n' || buffer.buf[i] == '\r') {
> +			buffer.buf[i] = '\0';
> +			buffer.len = i;
> +		}
I think you can shorten this loop to
	strbuf_setlen(&buffer, strcspn(buffer.buf, "\r\n"));
-- Hannes
Previous: Frank Li
Message 2 of 2 in “git-core: Support retrieving passwords with GIT_ASKPASS”
  1. 2/3 git-core: Support retrieving passwords with GIT_ASKPASSFrank Li, Mar 2, 2010
  2. Johannes SixtMar 2, 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.