* [PATCH v3 1/2] launch_editor: waiting for editor message
2024-04-12 17:05 ` [PATCH v3 0/2] launch_editor: waiting message Rubén Justo
@ 2024-04-12 17:15 ` Rubén Justo
2024-04-12 17:24 ` rsbecker
2024-04-12 17:15 ` [PATCH v3 2/2] launch_editor: waiting message on error Rubén Justo
2024-04-14 7:39 ` [PATCH v4] " Rubén Justo
2 siblings, 1 reply; 26+ messages in thread
From: Rubén Justo @ 2024-04-12 17:15 UTC (permalink / raw)
To: Git List, Junio C Hamano
We have a hint shown when we are waiting for user's editor since
abfb04d0c7 (launch_editor(): indicate that Git waits for user input,
2017-12-07).
After showing the hint, we call start_command() which can return with an
error. Then we'll show "unable to start editor...", after having said
"Waiting for your editor...", which may be confusing.
Move the code to show the hint below the start_command().
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
editor.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/editor.c b/editor.c
index b67b802ddf..1da3a26f5d 100644
--- a/editor.c
+++ b/editor.c
@@ -64,9 +64,21 @@ static int launch_specified_editor(const char *editor, const char *path,
if (strcmp(editor, ":")) {
struct strbuf realpath = STRBUF_INIT;
struct child_process p = CHILD_PROCESS_INIT;
- int ret, sig;
- int print_waiting_for_editor = advice_enabled(ADVICE_WAITING_FOR_EDITOR) && isatty(2);
+ int ret, sig, print_waiting_for_editor;
+ strbuf_realpath(&realpath, path, 1);
+
+ strvec_pushl(&p.args, editor, realpath.buf, NULL);
+ if (env)
+ strvec_pushv(&p.env, (const char **)env);
+ p.use_shell = 1;
+ p.trace2_child_class = "editor";
+ if (start_command(&p) < 0) {
+ strbuf_release(&realpath);
+ return error("unable to start editor '%s'", editor);
+ }
+
+ print_waiting_for_editor = advice_enabled(ADVICE_WAITING_FOR_EDITOR) && isatty(2);
if (print_waiting_for_editor) {
/*
* A dumb terminal cannot erase the line later on. Add a
@@ -83,18 +95,6 @@ static int launch_specified_editor(const char *editor, const char *path,
fflush(stderr);
}
- strbuf_realpath(&realpath, path, 1);
-
- strvec_pushl(&p.args, editor, realpath.buf, NULL);
- if (env)
- strvec_pushv(&p.env, (const char **)env);
- p.use_shell = 1;
- p.trace2_child_class = "editor";
- if (start_command(&p) < 0) {
- strbuf_release(&realpath);
- return error("unable to start editor '%s'", editor);
- }
-
sigchain_push(SIGINT, SIG_IGN);
sigchain_push(SIGQUIT, SIG_IGN);
ret = finish_command(&p);
--
2.44.0.771.gbd07cf668b
^ permalink raw reply related [flat|nested] 26+ messages in thread* RE: [PATCH v3 1/2] launch_editor: waiting for editor message
2024-04-12 17:15 ` [PATCH v3 1/2] launch_editor: waiting for editor message Rubén Justo
@ 2024-04-12 17:24 ` rsbecker
2024-04-12 17:37 ` Rubén Justo
2024-04-13 15:06 ` Phillip Wood
0 siblings, 2 replies; 26+ messages in thread
From: rsbecker @ 2024-04-12 17:24 UTC (permalink / raw)
To: 'Rubén Justo', 'Git List',
'Junio C Hamano'
On Friday, April 12, 2024 1:15 PM, Rubén Justo wrote:
>Subject: [PATCH v3 1/2] launch_editor: waiting for editor message
>
>We have a hint shown when we are waiting for user's editor since
>abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07).
>
>After showing the hint, we call start_command() which can return with an error.
>Then we'll show "unable to start editor...", after having said "Waiting for your
>editor...", which may be confusing.
>
>Move the code to show the hint below the start_command().
My thought on this move is for esoteric (but commonly used) terminal emulators. If one is on a t6530, tn3270, or w3270/9 emulator, for example, the emulator switches modes from text on the POSIX side to block/full screen mode when the editor is launched. Printing a message after the editor has launched has the potential to dump the message into the terminal emulation buffer and get caught in the commit text comment. This is not desirable. This change could have seriously undesirable side-effects.
On the other side, if the message is not displayed in the emulation buffer, it is deferred until after the editor closes, which makes the message a bit pointless.
--Randall
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v3 1/2] launch_editor: waiting for editor message
2024-04-12 17:24 ` rsbecker
@ 2024-04-12 17:37 ` Rubén Justo
2024-04-12 17:47 ` rsbecker
2024-04-13 15:06 ` Phillip Wood
1 sibling, 1 reply; 26+ messages in thread
From: Rubén Justo @ 2024-04-12 17:37 UTC (permalink / raw)
To: rsbecker, 'Git List', 'Junio C Hamano'
On Fri, Apr 12, 2024 at 01:24:55PM -0400, rsbecker@nexbridge.com wrote:
> On Friday, April 12, 2024 1:15 PM, Rubén Justo wrote:
> >Subject: [PATCH v3 1/2] launch_editor: waiting for editor message
> >
> >We have a hint shown when we are waiting for user's editor since
> >abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07).
> >
> >After showing the hint, we call start_command() which can return with an error.
> >Then we'll show "unable to start editor...", after having said "Waiting for your
> >editor...", which may be confusing.
> >
> >Move the code to show the hint below the start_command().
>
> My thought on this move is for esoteric (but commonly used) terminal
> emulators. If one is on a t6530, tn3270, or w3270/9 emulator, for
> example, the emulator switches modes from text on the POSIX side to
> block/full screen mode when the editor is launched. Printing a message
> after the editor has launched has the potential to dump the message
> into the terminal emulation buffer and get caught in the commit text
> comment. This is not desirable. This change could have seriously
> undesirable side-effects.
That's a good point. Thanks for bringing it up.
Of course, in such a situation the user has the opportunity to disable
the hint.
However, can you think of a way in which we could do this, not showing
the "Waiting..." before the "unable to start", better?
Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread
* RE: [PATCH v3 1/2] launch_editor: waiting for editor message
2024-04-12 17:37 ` Rubén Justo
@ 2024-04-12 17:47 ` rsbecker
0 siblings, 0 replies; 26+ messages in thread
From: rsbecker @ 2024-04-12 17:47 UTC (permalink / raw)
To: 'Rubén Justo', 'Git List',
'Junio C Hamano'
On Friday, April 12, 2024 1:37 PM, Rubén Justo wrote:
>On Fri, Apr 12, 2024 at 01:24:55PM -0400, rsbecker@nexbridge.com wrote:
>> On Friday, April 12, 2024 1:15 PM, Rubén Justo wrote:
>> >Subject: [PATCH v3 1/2] launch_editor: waiting for editor message
>> >
>> >We have a hint shown when we are waiting for user's editor since
>> >abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07).
>> >
>> >After showing the hint, we call start_command() which can return with an error.
>> >Then we'll show "unable to start editor...", after having said
>> >"Waiting for your editor...", which may be confusing.
>> >
>> >Move the code to show the hint below the start_command().
>>
>> My thought on this move is for esoteric (but commonly used) terminal
>> emulators. If one is on a t6530, tn3270, or w3270/9 emulator, for
>> example, the emulator switches modes from text on the POSIX side to
>> block/full screen mode when the editor is launched. Printing a message
>> after the editor has launched has the potential to dump the message
>> into the terminal emulation buffer and get caught in the commit text
>> comment. This is not desirable. This change could have seriously
>> undesirable side-effects.
>
>That's a good point. Thanks for bringing it up.
>
>Of course, in such a situation the user has the opportunity to disable the hint.
>
>However, can you think of a way in which we could do this, not showing the
>"Waiting..." before the "unable to start", better?
I do not have a good solution. One thought was to run the Waiting message in a separate thread, but that is dangerous. Terminal I/O APIs are generally not thread aware and random results are frequent when writing from two threads, particularly in different processes. Polluting stdout is never a good idea, and in this case the encoding and terminal type could also change between git and editor, even in Linux. The only potential way to do this is with an editor aware mutex (there isn't a portable on) that would block the editor, poll the terminal state, change to UTF-8 or US-ASCII or... and write the Waiting message, switch back, then release the mutex.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v3 1/2] launch_editor: waiting for editor message
2024-04-12 17:24 ` rsbecker
2024-04-12 17:37 ` Rubén Justo
@ 2024-04-13 15:06 ` Phillip Wood
1 sibling, 0 replies; 26+ messages in thread
From: Phillip Wood @ 2024-04-13 15:06 UTC (permalink / raw)
To: rsbecker, 'Rubén Justo', 'Git List',
'Junio C Hamano'
On 12/04/2024 18:24, rsbecker@nexbridge.com wrote:
> On Friday, April 12, 2024 1:15 PM, Rubén Justo wrote:
>> Subject: [PATCH v3 1/2] launch_editor: waiting for editor message
>>
>> We have a hint shown when we are waiting for user's editor since
>> abfb04d0c7 (launch_editor(): indicate that Git waits for user input, 2017-12-07).
>>
>> After showing the hint, we call start_command() which can return with an error.
>> Then we'll show "unable to start editor...", after having said "Waiting for your
>> editor...", which may be confusing.
>>
>> Move the code to show the hint below the start_command().
>
> My thought on this move is for esoteric (but commonly used) terminal emulators. If one is on a t6530, tn3270, or w3270/9 emulator, for example, the emulator switches modes from text on the POSIX side to block/full screen mode when the editor is launched. Printing a message after the editor has launched has the potential to dump the message into the terminal emulation buffer and get caught in the commit text comment. This is not desirable. This change could have seriously undesirable side-effects.
Writing to the terminal after starting the editor is a bad idea for the
reason you describe regardless of the terminal type. I don't think there
is a sensible way to avoid showing the hint before we know whether the
editor started successfully or not.
> On the other side, if the message is not displayed in the emulation buffer, it is deferred until after the editor closes, which makes the message a bit pointless.
I think the message is there for gui editors, with a terminal editor it
is obvious that git has started the editor and the user doesn't really
see the message because it is cleared when the editor exits successfully.
Best Wishes
Phillip
> --Randall
>
>
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v3 2/2] launch_editor: waiting message on error
2024-04-12 17:05 ` [PATCH v3 0/2] launch_editor: waiting message Rubén Justo
2024-04-12 17:15 ` [PATCH v3 1/2] launch_editor: waiting for editor message Rubén Justo
@ 2024-04-12 17:15 ` Rubén Justo
2024-04-13 15:09 ` Phillip Wood
2024-04-14 7:39 ` [PATCH v4] " Rubén Justo
2 siblings, 1 reply; 26+ messages in thread
From: Rubén Justo @ 2024-04-12 17:15 UTC (permalink / raw)
To: Git List, Junio C Hamano
When advice.waitingForEditor configuration is not set to false, we show
a hint telling that we are waiting for user's editor to close the file
when we launch an editor and wait for it to return control back to us.
We give the message on an incomplete line, expecting that we can go back
to the line and clear the message when the editor returns successfully.
However, it is possible that the editor exits with an error status, in
which case we show an error message and then return to our caller. In
such a case, the error message is given where the terminal cursor
happens to be, which is most likely after the "we are waiting for your
editor" message on the same line.
Only clear the line when the editor returned cleanly, and otherwise,
complete the message on the incomplete line with a newline before giving
the error message.
While we're here, make the error message follow our CodingGuideLines.
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
editor.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
diff --git a/editor.c b/editor.c
index 1da3a26f5d..eb0cfe4a28 100644
--- a/editor.c
+++ b/editor.c
@@ -104,16 +104,26 @@ static int launch_specified_editor(const char *editor, const char *path,
sigchain_pop(SIGQUIT);
if (sig == SIGINT || sig == SIGQUIT)
raise(sig);
+
+ if (print_waiting_for_editor && !is_terminal_dumb()) {
+ if (!ret)
+ /*
+ * Erase the entire line to avoid wasting
+ * the vertical space.
+ */
+ term_clear_line();
+ else
+ /*
+ * We don't want term_clear_line() here
+ * because the editor could have written
+ * some useful messages to the user.
+ */
+ fprintf(stderr, "\n");
+ }
+
if (ret)
- return error("There was a problem with the editor '%s'.",
+ return error("there was a problem with the editor '%s'",
editor);
-
- if (print_waiting_for_editor && !is_terminal_dumb())
- /*
- * Erase the entire line to avoid wasting the
- * vertical space.
- */
- term_clear_line();
}
if (!buffer)
--
2.44.0.771.gbd07cf668b
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v3 2/2] launch_editor: waiting message on error
2024-04-12 17:15 ` [PATCH v3 2/2] launch_editor: waiting message on error Rubén Justo
@ 2024-04-13 15:09 ` Phillip Wood
2024-04-14 7:23 ` Rubén Justo
0 siblings, 1 reply; 26+ messages in thread
From: Phillip Wood @ 2024-04-13 15:09 UTC (permalink / raw)
To: Rubén Justo, Git List, Junio C Hamano
Hi Rubén
On 12/04/2024 18:15, Rubén Justo wrote:
> When advice.waitingForEditor configuration is not set to false, we show
> a hint telling that we are waiting for user's editor to close the file
> when we launch an editor and wait for it to return control back to us.
> We give the message on an incomplete line, expecting that we can go back
> to the line and clear the message when the editor returns successfully.
>
> However, it is possible that the editor exits with an error status, in
> which case we show an error message and then return to our caller. In
> such a case, the error message is given where the terminal cursor
> happens to be, which is most likely after the "we are waiting for your
> editor" message on the same line.
I think it is very likely that the editor has printed an error message
if it exits with a non-zero exit code and if that message does not end
with a newline that is a bug in the editor. Do you have a real-world
example of the problem you are seeking to fix?
Best Wishes
Phillip
> Only clear the line when the editor returned cleanly, and otherwise,
> complete the message on the incomplete line with a newline before giving
> the error message.
>
> While we're here, make the error message follow our CodingGuideLines.
>
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
> editor.c | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/editor.c b/editor.c
> index 1da3a26f5d..eb0cfe4a28 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -104,16 +104,26 @@ static int launch_specified_editor(const char *editor, const char *path,
> sigchain_pop(SIGQUIT);
> if (sig == SIGINT || sig == SIGQUIT)
> raise(sig);
> +
> + if (print_waiting_for_editor && !is_terminal_dumb()) {
> + if (!ret)
> + /*
> + * Erase the entire line to avoid wasting
> + * the vertical space.
> + */
> + term_clear_line();
> + else
> + /*
> + * We don't want term_clear_line() here
> + * because the editor could have written
> + * some useful messages to the user.
> + */
> + fprintf(stderr, "\n");
> + }
> +
> if (ret)
> - return error("There was a problem with the editor '%s'.",
> + return error("there was a problem with the editor '%s'",
> editor);
> -
> - if (print_waiting_for_editor && !is_terminal_dumb())
> - /*
> - * Erase the entire line to avoid wasting the
> - * vertical space.
> - */
> - term_clear_line();
> }
>
> if (!buffer)
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v3 2/2] launch_editor: waiting message on error
2024-04-13 15:09 ` Phillip Wood
@ 2024-04-14 7:23 ` Rubén Justo
0 siblings, 0 replies; 26+ messages in thread
From: Rubén Justo @ 2024-04-14 7:23 UTC (permalink / raw)
To: phillip.wood, Git List, Junio C Hamano; +Cc: rsbecker
On Sat, Apr 13, 2024 at 04:09:27PM +0100, Phillip Wood wrote:
> I think it is very likely that the editor has printed an error message if it
> exits with a non-zero exit code and if that message does not end with a
> newline that is a bug in the editor. Do you have a real-world example of the
> problem you are seeking to fix?
Perhaps I am being too cautious. I'll follow Junio's suggestion and use
term_clear_line() in all cases.
Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH v4] launch_editor: waiting message on error
2024-04-12 17:05 ` [PATCH v3 0/2] launch_editor: waiting message Rubén Justo
2024-04-12 17:15 ` [PATCH v3 1/2] launch_editor: waiting for editor message Rubén Justo
2024-04-12 17:15 ` [PATCH v3 2/2] launch_editor: waiting message on error Rubén Justo
@ 2024-04-14 7:39 ` Rubén Justo
2024-04-15 14:05 ` Phillip Wood
2024-04-15 17:07 ` Rubén Justo
2 siblings, 2 replies; 26+ messages in thread
From: Rubén Justo @ 2024-04-14 7:39 UTC (permalink / raw)
To: Git List, Junio C Hamano; +Cc: rsbecker, Phillip Wood
When advice.waitingForEditor configuration is not set to false, we show
a hint telling that we are waiting for user's editor to close the file
when we launch an editor and wait for it to return control back to us.
We give the message on an incomplete line, expecting that we can go back
to the line and clear the message when the editor returns.
However, it is possible that the editor exits with an error status, in
which case we show an error message and then return to our caller. In
such a case, the error message is given where the terminal cursor
happens to be, which is most likely after the "we are waiting for your
editor" message on the same line.
Clear the line before showing the error.
While we're here, make the error message follow our CodingGuideLines.
Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
editor.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/editor.c b/editor.c
index b67b802ddf..d1ba2d7c34 100644
--- a/editor.c
+++ b/editor.c
@@ -104,16 +104,15 @@ static int launch_specified_editor(const char *editor, const char *path,
sigchain_pop(SIGQUIT);
if (sig == SIGINT || sig == SIGQUIT)
raise(sig);
- if (ret)
- return error("There was a problem with the editor '%s'.",
- editor);
-
if (print_waiting_for_editor && !is_terminal_dumb())
/*
* Erase the entire line to avoid wasting the
* vertical space.
*/
term_clear_line();
+ if (ret)
+ return error("there was a problem with the editor '%s'",
+ editor);
}
if (!buffer)
--
2.44.0.782.g038d277106
^ permalink raw reply related [flat|nested] 26+ messages in thread* Re: [PATCH v4] launch_editor: waiting message on error
2024-04-14 7:39 ` [PATCH v4] " Rubén Justo
@ 2024-04-15 14:05 ` Phillip Wood
2024-04-15 17:03 ` Rubén Justo
2024-04-15 17:20 ` Junio C Hamano
2024-04-15 17:07 ` Rubén Justo
1 sibling, 2 replies; 26+ messages in thread
From: Phillip Wood @ 2024-04-15 14:05 UTC (permalink / raw)
To: Rubén Justo, Git List, Junio C Hamano; +Cc: rsbecker, Phillip Wood
Hi Rubén
On 14/04/2024 08:39, Rubén Justo wrote:
> When advice.waitingForEditor configuration is not set to false, we show
> a hint telling that we are waiting for user's editor to close the file
> when we launch an editor and wait for it to return control back to us.
> We give the message on an incomplete line, expecting that we can go back
> to the line and clear the message when the editor returns.
>
> However, it is possible that the editor exits with an error status, in
> which case we show an error message and then return to our caller. In
> such a case, the error message is given where the terminal cursor
> happens to be, which is most likely after the "we are waiting for your
> editor" message on the same line.
As I've said before I'm not sure how likely that is as I think the
editor will probably have printed a message if there was an error.
Assuming the message from the editor ends with a newline the proposed
change wont do any harm so I don't object to it.
Best Wishes
Phillip
> Clear the line before showing the error.
>
> While we're here, make the error message follow our CodingGuideLines.
>
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
> editor.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/editor.c b/editor.c
> index b67b802ddf..d1ba2d7c34 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -104,16 +104,15 @@ static int launch_specified_editor(const char *editor, const char *path,
> sigchain_pop(SIGQUIT);
> if (sig == SIGINT || sig == SIGQUIT)
> raise(sig);
> - if (ret)
> - return error("There was a problem with the editor '%s'.",
> - editor);
> -
> if (print_waiting_for_editor && !is_terminal_dumb())
> /*
> * Erase the entire line to avoid wasting the
> * vertical space.
> */
> term_clear_line();
> + if (ret)
> + return error("there was a problem with the editor '%s'",
> + editor);
> }
>
> if (!buffer)
^ permalink raw reply [flat|nested] 26+ messages in thread* Re: [PATCH v4] launch_editor: waiting message on error
2024-04-15 14:05 ` Phillip Wood
@ 2024-04-15 17:03 ` Rubén Justo
2024-04-15 17:20 ` Junio C Hamano
1 sibling, 0 replies; 26+ messages in thread
From: Rubén Justo @ 2024-04-15 17:03 UTC (permalink / raw)
To: phillip.wood, Git List, Junio C Hamano; +Cc: rsbecker
On Mon, Apr 15, 2024 at 03:05:32PM +0100, Phillip Wood wrote:
> > However, it is possible that the editor exits with an error status, in
> > which case we show an error message and then return to our caller. In
> > such a case, the error message is given where the terminal cursor
> > happens to be, which is most likely after the "we are waiting for your
> > editor" message on the same line.
>
> As I've said before I'm not sure how likely that is as I think the editor
> will probably have printed a message if there was an error.
For instance, Vim with ":cq" does not emit any error message.
> Assuming the
> message from the editor ends with a newline the proposed change wont do any
> harm so I don't object to it.
Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] launch_editor: waiting message on error
2024-04-15 14:05 ` Phillip Wood
2024-04-15 17:03 ` Rubén Justo
@ 2024-04-15 17:20 ` Junio C Hamano
1 sibling, 0 replies; 26+ messages in thread
From: Junio C Hamano @ 2024-04-15 17:20 UTC (permalink / raw)
To: Phillip Wood; +Cc: Rubén Justo, Git List, rsbecker, Phillip Wood
Phillip Wood <phillip.wood123@gmail.com> writes:
> As I've said before I'm not sure how likely that is as I think the
> editor will probably have printed a message if there was an
> error. Assuming the message from the editor ends with a newline the
> proposed change wont do any harm so I don't object to it.
Yup, I think it is a no-op for a well-behaving editor that emits an
error message with terminating newline. An editor that leaves its
own error message incomplete, its error message together with our
"we are waiting" will be erased together, but we probably do not
care for such an editor. If an editor silently errors out, then
this will still clear "we are waiting" we printed earlier and say
"there was a problem", which is what we want to see happen.
So, this looks good to me; let's queue it.
Thanks, both.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] launch_editor: waiting message on error
2024-04-14 7:39 ` [PATCH v4] " Rubén Justo
2024-04-15 14:05 ` Phillip Wood
@ 2024-04-15 17:07 ` Rubén Justo
2024-04-15 18:44 ` Junio C Hamano
1 sibling, 1 reply; 26+ messages in thread
From: Rubén Justo @ 2024-04-15 17:07 UTC (permalink / raw)
To: Git List, Junio C Hamano; +Cc: rsbecker, Phillip Wood
On Sun, Apr 14, 2024 at 09:39:44AM +0200, Rubén Justo wrote:
> When advice.waitingForEditor configuration is not set to false, we show
> a hint telling that we are waiting for user's editor to close the file
> when we launch an editor and wait for it to return control back to us.
> We give the message on an incomplete line, expecting that we can go back
> to the line and clear the message when the editor returns.
>
> However, it is possible that the editor exits with an error status, in
> which case we show an error message and then return to our caller. In
> such a case, the error message is given where the terminal cursor
> happens to be, which is most likely after the "we are waiting for your
> editor" message on the same line.
>
> Clear the line before showing the error.
>
> While we're here, make the error message follow our CodingGuideLines.
>
> Signed-off-by: Rubén Justo <rjusto@gmail.com>
> ---
The changes since v3 are:
- dropped [v3 1/2] because, as noted by Randall and Phillip, it is not a
good idea.
The message stays like:
$ GIT_EDITOR=falso git commit -a
hint: Waiting for your editor to close the file... error: cannot run falso: No such file or directory
error: unable to start editor 'falso'
Please supply the message using either -m or -F option.
The "error: unable to start..." at the beginning of the line makes it
less prone to confusion than the other error message considered in
this series.
- term_clear_line() is now used in all cases as it is unlikely that any
sane editor emits an error message without ending it with a newline.
This:
$ GIT_EDITOR=false git commit -a
hint: Waiting for your editor to close the file... error: There was a problem with the editor 'false'.
Please supply the message using either -m or -F option.
becomes:
$ GIT_EDITOR=false git commit -a
error: There was a problem with the editor 'false'.
Please supply the message using either -m or -F option.
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH v4] launch_editor: waiting message on error
2024-04-15 17:07 ` Rubén Justo
@ 2024-04-15 18:44 ` Junio C Hamano
0 siblings, 0 replies; 26+ messages in thread
From: Junio C Hamano @ 2024-04-15 18:44 UTC (permalink / raw)
To: Rubén Justo; +Cc: Git List, rsbecker, Phillip Wood
Rubén Justo <rjusto@gmail.com> writes:
> - term_clear_line() is now used in all cases as it is unlikely that any
> sane editor emits an error message without ending it with a newline.
>
> This:
>
> $ GIT_EDITOR=false git commit -a
> hint: Waiting for your editor to close the file... error: There was a problem with the editor 'false'.
> Please supply the message using either -m or -F option.
>
> becomes:
>
> $ GIT_EDITOR=false git commit -a
> error: There was a problem with the editor 'false'.
> Please supply the message using either -m or -F option.
Nobody uses 'false' as their editor, but as you said ':cq' in vim
may be a real-world example of a use case that may benefit from this
change.
Will queue. Thanks.
^ permalink raw reply [flat|nested] 26+ messages in thread