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
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 18, 2010, 19:03 UTC
Message-ID
<20100318190309.GC10981@spearce.org>
In-Reply-To
<d411cc4a1003181157o79f1a1e1qcdea05322d76b812@mail.gmail.com>
Scott Chacon <schacon@gmail.com> wrote:
Show 27 quoted lines
> When an HTTP request returns a 401, Git will currently fail with a
> confusing message saying that it got a 401.  This changes
> http_request to prompt for the username and password, then return
> HTTP_REAUTH so http_get_strbuf can try again.  If it gets a 401 even
> when a user/pass is supplied, http_request will now return HTTP_NOAUTH
> which remote_curl can then use to display a more intelligent error
> message that is less confusing.
> 
> Signed-off-by: Scott Chacon <schacon@gmail.com>
> ---
>  http.c        |   21 +++++++++++++++++++--
>  http.h        |    2 ++
>  remote-curl.c |    2 ++
>  3 files changed, 23 insertions(+), 2 deletions(-)
> 
> diff --git a/http.c b/http.c
> index deab595..731783e 100644
> --- a/http.c
> +++ b/http.c
> @@ -199,6 +199,11 @@ static int http_options(const char *var, const
> char *value, void *cb)
>  	return git_default_config(var, value, cb);
>  }
> 
> +static void get_http_user_name()
> +{
> +	user_name = xstrdup(getpass("Username: "));

Why are we getting the username via a password prompt where echo has been disabled? Traditionally a username field is obtained as echoed input.

Also, this method shouldn't be named get_*() if its returning void. Sounds far to funny. init_http_user_name()? prompt_for_user_name()?

-- 
Shawn.
Previous: Scott ChaconNext: René Scharfe
Message 2 of 3 in “Prompt for a username when an HTTP request 401s”
  1. Prompt for a username when an HTTP request 401sScott Chacon, Mar 18, 2010
  2. Shawn O. PearceMar 18, 2010
  3. René ScharfeMar 18, 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.