@@ -726,11 +726,13 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
726726 int clean_message_contents = (cleanup_mode != COMMIT_MSG_CLEANUP_NONE );
727727 int old_display_comment_prefix ;
728728 int merge_contains_scissors = 0 ;
729+ int invoked_hook ;
729730
730731 /* This checks and barfs if author is badly specified */
731732 determine_author_info (author_ident );
732733
733- if (!no_verify && run_commit_hook (use_editor , index_file , "pre-commit" , NULL ))
734+ if (!no_verify && run_commit_hook (use_editor , index_file , & invoked_hook ,
735+ "pre-commit" , NULL ))
734736 return 0 ;
735737
736738 if (squash_message ) {
@@ -1053,10 +1055,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
10531055 return 0 ;
10541056 }
10551057
1056- if (!no_verify && hook_exists ( "pre-commit" ) ) {
1058+ if (!no_verify && invoked_hook ) {
10571059 /*
1058- * Re-read the index as pre-commit hook could have updated it,
1059- * and write it out as a tree. We must do this before we invoke
1060+ * Re-read the index as the pre-commit-commit hook was invoked
1061+ * and could have updated it. We must do this before we invoke
10601062 * the editor and after we invoke run_status above.
10611063 */
10621064 discard_cache ();
@@ -1068,7 +1070,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
10681070 return 0 ;
10691071 }
10701072
1071- if (run_commit_hook (use_editor , index_file , "prepare-commit-msg" ,
1073+ if (run_commit_hook (use_editor , index_file , NULL , "prepare-commit-msg" ,
10721074 git_path_commit_editmsg (), hook_arg1 , hook_arg2 , NULL ))
10731075 return 0 ;
10741076
@@ -1085,7 +1087,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
10851087 }
10861088
10871089 if (!no_verify &&
1088- run_commit_hook (use_editor , index_file , "commit-msg" , git_path_commit_editmsg (), NULL )) {
1090+ run_commit_hook (use_editor , index_file , NULL , "commit-msg" ,
1091+ git_path_commit_editmsg (), NULL )) {
10891092 return 0 ;
10901093 }
10911094
@@ -1841,7 +1844,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
18411844
18421845 repo_rerere (the_repository , 0 );
18431846 run_auto_maintenance (quiet );
1844- run_commit_hook (use_editor , get_index_file (), "post-commit" , NULL );
1847+ run_commit_hook (use_editor , get_index_file (), NULL , "post-commit" ,
1848+ NULL );
18451849 if (amend && !no_post_rewrite ) {
18461850 commit_post_rewrite (the_repository , current_head , & oid );
18471851 }
0 commit comments