git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: lars.schneider@autodesk.com
Cc: git@vger.kernel.org, gitster@pobox.com, sbeller@google.com,
	sunshine@sunshineco.com, kaartic.sivaraam@gmail.com,
	sandals@crustytoothpaste.net,
	Lars Schneider <larsxschneider@gmail.com>
Subject: Re: [PATCH v4 2/2] launch_editor(): indicate that Git waits for user input
Date: Thu, 30 Nov 2017 15:51:37 -0500	[thread overview]
Message-ID: <20171130205137.GC3313@sigill.intra.peff.net> (raw)
In-Reply-To: <20171129143752.60553-3-lars.schneider@autodesk.com>

On Wed, Nov 29, 2017 at 03:37:52PM +0100, lars.schneider@autodesk.com wrote:

> No message is printed in a "dumb" terminal as it would not be possible
> to remove the message after the editor returns. This should not be a
> problem as this feature is targeted at novice Git users and they are
> unlikely to work with a "dumb" terminal.

I think novice users could end up in this situation with something like:

  ssh remote_host git commit

But then I'd expect most terminal-based editors to give some sort of
error in that situation, too. And at any rate, the worst case is that
they get no special "waiting..." message from Git, which is already the
status quo.  So it's probably not worth worrying about such an obscure
case.

> Power users might not want to see this message or their editor might
> already print such a message (e.g. emacsclient). Allow these users to
> suppress the message by disabling the "advice.waitingForEditor" config.

I'm happy to see the hard-coded emacsclient behavior go. Hopefully we
won't see too many complaints about people having to set the advice
flag.

> The standard advise() function is not used here as it would always add
> a newline which would make deleting the message harder.

I tried to think of ways this "show a message and then delete it" could
go wrong. It should work OK with editors that just do curses-like
things, taking over the terminal and then restoring it at the end.

It does behave in a funny way if the editor produces actual lines of
output outside of the curses handling. E.g. (I just quit vim
immediately, hence the aborting message):

  $ GIT_EDITOR='echo foo; vim' git commit
  hint: Waiting for your editor input...foo
  Aborting commit due to empty commit message.

our "foo" gets tacked onto the hint line, and then our deletion does
nothing (because the newline after "foo" bumped us to a new line, and
there was nothing on that line to erase).

An even worse case (and yes, this is really reaching) is:

  $ GIT_EDITOR='echo one; printf "two\\r"; vim' git commit
  hint: Waiting for your editor input...one
  Aborting commit due to empty commit message.

There we ate the "two" line.

These are obviously the result of devils-advocate poking at the feature.
I doubt any editor would end its output with a CR. But the first case is
probably going to be common, especially for actual graphical editors. We
know that emacsclient prints its own line, and I wouldn't be surprised
if other graphical editors spew some telemetry to stderr (certainly
anything built against GTK tends to do so).

I don't think there's a good way around it. Portably saying "delete
_this_ line that I wrote earlier" would probably require libcurses or
similar. So maybe we just live with it. The deletion magic makes the
common cases better (a terminal editor that doesn't print random
lines, or a graphical editor that is quiet), and everyone else can flip
the advice switch if they need to. I dunno.

> ---
>  Documentation/config.txt |  3 +++
>  advice.c                 |  2 ++
>  advice.h                 |  1 +
>  editor.c                 | 15 +++++++++++++++
>  4 files changed, 21 insertions(+)

The patch itself looks fine, as far as correctly implementing the
design.

-Peff

  reply	other threads:[~2017-11-30 20:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 14:37 [PATCH v4 0/2] launch_editor(): indicate that Git waits for user input lars.schneider
2017-11-29 14:37 ` [PATCH v4 1/2] refactor "dumb" terminal determination lars.schneider
2017-11-30 20:30   ` Jeff King
2017-12-01  3:26   ` Kaartic Sivaraam
2017-11-29 14:37 ` [PATCH v4 2/2] launch_editor(): indicate that Git waits for user input lars.schneider
2017-11-30 20:51   ` Jeff King [this message]
2017-12-01  3:56     ` Kaartic Sivaraam
2017-12-01 12:52     ` Lars Schneider
2017-12-01 18:29       ` Jeff King
2017-12-02  3:45         ` Kaartic Sivaraam
2017-12-03 16:39           ` Lars Schneider
2017-12-04 16:41             ` Kaartic Sivaraam
2017-12-04 17:26             ` Jeff King
2017-12-04 21:31               ` Lars Schneider
2017-12-04 21:42                 ` Jeff King
2017-12-04 21:54                   ` Lars Schneider
2017-12-04 22:09                     ` Jeff King
2017-12-04 17:25           ` Jeff King
2017-12-03  5:15     ` Junio C Hamano
2017-12-03 12:47       ` Lars Schneider
2017-12-04 17:32         ` Jeff King
2017-12-04 21:34           ` Lars Schneider
2017-12-04 21:40           ` Junio C Hamano
2017-12-04 17:30       ` Jeff King
2017-11-29 18:35 ` [PATCH v4 0/2] " Thomas Adam
2017-11-30 13:55   ` Lars Schneider
2017-11-30 14:42     ` Thomas Adam
2017-11-30 15:13       ` Andreas Schwab
2017-12-01  3:41         ` Kaartic Sivaraam
2017-11-30 20:12   ` Jeff King
2017-11-30 20:51     ` Thomas Adam

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=20171130205137.GC3313@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=lars.schneider@autodesk.com \
    --cc=larsxschneider@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.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).