diff options
author | Lars Schneider <larsxschneider@gmail.com> | 2017-11-29 15:37:51 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-12-04 09:38:30 -0800 |
commit | a64f213d3fa13fa01e582b6734fe7883ed975dc9 (patch) | |
tree | 24b1b8f7e95c639ed5cf1c77f6bd6e7753e9a20a /editor.c | |
parent | 5a1f5c3060427375de30d609d72ac032516be4c2 (diff) | |
download | git-a64f213d3fa13fa01e582b6734fe7883ed975dc9.tar.gz |
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.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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; |