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

Re: [PATCH] Prompt for a username when an HTTP request 401s

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 19, 2010, 19:27 UTC
Message-ID
<7vr5ngkt7x.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100319143205.GB16211@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 20 quoted lines
> Scott Chacon <schacon@gmail.com> wrote:
>> @@ -815,7 +815,18 @@ static int http_request(const char *url, void
>> *result, int target, int options)
>>  			ret = HTTP_OK;
>>  		else if (missing_target(&results))
>>  			ret = HTTP_MISSING_TARGET;
>> -		else
>> +		else if (results.http_code == 401) {
>> +			if (user_name) {
>> +				ret = HTTP_NOAUTH;
>> +			} else {
>> +				// it is neccesary to use getpass here because
>> +				// there appears to be no other clean way to
>> +				// read/write stdout/stdin
>> +				user_name = xstrdup(getpass("Username: "));
>
> No, getpass is needed here because its very likely stdin/stdout are
> pipes to our parent process.  So we instead need to use /dev/tty,
> but that is non-portable.  Using getpass() can at least be stubbed
> on other platforms with a different implementation if/when necessary.

In addition to the obligatory "no C++/C99 double-slash comments, please ", I think by the time this gets into an applicable shape, Frank's f206063 (git-core: Support retrieving passwords with GIT_ASKPASS, 2010-03-04) will have graduated to the 'master'. It would be a good idea to build this change on top of that one.

Previous: Shawn O. Pearce
Message 8 of 8 in “Prompt for a username when an HTTP request 401s”
  1. Prompt for a username when an HTTP request 401sScott Chacon, Mar 19, 2010
  2. Tay Ray ChuanMar 19, 2010
  3. Daniel StenbergMar 19, 2010
  4. Shawn O. PearceMar 19, 2010
  5. Shawn O. PearceMar 19, 2010
  6. Scott ChaconMar 19, 2010
  7. Shawn O. PearceMar 19, 2010
  8. Junio C HamanoMar 19, 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.