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>
This commit is contained in:

committed by
Junio C Hamano

parent
5a1f5c3060
commit
a64f213d3f
9
editor.c
9
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;
|
||||
|
Reference in New Issue
Block a user