summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-11-16 14:51:38 +0900
committerJunio C Hamano <gitster@pobox.com>2017-11-17 11:55:22 +0900
commitdbe74871995912004bfa24d22c01205d4a8aa1cf (patch)
tree68dcd9d0d762520a58b74b8b052574fcd3c5c3e5
parent5a1f5c3060427375de30d609d72ac032516be4c2 (diff)
downloadgit-jc/editor-waiting-message.tar.gz
launch_editor(): indicate that Git waits for user inputjc/editor-waiting-message
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 such a 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>
-rw-r--r--editor.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/editor.c b/editor.c
index 7519edecdc..9663593f80 100644
--- a/editor.c
+++ b/editor.c
@@ -40,6 +40,28 @@ 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, "Waiting for you to finish editing...");
+ fflush(stderr);
+ }
p.argv = args;
p.env = env;
@@ -58,6 +80,8 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
if (ret)
return error("There was a problem with the editor '%s'.",
editor);
+ if (close_notice)
+ fputs(close_notice, stderr);
}
if (!buffer)