@@ -438,8 +438,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
438438 hook_arg1 = "message" ;
439439 } else if (logfile ) {
440440 if (strbuf_read_file (& sb , logfile , 0 ) < 0 )
441- die ("could not read log file '%s': %s " ,
442- logfile , strerror ( errno ) );
441+ die_errno ("could not read log file '%s'" ,
442+ logfile );
443443 hook_arg1 = "message" ;
444444 } else if (use_message ) {
445445 buffer = strstr (use_message_buffer , "\n\n" );
@@ -450,16 +450,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
450450 hook_arg2 = use_message ;
451451 } else if (!stat (git_path ("MERGE_MSG" ), & statbuf )) {
452452 if (strbuf_read_file (& sb , git_path ("MERGE_MSG" ), 0 ) < 0 )
453- die ("could not read MERGE_MSG: %s" , strerror ( errno ) );
453+ die_errno ("could not read MERGE_MSG" );
454454 hook_arg1 = "merge" ;
455455 } else if (!stat (git_path ("SQUASH_MSG" ), & statbuf )) {
456456 if (strbuf_read_file (& sb , git_path ("SQUASH_MSG" ), 0 ) < 0 )
457- die ("could not read SQUASH_MSG: %s" , strerror ( errno ) );
457+ die_errno ("could not read SQUASH_MSG" );
458458 hook_arg1 = "squash" ;
459459 } else if (template_file && !stat (template_file , & statbuf )) {
460460 if (strbuf_read_file (& sb , template_file , 0 ) < 0 )
461- die ("could not read %s: %s" ,
462- template_file , strerror (errno ));
461+ die_errno ("could not read '%s'" , template_file );
463462 hook_arg1 = "template" ;
464463 }
465464
@@ -472,8 +471,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
472471
473472 fp = fopen (git_path (commit_editmsg ), "w" );
474473 if (fp == NULL )
475- die ("could not open %s: %s" ,
476- git_path (commit_editmsg ), strerror (errno ));
474+ die_errno ("could not open '%s'" , git_path (commit_editmsg ));
477475
478476 if (cleanup_mode != CLEANUP_NONE )
479477 stripspace (& sb , 0 );
@@ -497,7 +495,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
497495 }
498496
499497 if (fwrite (sb .buf , 1 , sb .len , fp ) < sb .len )
500- die ("could not write commit template: %s" , strerror ( errno ) );
498+ die_errno ("could not write commit template" );
501499
502500 strbuf_release (& sb );
503501
@@ -940,8 +938,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
940938 pptr = & commit_list_insert (lookup_commit (head_sha1 ), pptr )-> next ;
941939 fp = fopen (git_path ("MERGE_HEAD" ), "r" );
942940 if (fp == NULL )
943- die ("could not open %s for reading: %s " ,
944- git_path ("MERGE_HEAD" ), strerror ( errno ));
941+ die_errno ("could not open '%s' for reading" ,
942+ git_path ("MERGE_HEAD" ));
945943 while (strbuf_getline (& m , fp , '\n' ) != EOF ) {
946944 unsigned char sha1 [20 ];
947945 if (get_sha1_hex (m .buf , sha1 ) < 0 )
@@ -952,8 +950,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
952950 strbuf_release (& m );
953951 if (!stat (git_path ("MERGE_MODE" ), & statbuf )) {
954952 if (strbuf_read_file (& sb , git_path ("MERGE_MODE" ), 0 ) < 0 )
955- die ("could not read MERGE_MODE: %s" ,
956- strerror (errno ));
953+ die_errno ("could not read MERGE_MODE" );
957954 if (!strcmp (sb .buf , "no-ff" ))
958955 allow_fast_forward = 0 ;
959956 }
0 commit comments