Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Schneider <larsxschneider@gmail.com>2017-11-29 17:37:51 +0300
committerJunio C Hamano <gitster@pobox.com>2017-12-04 20:38:30 +0300
commita64f213d3fa13fa01e582b6734fe7883ed975dc9 (patch)
tree24b1b8f7e95c639ed5cf1c77f6bd6e7753e9a20a /editor.c
parent5a1f5c3060427375de30d609d72ac032516be4c2 (diff)
refactor "dumb" terminal determination
Move the code to detect "dumb" terminals into a single location. This avoids duplicating the terminal detection code yet again in a subsequent commit. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/editor.c b/editor.c
index 7519edecdc..c65ea698eb 100644
--- a/editor.c
+++ b/editor.c
@@ -7,11 +7,16 @@
#define DEFAULT_EDITOR "vi"
#endif
+int is_terminal_dumb(void)
+{
+ const char *terminal = getenv("TERM");
+ return !terminal || !strcmp(terminal, "dumb");
+}
+
const char *git_editor(void)
{
const char *editor = getenv("GIT_EDITOR");
- const char *terminal = getenv("TERM");
- int terminal_is_dumb = !terminal || !strcmp(terminal, "dumb");
+ int terminal_is_dumb = is_terminal_dumb();
if (!editor && editor_program)
editor = editor_program;