git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Lars Schneider <larsxschneider@gmail.com>
Date
Nov 27, 2017, 20:04 UTC
Message-ID
<BF8D6B02-37C1-40B3-9FDA-3B1055389B85@gmail.com>
In-Reply-To
<CAPig+cSStSbckFi5K33z0WZThjNZC5Eb1Fb+ikrd5ZajM6mV3Q@mail.gmail.com>
Show 36 quoted lines
> On 27 Nov 2017, at 19:36, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 
> On Mon, Nov 27, 2017 at 8:47 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,35 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>> +               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 if (term && strstr(term, "emacsclient"))
> 
> You need to check 'editor' here, not 'term', and you should do it
> before the "not dumb" terminal check, otherwise you'll never get this
> far.
Ouch. That happens if I try to do two things at once. Embarrassing.

Thanks, Lars

Show 11 quoted lines
> 
>> +                               /*
>> +                                * `emacsclient` (or `emacsclientw` on Windows) already prints
>> +                                * ("Waiting for Emacs...") if a file is opened for editing.
>> +                                * Therefore, we don't need to print the editor launch info.
>> +                                */
>> +                               ;
>> +                       else
>> +                               /* otherwise, complete and waste the line */
>> +                               close_notice = _("done.\n");
>> +               }
Previous: Eric SunshineNext: brian m. carlson
Message 4 of 11 in “launch_editor(): indicate that Git waits for user input”
  1. launch_editor(): indicate that Git waits for user inputlars.schneider@autodesk.com, Nov 27, 2017
  2. Kaartic SivaraamNov 27, 2017
  3. Eric SunshineNov 27, 2017
  4. Lars SchneiderNov 27, 2017
  5. brian m. carlsonNov 27, 2017
  6. Jeff KingNov 27, 2017
  7. Junio C HamanoNov 28, 2017
  8. Lars SchneiderNov 28, 2017
  9. brian m. carlsonNov 29, 2017
  10. Junio C HamanoNov 27, 2017
  11. Lars SchneiderNov 28, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.