threads / patch / 47229

v2launch_editor(): indicate that Git waits for user input

Subject: [PATCH v2] launch_editor(): indicate that Git waits for user input

## tl;dr

12 messages between Nov 17, 2017 and Nov 24, 2017. Diffs are folded; open one to read it.

replies: 11people: 5as markdown or json

lars.schneider@autodesk.com· Nov 17, 2017, 13:51 UTC · lore
From: Junio C Hamano <gitster@pobox.com>

When a graphical GIT_EDITOR is spawned by a Git command that opens and waits for user input (e.g. "git rebase -i"), then the editor window might be obscured by other windows. The user may be left staring at the original Git terminal window without even realizing that s/he needs to interact with another window before Git can proceed. To this user Git appears hanging.

Show a message in the original terminal and get rid of it when the editor returns.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---

Junio posted the original version of this patch [1] as response to my RFC [2]. I took Junio's patch and slightly changed the commit message as well as the message printed to the user after GIT_EDITOR is invoked [3].

Thanks, Lars

[1] https://public-inbox.org/git/xmqqr2syvjxb.fsf@gitster.mtv.corp.google.com/ [2] https://public-inbox.org/git/274B4850-2EB7-4BFA-A42C-25A573254969@gmail.com/ [3] https://public-inbox.org/git/DAEC36C7-AE09-4C9B-ACC4-07F2C5F2B97F@gmail.com/

Notes:
    Base Ref: master
    Web-Diff: https://github.com/larsxschneider/git/commit/6fd6d8e682
    Checkout: git fetch https://github.com/larsxschneider/git editor-v2 && git checkout 6fd6d8e682
 editor.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
Show changes to editor.c +29 −1
diff --git a/editor.c b/editor.c
index 7519edecdc..23db92d8c6 100644
--- a/editor.c
+++ b/editor.c
@@ -40,6 +40,32 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 		const char *args[] = { editor, real_path(path), NULL };
 		struct child_process p = CHILD_PROCESS_INIT;
 		int ret, sig;
+		static const char *close_notice = NULL;
+
+		if (isatty(2) && !close_notice) {
+			char *term = getenv("TERM");
+
+			if (term && strcmp(term, "dumb"))
+				/*
+				 * go back to the beginning and erase the
+				 * entire line if the terminal is capable
+				 * to do so, to avoid wasting the vertical
+				 * space.
+				 */
+				close_notice = "\r\033[K";
+			else
+				/* otherwise, complete and waste the line */
+				close_notice = "done.\n";
+		}
+
+		if (close_notice) {
+			fprintf(
+				stderr,
+				"Launched your editor ('%s'). Adjust, save, and close the "
+				"file to continue. Waiting for your input... ", editor
+			);
+			fflush(stderr);
+		}

 		p.argv = args;
 		p.env = env;
@@ -53,11 +79,14 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
 		sig = ret - 128;
 		sigchain_pop(SIGINT);
 		sigchain_pop(SIGQUIT);
+
 		if (sig == SIGINT || sig == SIGQUIT)
 			raise(sig);
 		if (ret)
 			return error("There was a problem with the editor '%s'.",
 					editor);
+		if (close_notice)
+			fputs(close_notice, stderr);
 	}

 	if (!buffer)

base-commit: 89ea799ffcc5c8a0547d3c9075eb979256ee95b8
--
2.15.0
Junio C Hamano· Nov 17, 2017, 18:40 UTC · re: lars.schneider@autodesk.com · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

lars.schneider@autodesk.com writes:
Show 6 quoted lines
> Junio posted the original version of this patch [1] as response to my RFC [2].
> I took Junio's patch and slightly changed the commit message as well as the
> message printed to the user after GIT_EDITOR is invoked [3].
>
> Thanks,
> Lars
Thanks.
Show 11 quoted lines
> diff --git a/editor.c b/editor.c
> index 7519edecdc..23db92d8c6 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -40,6 +40,32 @@ int launch_editor(const char *path, struct strbuf...
> ...
> +		if (close_notice) {
> +			fprintf(
> +				stderr,
> +				"Launched your editor ('%s'). Adjust, save, and close the "
> +				"file to continue. Waiting for your input... ", editor

How wide is your typical terminal window? With message this long, a sample standalone program I used while developing the prototype of this feature no longer can retract this "temporary" message.

Would something shorter like "Waiting for you to finish editing..." work well enough?

-- -- -- #include <stdio.h>

int main(void)
{
	const char *EL = "\033[K"; /* Erase in Line */
	const char *editor = "emacsclient";
	fprintf(
		stderr,
		"Launched your editor ('%s'). Adjust, save, and close the "
		"file to continue. Waiting for your input... ", editor);
	fflush(stderr);
	sleep(2);
	fprintf(stderr, "\r%s", EL);
	fflush(stderr);
	return 0;
}
-- -- --
Lars Schneider· Nov 22, 2017, 16:47 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

Show 31 quoted lines
> On 17 Nov 2017, at 19:40, Junio C Hamano <gitster@pobox.com> wrote:
> 
> lars.schneider@autodesk.com writes:
> 
>> Junio posted the original version of this patch [1] as response to my RFC [2].
>> I took Junio's patch and slightly changed the commit message as well as the
>> message printed to the user after GIT_EDITOR is invoked [3].
>> 
>> Thanks,
>> Lars
> 
> Thanks.
> 
>> diff --git a/editor.c b/editor.c
>> index 7519edecdc..23db92d8c6 100644
>> --- a/editor.c
>> +++ b/editor.c
>> @@ -40,6 +40,32 @@ int launch_editor(const char *path, struct strbuf...
>> ...
>> +		if (close_notice) {
>> +			fprintf(
>> +				stderr,
>> +				"Launched your editor ('%s'). Adjust, save, and close the "
>> +				"file to continue. Waiting for your input... ", editor
> 
> How wide is your typical terminal window?  With message this long, a
> sample standalone program I used while developing the prototype of
> this feature no longer can retract this "temporary" message.
> 
> Would something shorter like "Waiting for you to finish editing..."
> work well enough?

Yeah, Eric criticized the verbosity elsewhere, too. I understand your point of view. Let's revert it to your initial short version.

- Lars
Show 21 quoted lines
> 
> -- -- --
> #include <stdio.h>
> 
> int main(void)
> {
> 	const char *EL = "\033[K"; /* Erase in Line */
> 	const char *editor = "emacsclient";
> 
> 	fprintf(
> 		stderr,
> 		"Launched your editor ('%s'). Adjust, save, and close the "
> 		"file to continue. Waiting for your input... ", editor);
> 	fflush(stderr);
> 	sleep(2);
> 	fprintf(stderr, "\r%s", EL);
> 	fflush(stderr);
> 	return 0;
> }
> -- -- --
> 
Eric Sunshine· Nov 17, 2017, 19:41 UTC · re: lars.schneider@autodesk.com · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

On Fri, Nov 17, 2017 at 8:51 AM,  <lars.schneider@autodesk.com> wrote:
Show 18 quoted lines
> When a graphical GIT_EDITOR is spawned by a Git command that opens
> and waits for user input (e.g. "git rebase -i"), then the editor window
> might be obscured by other windows. The user may be left staring at the
> original Git terminal window without even realizing that s/he needs to
> interact with another window before Git can proceed. To this user Git
> appears hanging.
>
> Show a message in the original terminal and get rid of it when the
> editor returns.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
> diff --git a/editor.c b/editor.c
> @@ -40,6 +40,32 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
> +               static const char *close_notice = NULL;
> +
> +               if (isatty(2) && !close_notice) {

If you reverse this condition to say (!close_notice && isatty(2)), then you save an isatty() invocation each time if close_notice is already assigned.

However, it's not clear how much benefit you gain from stashing this away in a static variable. Premature optimization?

Show 21 quoted lines
> +                       char *term = getenv("TERM");
> +
> +                       if (term && strcmp(term, "dumb"))
> +                               /*
> +                                * go back to the beginning and erase the
> +                                * entire line if the terminal is capable
> +                                * to do so, to avoid wasting the vertical
> +                                * space.
> +                                */
> +                               close_notice = "\r\033[K";
> +                       else
> +                               /* otherwise, complete and waste the line */
> +                               close_notice = "done.\n";
> +               }
> +
> +               if (close_notice) {
> +                       fprintf(
> +                               stderr,
> +                               "Launched your editor ('%s'). Adjust, save, and close the "
> +                               "file to continue. Waiting for your input... ", editor
> +                       );
Here's what this looks like for me:

--- 8< --- Launched your editor ('/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'). Adjust, save, and close the file to continue. Waiting for your input... Waiting for Emacs... --- 8< ---

Very, very noisy, so much so that it's almost unreadable. There are at least three reasons for the noise:

* The raw message itself is already overly long. Do we really need to
assume that newcomers are so clueless that they need it spelled out to
such a level of detail? "Launched editor" should be enough for most
people, and one would hope that "Launched editor; waiting for
input..." would be enough for the rest.
* Does not take into consideration that EDITOR might be very long;
perhaps you could just print the basename and strip arguments (i.e.
"/my/long/path/edit -x --foo --zap" becomes "edit"). Or, just omit the
editor altogether.
* emacsclient already prints its own message ("Waiting for Emacs...",
which runs together with Git's message). Perhaps treat emacsclient as
a special case and skip printing this message if emacsclient is in
use: if (strstr(...,"emacsclient"))

And, of course, with a "dumb" terminal, it's even noisier with the extra "done." at the end:

--- 8< --- Launched your editor ('/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'). Adjust, save, and close the file to continue. Waiting for your input... Waiting for Emacs... done. --- 8< ---

As Junio pointed out in [1], emacsclient has already emitted a newline, so the clear-line sequence is ineffective; likewise, for a dumb terminal, "done." ends up on its own line. Aside from the noise, this also suggests making a special case for emacsclient.

And, as Junio pointed out in [2], with a message so long, once it has wrapped, the clear-line sequence does not work as intended. For those of us with 80-column terminals, we're left with a bunch of noise on the screen.

Show 17 quoted lines
> +                       fflush(stderr);
> +               }
>
>                 p.argv = args;
>                 p.env = env;
> @@ -53,11 +79,14 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>                 sig = ret - 128;
>                 sigchain_pop(SIGINT);
>                 sigchain_pop(SIGQUIT);
> +
>                 if (sig == SIGINT || sig == SIGQUIT)
>                         raise(sig);
>                 if (ret)
>                         return error("There was a problem with the editor '%s'.",
>                                         editor);
> +               if (close_notice)
> +                       fputs(close_notice, stderr);

Should printing of close_notice be done before the error()? Otherwise, you get this:

--- 8< --- Launched your editor (...) ...There was a problem... --- 8< ---

>         }

[1]: https://public-inbox.org/git/xmqqr2syvjxb.fsf@gitster.mtv.corp.google.com/ [2]: https://public-inbox.org/git/xmqqy3n4rbnr.fsf@gitster.mtv.corp.google.com/

Junio C Hamano· Nov 18, 2017, 01:40 UTC · re: Eric Sunshine · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

Eric Sunshine <sunshine@sunshineco.com> writes:
Show 11 quoted lines
>> @@ -40,6 +40,32 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>> +               static const char *close_notice = NULL;
>> +
>> +               if (isatty(2) && !close_notice) {
>
> If you reverse this condition to say (!close_notice && isatty(2)),
> then you save an isatty() invocation each time if close_notice is
> already assigned.
>
> However, it's not clear how much benefit you gain from stashing this
> away in a static variable. Premature optimization?

The variable being "static" could be (but it was done primarily because it allowed me not to worry about freeing), but during a single invocation, it primarily is used as a flag "are we showing the editor invocation notice?" two places in the function can use without having to do the same checks twice.

If we want this as an optimization "we've already checked the condition in our previous call, so let's use the result without checking again", then this has to become tristate:

 - We haven't checked, and needs checking (probably NULL);
 - We have checked, and we know we want to show the notice---here is
   a string to use when we clear the notice (what we have here);
 - We have checked, and we know we do not want to show the notice
   (there is no provision for this in the posted code---that makes
   this not an optimization yet).

Perhaps an empty string can be used for the last one, but if/when it is done, the above needs to go in a comment near the definition of the variable.

Show 6 quoted lines
> Should printing of close_notice be done before the error()? Otherwise,
> you get this:
>
> --- 8< ---
> Launched your editor (...) ...There was a problem...
> --- 8< ---

In my version with a far shorter message, I deliberately chose not to clear the notice. We ran the editor, and we saw a problem. That is what happened and that is what will be left on the terminal.

I agree that the verbose message Lars substituted makes it harder to read.

Kaartic Sivaraam· Nov 19, 2017, 17:49 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

On Saturday 18 November 2017 07:10 AM, Junio C Hamano wrote:
Show 16 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> 
>>> @@ -40,6 +40,32 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>>> +               static const char *close_notice = NULL;
>>> +
>>> +               if (isatty(2) && !close_notice) {
>>
>> If you reverse this condition to say (!close_notice && isatty(2)),
>> then you save an isatty() invocation each time if close_notice is
>> already assigned.
>>
>> However, it's not clear how much benefit you gain from stashing this
>> away in a static variable. Premature optimization?
> 
> The variable being "static" could be (but it was done primarily
> because it allowed me not to worry about freeing),

AFAIK, observing the way the variable 'close_notice' is used, I guess you don't need to worry about freeing it up even if it wasn't "static". That's my interpretation of the following section of the C standard,

======================== 6.5.2.5 Compound literals

...

9 EXAMPLE 2 In contrast, in void f(void) { int *p; /*...*/ p = (int [2]){*p}; /*...*/ } p is assigned the address of the first element of an array of two ints, the first having the value previously pointed to by p and the second, zero. The expressions in this compound literal need not be constant. The unnamed object has automatic storage duration. =========================

So the unnamed objects created as a consequence of the string literals assigned to 'close_notice' should have "automatic" storage duration which means you don't have to worry about allocating memory for them which would make you worry about freeing it up. If I'm stating something wrong, let me know.

BTW, I find making the variable 'close_notice' to be 'static' unwanted as I couldn't find any piece of code that invokes 'launch_editor' more than once within a single run. What could be the possible cases in which 'launch_editor' could be called twice ?

Show 11 quoted lines
>> Should printing of close_notice be done before the error()? Otherwise,
>> you get this:
>>
>> --- 8< ---
>> Launched your editor (...) ...There was a problem...
>> --- 8< ---
> 
> In my version with a far shorter message, I deliberately chose not
> to clear the notice.  We ran the editor, and we saw a problem.  That
> is what happened and that is what will be left on the terminal.
> 

It might be a good thing to keep the notice but I think it would be better to have that error message in a "new line". I'm not sure if it's possible or not.

--- Kaartic

Junio C Hamano· Nov 20, 2017, 00:11 UTC · re: Kaartic Sivaraam · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
Show 5 quoted lines
>>> However, it's not clear how much benefit you gain from stashing this
>>> away in a static variable. Premature optimization?
>>
>> The variable being "static" could be (but it was done primarily
>> because it allowed me not to worry about freeing),

The current code happens to be safe because I do not allocate. I do not know what others will do to the code in the future, and at that point, instinct kicks in to futureproof against the worst ;-).

Show 15 quoted lines
>>> Should printing of close_notice be done before the error()? Otherwise,
>>> you get this:
>>>
>>> --- 8< ---
>>> Launched your editor (...) ...There was a problem...
>>> --- 8< ---
>>
>> In my version with a far shorter message, I deliberately chose not
>> to clear the notice.  We ran the editor, and we saw a problem.  That
>> is what happened and that is what will be left on the terminal.
>>
>
> It might be a good thing to keep the notice but I think it would be
> better to have that error message in a "new line". I'm not sure if
> it's possible or not.

Of course it is possible, if you really wanted to. The code knows if it gave the "we launched and waiting for you" notice, so it can maintain not just one (i.e. "how I close the notice?") but another one (i.e. "how I do so upon an error?") and use it in the error codepath.

Lars Schneider· Nov 22, 2017, 16:55 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

Show 35 quoted lines
> On 20 Nov 2017, at 01:11, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> 
>>>> However, it's not clear how much benefit you gain from stashing this
>>>> away in a static variable. Premature optimization?
>>> 
>>> The variable being "static" could be (but it was done primarily
>>> because it allowed me not to worry about freeing),
> 
> The current code happens to be safe because I do not allocate.  I do
> not know what others will do to the code in the future, and at that
> point, instinct kicks in to futureproof against the worst ;-).
> 
>>>> Should printing of close_notice be done before the error()? Otherwise,
>>>> you get this:
>>>> 
>>>> --- 8< ---
>>>> Launched your editor (...) ...There was a problem...
>>>> --- 8< ---
>>> 
>>> In my version with a far shorter message, I deliberately chose not
>>> to clear the notice.  We ran the editor, and we saw a problem.  That
>>> is what happened and that is what will be left on the terminal.
>>> 
>> 
>> It might be a good thing to keep the notice but I think it would be
>> better to have that error message in a "new line". I'm not sure if
>> it's possible or not.
> 
> Of course it is possible, if you really wanted to.  The code knows
> if it gave the "we launched and waiting for you" notice, so it can
> maintain not just one (i.e. "how I close the notice?") but another
> one (i.e. "how I do so upon an error?") and use it in the error
> codepath.
I think a newline makes sense. I'll look into this for v3.

Thanks, Lars

Kaartic Sivaraam· Nov 22, 2017, 17:58 UTC · re: Lars Schneider · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

On Wednesday 22 November 2017 10:25 PM, Lars Schneider wrote:
Show 16 quoted lines
> 
>> On 20 Nov 2017, at 01:11, Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
>>> It might be a good thing to keep the notice but I think it would be
>>> better to have that error message in a "new line". I'm not sure if
>>> it's possible or not.
>>
>> Of course it is possible, if you really wanted to.  The code knows
>> if it gave the "we launched and waiting for you" notice, so it can
>> maintain not just one (i.e. "how I close the notice?") but another
>> one (i.e. "how I do so upon an error?") and use it in the error
>> codepath.
> 
> I think a newline makes sense. I'll look into this for v3.
>

If I remember correctly, I don't think it's as simple as printing a newline character in case of an error. That's because the error message that shows up in the same line as "Launched your ..." comes from a different function (possibly finish_command() though I'm not sure)

> Thanks,
> Lars
> 
Junio C Hamano· Nov 24, 2017, 06:38 UTC · re: Lars Schneider · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

Lars Schneider <larsxschneider@gmail.com> writes:
Show 7 quoted lines
>> Of course it is possible, if you really wanted to.  The code knows
>> if it gave the "we launched and waiting for you" notice, so it can
>> maintain not just one (i.e. "how I close the notice?") but another
>> one (i.e. "how I do so upon an error?") and use it in the error
>> codepath.
>
> I think a newline makes sense. I'll look into this for v3.

As this is an error codepath, I am OK to waste one more line with a line break after the "we launched and are waiting..." message, but with a shorter "we are waiting..." message, I do not know if it is bad enough to have these two on the same line, so I am on the fence.

Lars Schneider· Nov 22, 2017, 16:53 UTC · re: Eric Sunshine · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

Show 48 quoted lines
> On 17 Nov 2017, at 20:41, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 
> On Fri, Nov 17, 2017 at 8:51 AM,  <lars.schneider@autodesk.com> wrote:
> 
>> +                       char *term = getenv("TERM");
>> +
>> +                       if (term && strcmp(term, "dumb"))
>> +                               /*
>> +                                * go back to the beginning and erase the
>> +                                * entire line if the terminal is capable
>> +                                * to do so, to avoid wasting the vertical
>> +                                * space.
>> +                                */
>> +                               close_notice = "\r\033[K";
>> +                       else
>> +                               /* otherwise, complete and waste the line */
>> +                               close_notice = "done.\n";
>> +               }
>> +
>> +               if (close_notice) {
>> +                       fprintf(
>> +                               stderr,
>> +                               "Launched your editor ('%s'). Adjust, save, and close the "
>> +                               "file to continue. Waiting for your input... ", editor
>> +                       );
> 
> Here's what this looks like for me:
> 
> --- 8< ---
> Launched your editor
> ('/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'). Adjust,
> save, and close the file to continue. Waiting for your input...
> Waiting for Emacs...
> --- 8< ---
> 
> Very, very noisy, so much so that it's almost unreadable. There are at
> least three reasons for the noise:
> 
> * The raw message itself is already overly long. Do we really need to
> assume that newcomers are so clueless that they need it spelled out to
> such a level of detail? "Launched editor" should be enough for most
> people, and one would hope that "Launched editor; waiting for
> input..." would be enough for the rest.
> 
> * Does not take into consideration that EDITOR might be very long;
> perhaps you could just print the basename and strip arguments (i.e.
> "/my/long/path/edit -x --foo --zap" becomes "edit"). Or, just omit the
> editor altogether.

Agreed already in another reply here: https://public-inbox.org/git/0DD1EE8A-47F1-41AA-8F86-C9FDF99D22A0@gmail.com/

Show 5 quoted lines
> 
> * emacsclient already prints its own message ("Waiting for Emacs...",
> which runs together with Git's message). Perhaps treat emacsclient as
> a special case and skip printing this message if emacsclient is in
> use: if (strstr(...,"emacsclient"))

If Junio et al. are ok with the special handling of emacs, then I am happy to add this change in v3. If we look for "emacsclient", then would this cover emacs on Linux and Windows, too? (I am no emacs user)

Show 46 quoted lines
> 
> And, of course, with a "dumb" terminal, it's even noisier with the
> extra "done." at the end:
> 
> --- 8< ---
> Launched your editor
> ('/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'). Adjust,
> save, and close the file to continue. Waiting for your input...
> Waiting for Emacs...
> done.
> --- 8< ---
> 
> As Junio pointed out in [1], emacsclient has already emitted a
> newline, so the clear-line sequence is ineffective; likewise, for a
> dumb terminal, "done." ends up on its own line. Aside from the noise,
> this also suggests making a special case for emacsclient.
> 
> And, as Junio pointed out in [2], with a message so long, once it has
> wrapped, the clear-line sequence does not work as intended. For those
> of us with 80-column terminals, we're left with a bunch of noise on
> the screen.
> 
>> +                       fflush(stderr);
>> +               }
>> 
>>                p.argv = args;
>>                p.env = env;
>> @@ -53,11 +79,14 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>>                sig = ret - 128;
>>                sigchain_pop(SIGINT);
>>                sigchain_pop(SIGQUIT);
>> +
>>                if (sig == SIGINT || sig == SIGQUIT)
>>                        raise(sig);
>>                if (ret)
>>                        return error("There was a problem with the editor '%s'.",
>>                                        editor);
>> +               if (close_notice)
>> +                       fputs(close_notice, stderr);
> 
> Should printing of close_notice be done before the error()? Otherwise,
> you get this:
> 
> --- 8< ---
> Launched your editor (...) ...There was a problem...
> --- 8< ---

I think we should keep it as I agree with Junio's argument here: https://public-inbox.org/git/xmqqh8tsqs83.fsf@gitster.mtv.corp.google.com/

- Lars
Eric Sunshine· Nov 22, 2017, 17:33 UTC · re: Lars Schneider · lore

Re: [PATCH v2] launch_editor(): indicate that Git waits for user input

On Wed, Nov 22, 2017 at 11:53 AM, Lars Schneider <larsxschneider@gmail.com> wrote:

Show 9 quoted lines
>> On 17 Nov 2017, at 20:41, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> * emacsclient already prints its own message ("Waiting for Emacs...",
>> which runs together with Git's message). Perhaps treat emacsclient as
>> a special case and skip printing this message if emacsclient is in
>> use: if (strstr(...,"emacsclient"))
>
> If Junio et al. are ok with the special handling of emacs, then I am happy
> to add this change in v3. If we look for "emacsclient", then would this
> cover emacs on Linux and Windows, too? (I am no emacs user)

Yes, searching for "emacsclient" should work on all platforms (Linux, MacOS, Windows, BSD). Most of the time, the full value of EDITOR is just "emacsclient", but sometimes emacsclient is located at an out-of-the-way location, not in PATH, such as in my example (/long/path/to/emacsclient). On Windows, it's actually called "emacsclientw", but that should be matched just fine when searching for "emacsclient".

← back to recent threads