@@ -438,8 +438,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
438
438
hook_arg1 = "message" ;
439
439
} else if (logfile ) {
440
440
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 );
443
443
hook_arg1 = "message" ;
444
444
} else if (use_message ) {
445
445
buffer = strstr (use_message_buffer , "\n\n" );
@@ -450,16 +450,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
450
450
hook_arg2 = use_message ;
451
451
} else if (!stat (git_path ("MERGE_MSG" ), & statbuf )) {
452
452
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" );
454
454
hook_arg1 = "merge" ;
455
455
} else if (!stat (git_path ("SQUASH_MSG" ), & statbuf )) {
456
456
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" );
458
458
hook_arg1 = "squash" ;
459
459
} else if (template_file && !stat (template_file , & statbuf )) {
460
460
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 );
463
462
hook_arg1 = "template" ;
464
463
}
465
464
@@ -472,8 +471,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
472
471
473
472
fp = fopen (git_path (commit_editmsg ), "w" );
474
473
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 ));
477
475
478
476
if (cleanup_mode != CLEANUP_NONE )
479
477
stripspace (& sb , 0 );
@@ -497,7 +495,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
497
495
}
498
496
499
497
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" );
501
499
502
500
strbuf_release (& sb );
503
501
@@ -940,8 +938,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
940
938
pptr = & commit_list_insert (lookup_commit (head_sha1 ), pptr )-> next ;
941
939
fp = fopen (git_path ("MERGE_HEAD" ), "r" );
942
940
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" ));
945
943
while (strbuf_getline (& m , fp , '\n' ) != EOF ) {
946
944
unsigned char sha1 [20 ];
947
945
if (get_sha1_hex (m .buf , sha1 ) < 0 )
@@ -952,8 +950,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
952
950
strbuf_release (& m );
953
951
if (!stat (git_path ("MERGE_MODE" ), & statbuf )) {
954
952
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" );
957
954
if (!strcmp (sb .buf , "no-ff" ))
958
955
allow_fast_forward = 0 ;
959
956
}
0 commit comments