aboutsummaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
authorLars Schneider <larsxschneider@gmail.com>2017-11-29 15:37:51 +0100
committerJunio C Hamano <gitster@pobox.com>2017-12-04 09:38:30 -0800
commita64f213d3fa13fa01e582b6734fe7883ed975dc9 (patch)
tree24b1b8f7e95c639ed5cf1c77f6bd6e7753e9a20a /editor.c
parent5a1f5c3060427375de30d609d72ac032516be4c2 (diff)
downloadgit-a64f213d3fa13fa01e582b6734fe7883ed975dc9.tar.gz
git-a64f213d3fa13fa01e582b6734fe7883ed975dc9.tar.xz
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 7519edecd..c65ea698e 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;