git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2] launch_editor(): indicate that Git waits for user input
@ 2017-11-17 13:51 lars.schneider
  2017-11-17 18:40 ` Junio C Hamano
  2017-11-17 19:41 ` Eric Sunshine
  0 siblings, 2 replies; 12+ messages in thread
From: lars.schneider @ 2017-11-17 13:51 UTC (permalink / raw)
  To: git; +Cc: gitster, sbeller, Lars Schneider

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(+)

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-17 13:51 [PATCH v2] launch_editor(): indicate that Git waits for user input lars.schneider
@ 2017-11-17 18:40 ` Junio C Hamano
  2017-11-22 16:47   ` Lars Schneider
  2017-11-17 19:41 ` Eric Sunshine
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2017-11-17 18:40 UTC (permalink / raw)
  To: lars.schneider; +Cc: git, sbeller, Lars Schneider

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?

-- -- --
#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;
}
-- -- --


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-17 13:51 [PATCH v2] launch_editor(): indicate that Git waits for user input lars.schneider
  2017-11-17 18:40 ` Junio C Hamano
@ 2017-11-17 19:41 ` Eric Sunshine
  2017-11-18  1:40   ` Junio C Hamano
  2017-11-22 16:53   ` Lars Schneider
  1 sibling, 2 replies; 12+ messages in thread
From: Eric Sunshine @ 2017-11-17 19:41 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git List, Junio C Hamano, Stefan Beller, Lars Schneider

On Fri, Nov 17, 2017 at 8:51 AM,  <lars.schneider@autodesk.com> wrote:
> 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?

> +                       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.

> +                       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/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-17 19:41 ` Eric Sunshine
@ 2017-11-18  1:40   ` Junio C Hamano
  2017-11-19 17:49     ` Kaartic Sivaraam
  2017-11-22 16:53   ` Lars Schneider
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2017-11-18  1:40 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Lars Schneider, Git List, Stefan Beller, Lars Schneider

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), 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.

> 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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-18  1:40   ` Junio C Hamano
@ 2017-11-19 17:49     ` Kaartic Sivaraam
  2017-11-20  0:11       ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Kaartic Sivaraam @ 2017-11-19 17:49 UTC (permalink / raw)
  To: Junio C Hamano, Eric Sunshine
  Cc: Lars Schneider, Git List, Stefan Beller, Lars Schneider

On Saturday 18 November 2017 07:10 AM, Junio C Hamano wrote:
> 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 ?


>> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-19 17:49     ` Kaartic Sivaraam
@ 2017-11-20  0:11       ` Junio C Hamano
  2017-11-22 16:55         ` Lars Schneider
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2017-11-20  0:11 UTC (permalink / raw)
  To: Kaartic Sivaraam
  Cc: Eric Sunshine, Lars Schneider, Git List, Stefan Beller,
	Lars Schneider

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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-17 18:40 ` Junio C Hamano
@ 2017-11-22 16:47   ` Lars Schneider
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Schneider @ 2017-11-22 16:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Lars Schneider, git, Stefan Beller, Eric Sunshine


> 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

> 
> -- -- --
> #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;
> }
> -- -- --
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-17 19:41 ` Eric Sunshine
  2017-11-18  1:40   ` Junio C Hamano
@ 2017-11-22 16:53   ` Lars Schneider
  2017-11-22 17:33     ` Eric Sunshine
  1 sibling, 1 reply; 12+ messages in thread
From: Lars Schneider @ 2017-11-22 16:53 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Lars Schneider, Git List, Junio C Hamano, Stefan Beller


> 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/

> 
> * 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)


> 
> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-20  0:11       ` Junio C Hamano
@ 2017-11-22 16:55         ` Lars Schneider
  2017-11-22 17:58           ` Kaartic Sivaraam
  2017-11-24  6:38           ` Junio C Hamano
  0 siblings, 2 replies; 12+ messages in thread
From: Lars Schneider @ 2017-11-22 16:55 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Kaartic Sivaraam, Eric Sunshine, Lars Schneider, Git List,
	Stefan Beller


> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-22 16:53   ` Lars Schneider
@ 2017-11-22 17:33     ` Eric Sunshine
  0 siblings, 0 replies; 12+ messages in thread
From: Eric Sunshine @ 2017-11-22 17:33 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Lars Schneider, Git List, Junio C Hamano, Stefan Beller

On Wed, Nov 22, 2017 at 11:53 AM, Lars Schneider
<larsxschneider@gmail.com> wrote:
>> 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".

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-22 16:55         ` Lars Schneider
@ 2017-11-22 17:58           ` Kaartic Sivaraam
  2017-11-24  6:38           ` Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Kaartic Sivaraam @ 2017-11-22 17:58 UTC (permalink / raw)
  To: Lars Schneider, Junio C Hamano
  Cc: Eric Sunshine, Lars Schneider, Git List, Stefan Beller

On Wednesday 22 November 2017 10:25 PM, Lars Schneider wrote:
> 
>> 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
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
  2017-11-22 16:55         ` Lars Schneider
  2017-11-22 17:58           ` Kaartic Sivaraam
@ 2017-11-24  6:38           ` Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2017-11-24  6:38 UTC (permalink / raw)
  To: Lars Schneider
  Cc: Kaartic Sivaraam, Eric Sunshine, Lars Schneider, Git List,
	Stefan Beller

Lars Schneider <larsxschneider@gmail.com> writes:

>> 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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-11-24  6:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-17 13:51 [PATCH v2] launch_editor(): indicate that Git waits for user input lars.schneider
2017-11-17 18:40 ` Junio C Hamano
2017-11-22 16:47   ` Lars Schneider
2017-11-17 19:41 ` Eric Sunshine
2017-11-18  1:40   ` Junio C Hamano
2017-11-19 17:49     ` Kaartic Sivaraam
2017-11-20  0:11       ` Junio C Hamano
2017-11-22 16:55         ` Lars Schneider
2017-11-22 17:58           ` Kaartic Sivaraam
2017-11-24  6:38           ` Junio C Hamano
2017-11-22 16:53   ` Lars Schneider
2017-11-22 17:33     ` Eric Sunshine

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).