git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Firmin Martin <firminmartin24@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] prompt.h: clarify the non-use of git_prompt
Date: Sat, 15 May 2021 06:12:39 -0400	[thread overview]
Message-ID: <YJ+elwq2OkvSgvJc@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqv97m8dnw.fsf@gitster.g>

On Fri, May 14, 2021 at 07:36:03AM +0900, Junio C Hamano wrote:

> Firmin Martin <firminmartin24@gmail.com> writes:
> 
> > +/*
> > + * This function should not be used for regular prompts (i.e., asking user for
> > + * confirmation or picking an option from an interactive menu) as it only
> > + * accepts input from /dev/tty, thus making it impossible to test with the
> > + * current test suite.  Please instead use git_read_line_interactively for that
> > + * purpose.  See 97387c8bdd (am: read interactive input from stdin, 2019-05-20)
> > + * for historical context.
> > + *
> > + */
> 
> I have a strong objection against the above phrasing.
> 
> If we are asking user for interactive input, this SHOULD be used,
> especially if we might be reading the data to work on from the
> standard input and we may need to ask the user to interactively
> instruct us what to do to that data.  The only plausible reason that
> we may want to avoid it and instead prefer the (misnamed)
> read_line_interactively() to read whatever from the standard input
> (which may not be "interactive" at all, which is why I said
> "misnamed") is because our test framework does not use setsid (and
> setsid(1) may not be universally available) with pty to emulate tty
> input, isn't it?

I'm not sure I agree with your "should". Sometimes it's convenient to
access the controlling terminal directly, but sometimes it's convenient
to be able to drive the interaction of programs over stdin. Obviously
our tests are more interested in doing that than most users would be,
but it can still be handy (e.g., driving them from another non-terminal
program). Arguably nobody should be doing that as these are porcelains,
but I wouldn't be at all surprised if it happens (especially for
something like add--interactive).

In such a case, switching from stdin to /dev/tty may be considered a
regression (I know that the patches here are switching bisect away from
using the tty, but I think it is just reversing what happened with the
recent switch from git-bisect.sh to the builtin, though I think it
insisted on "test -t 0" in the old code, so the distinction may be
moot).

I dunno. I guess I don't feel all that strongly, but I just generally
find stdin more convenient than accessing the tty directly (because it's
easy to do "</dev/tty", but hard to set up a controlling terminal). But
I admit that I am a lot more likely to drive our programs via script for
testing or debugging than normal users would.

-Peff

  parent reply	other threads:[~2021-05-15 10:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-13 21:41 [PATCH 0/2] Refactor some prompts Firmin Martin
2021-05-13 21:41 ` [PATCH 1/2] prompt.h: clarify the non-use of git_prompt Firmin Martin
2021-05-13 22:36   ` Junio C Hamano
2021-05-13 23:03     ` Junio C Hamano
2021-05-15 10:12     ` Jeff King [this message]
2021-05-13 21:41 ` [PATCH 2/2] builtin: use git_read_line_interactively to prompt Firmin Martin
2021-05-13 22:51   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YJ+elwq2OkvSgvJc@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=firminmartin24@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).