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

[PATCH 0/2] prompt.c: split up git_prompt(), read from /dev/tty, not STDIN

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 2, 2021, 16:48 UTC
Message-ID
<cover-0.2-00000000000-20211102T155046Z-avarab@gmail.com>
In-Reply-To
<20190524062724.GC25694@sigill.intra.peff.net>

I had a stupid bug in another series of mine[1] breaking code around git_prompt() in bisect--helper.c, and in trying to follow-up to add testing to that discovered that doing so was rather hard, due to how git_prompt() behaves.

In another case in 2019 (which is the In-Reply-To here) we added a seeming for-the-tests workaround for the same issue in "git am --interacive".

This starts out by splitting the more complex "get a password interactively" case out of prompt.c into a new prompt-password.c, most of prompt.c's complexity was to cater to one API user in credential.c.

That being done move these callers to using git_prompt(), and have it understanda a new GIT_TEST_TERMINAL_PROMPT=true variable so we can have our cake and it it too in the test suite. If that's set the prompt function will allow input on stdin.

This then allowed my to add the missing test for "git bisect" for the code I'd accidentally broken in [1].

As noted in the discussion in 2/2 I'm not 100% sure this is the right direction in terms of swiching us back to using /dev/tty and not stdin, but see that commit & commit message for details. In any case, whatever behavior we go for as far as the UX goes shouldn't be catering only to the test suite at the cost of trade-offs elsewhere.

1. https://lore.kernel.org/git/cover-v6-0.8-00000000000-20211102T122507Z-avarab@gmail.com/
Ævar Arnfjörð Bjarmason (2):
  prompt.c: split up the password and non-password handling
  prompt.c: add and use a GIT_TEST_TERMINAL_PROMPT=true
 Makefile                    |  1 +
 builtin/am.c                |  8 ++--
 builtin/bisect--helper.c    |  8 +---
 credential.c                | 17 ++++----
 help.c                      |  2 +-
 prompt-password.c           | 63 +++++++++++++++++++++++++++++
 prompt-password.h           |  7 ++++
 prompt.c                    | 79 ++++++++-----------------------------
 prompt.h                    |  7 +---
 t/t6030-bisect-porcelain.sh | 41 +++++++++++++++++++
 t/test-lib.sh               |  4 ++
 11 files changed, 151 insertions(+), 86 deletions(-)
 create mode 100644 prompt-password.c
 create mode 100644 prompt-password.h
-- 
2.33.1.1570.g069344fdd45
Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 10 of 30 in “Abort (core dumped)”
  1. Alejandro SanchezMay 20, 2019
  2. Jeff KingMay 20, 2019
  3. 0/4 fix BUG() with "git am -i --resolved"Jeff King, May 20, 2019
  4. 1/4 am: simplify prompt response handlingJeff King, May 20, 2019
  5. 2/4 am: read interactive input from stdinJeff King, May 20, 2019
  6. 3/4 am: drop tty requirement for --interactiveJeff King, May 20, 2019
  7. Jeff KingMay 20, 2019
  8. Johannes SchindelinMay 23, 2019
  9. Jeff KingMay 24, 2019
  10. 0/2 prompt.c: split up git_prompt(), read from /dev/tty, not STDINÆvar Arnfjörð Bjarmason, Nov 2, 2021
  11. 1/2 prompt.c: split up the password and non-password handlingÆvar Arnfjörð Bjarmason, Nov 2, 2021
  12. Jeff KingNov 3, 2021
  13. Junio C HamanoNov 3, 2021
  14. 2/2 prompt.c: add and use a GIT_TEST_TERMINAL_PROMPT=trueÆvar Arnfjörð Bjarmason, Nov 2, 2021
  15. Jeff KingNov 3, 2021
  16. Ævar Arnfjörð BjarmasonNov 3, 2021
  17. Jeff KingNov 4, 2021
  18. Junio C HamanoNov 3, 2021
  19. Johannes SchindelinNov 4, 2021
  20. Jeff KingNov 4, 2021
  21. Jeff KingNov 4, 2021
  22. 4/4 am: fix --interactive HEAD tree resolutionJeff King, May 20, 2019
  23. Johannes SchindelinMay 23, 2019
  24. Jeff KingMay 24, 2019
  25. 4/4 am: fix --interactive HEAD tree resolutionJeff King, May 24, 2019
  26. Johannes SchindelinMay 28, 2019
  27. Jeff KingMay 28, 2019
  28. Johannes SchindelinMay 29, 2019
  29. Alejandro SanchezSep 26, 2019
  30. Jeff KingSep 26, 2019

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.