@@ -1109,6 +1109,33 @@ static void write_merge_state(void)
11091109 close (fd );
11101110}
11111111
1112+ static int default_edit_option (void )
1113+ {
1114+ static const char name [] = "GIT_MERGE_AUTOEDIT" ;
1115+ const char * e = getenv (name );
1116+ struct stat st_stdin , st_stdout ;
1117+
1118+ if (have_message )
1119+ /* an explicit -m msg without --[no-]edit */
1120+ return 0 ;
1121+
1122+ if (e ) {
1123+ int v = git_config_maybe_bool (name , e );
1124+ if (v < 0 )
1125+ die ("Bad value '%s' in environment '%s'" , e , name );
1126+ return v ;
1127+ }
1128+
1129+ /* Use editor if stdin and stdout are the same and is a tty */
1130+ return (!fstat (0 , & st_stdin ) &&
1131+ !fstat (1 , & st_stdout ) &&
1132+ isatty (0 ) && isatty (1 ) &&
1133+ st_stdin .st_dev == st_stdout .st_dev &&
1134+ st_stdin .st_ino == st_stdout .st_ino &&
1135+ st_stdin .st_mode == st_stdout .st_mode );
1136+ }
1137+
1138+
11121139int cmd_merge (int argc , const char * * argv , const char * prefix )
11131140{
11141141 unsigned char result_tree [20 ];
@@ -1298,7 +1325,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
12981325 merge_remote_util (commit )-> obj &&
12991326 merge_remote_util (commit )-> obj -> type == OBJ_TAG ) {
13001327 if (option_edit < 0 )
1301- option_edit = 1 ;
1328+ option_edit = default_edit_option () ;
13021329 allow_fast_forward = 0 ;
13031330 }
13041331 }
0 commit comments