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

Re: git_getpass regression?

From
Jeff King <peff@peff.net>
Date
Jun 29, 2012, 17:39 UTC
Message-ID
<20120629173954.GA3804@sigill.intra.peff.net>
In-Reply-To
<CABPQNSa4uvgijjGCSJDXDMqHC3UkqQKKujG3xDFqnQ13LNrKdQ@mail.gmail.com>
On Fri, Jun 29, 2012 at 12:06:31PM +0200, Erik Faye-Lund wrote:
Show 10 quoted lines
> Since 9b4b894 ("Makefile: linux has /dev/tty", 2011-12-10) we're
> reading input from the terminal using strbuf_getline instead of
> getpass. But at least on my linux-box, getpass treats the
> backspace-key ('\b') as an actual deletion. strbuf_getline obviously
> shouldn't do this, as it's a utility function. But I think as a
> user-interface feature, it would be much more pleasant to be allowed
> to edit the entered text ;)
> 
> I can't find anything in POSIX that standardize this behavior, but for
> most text-input use-cases it's probably what the user intended.

Backspace shouldn't be making it to git at all; it should be handled at the terminal input layer, because we are not putting the terminal into raw mode. It works just fine for me here, both on the linux console and in an xterm. What terminal are you using? Are you ssh-ing to a remote linux box? If that is the case, I wonder if your 'stty erase' settings do not match what your terminal emulator is sending.

If you run "stty erase ^H" and then run git, does it work?
Show 5 quoted lines
> I think we have multiple possible solutions:
>  1) Read a character at the time, and special-case '\r' to erase the
> previously entered character.
>  2) Post-process the strbuf to explicitly perform the erasing.
>  3) Do nothing.

I assume you meant '\b' in (1). I think (3) is the only sane thing, though. Even if we handled \b, that is not what all terminals generate. In particular, most linux terminal emulators these days will generate DEL (aka ^? or 0x7f) on backspace. This problem needs to be solved at the terminal layer, and I suspect is just a configuration issue in your setup.

-Peff
Previous: Erik Faye-LundNext: Jeff King
Message 2 of 10 in “git_getpass regression?”
  1. Erik Faye-LundJun 29, 2012
  2. Jeff KingJun 29, 2012
  3. Jeff KingJun 29, 2012
  4. Erik Faye-LundJun 30, 2012
  5. Jeff KingJun 30, 2012
  6. Erik Faye-LundJul 3, 2012
  7. Jeff KingJul 3, 2012
  8. Erik Faye-LundJul 3, 2012
  9. Junio C HamanoJul 18, 2012
  10. Erik Faye-LundJul 18, 2012

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.