From: lars.schneider@autodesk.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, sbeller@google.com,
Lars Schneider <larsxschneider@gmail.com>
Subject: [PATCH v2] launch_editor(): indicate that Git waits for user input
Date: Fri, 17 Nov 2017 14:51:09 +0100 [thread overview]
Message-ID: <20171117135109.18071-1-lars.schneider@autodesk.com> (raw)
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
next reply other threads:[~2017-11-17 13:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 13:51 lars.schneider [this message]
2017-11-17 18:40 ` [PATCH v2] launch_editor(): indicate that Git waits for user input 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
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=20171117135109.18071-1-lars.schneider@autodesk.com \
--to=lars.schneider@autodesk.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=larsxschneider@gmail.com \
--cc=sbeller@google.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).