File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -1438,6 +1438,7 @@ extern const char *ident_default_name(void);
14381438extern const char * ident_default_email (void );
14391439extern const char * git_editor (void );
14401440extern const char * git_pager (int stdout_is_tty );
1441+ extern int is_terminal_dumb (void );
14411442extern int git_ident_config (const char * , const char * , void * );
14421443extern void reset_ident_date (void );
14431444
Original file line number Diff line number Diff line change @@ -329,8 +329,7 @@ static int check_auto_color(void)
329329 if (color_stdout_is_tty < 0 )
330330 color_stdout_is_tty = isatty (1 );
331331 if (color_stdout_is_tty || (pager_in_use () && pager_use_color )) {
332- char * term = getenv ("TERM" );
333- if (term && strcmp (term , "dumb" ))
332+ if (!is_terminal_dumb ())
334333 return 1 ;
335334 }
336335 return 0 ;
Original file line number Diff line number Diff line change 77#define DEFAULT_EDITOR "vi"
88#endif
99
10+ int is_terminal_dumb (void )
11+ {
12+ const char * terminal = getenv ("TERM" );
13+ return !terminal || !strcmp (terminal , "dumb" );
14+ }
15+
1016const char * git_editor (void )
1117{
1218 const char * editor = getenv ("GIT_EDITOR" );
13- const char * terminal = getenv ("TERM" );
14- int terminal_is_dumb = !terminal || !strcmp (terminal , "dumb" );
19+ int terminal_is_dumb = is_terminal_dumb ();
1520
1621 if (!editor && editor_program )
1722 editor = editor_program ;
Original file line number Diff line number Diff line change 2020
2121int recv_sideband (const char * me , int in_stream , int out )
2222{
23- const char * term , * suffix ;
23+ const char * suffix ;
2424 char buf [LARGE_PACKET_MAX + 1 ];
2525 struct strbuf outbuf = STRBUF_INIT ;
2626 int retval = 0 ;
2727
28- term = getenv ("TERM" );
29- if (isatty (2 ) && term && strcmp (term , "dumb" ))
28+ if (isatty (2 ) && !is_terminal_dumb ())
3029 suffix = ANSI_SUFFIX ;
3130 else
3231 suffix = DUMB_SUFFIX ;
You can’t perform that action at this time.
0 commit comments