@@ -775,10 +775,13 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
775775 }
776776 return 0 ; /* unknown %g placeholder */
777777 case 'N' :
778- format_display_notes (commit -> object .sha1 , sb ,
779- git_log_output_encoding ? git_log_output_encoding
780- : git_commit_encoding , 0 );
781- return 1 ;
778+ if (c -> pretty_ctx -> show_notes ) {
779+ format_display_notes (commit -> object .sha1 , sb ,
780+ git_log_output_encoding ? git_log_output_encoding
781+ : git_commit_encoding , 0 );
782+ return 1 ;
783+ }
784+ return 0 ;
782785 }
783786
784787 /* For the rest we have to parse the commit header. */
@@ -855,6 +858,35 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
855858 return consumed + 1 ;
856859}
857860
861+ static size_t userformat_want_item (struct strbuf * sb , const char * placeholder ,
862+ void * context )
863+ {
864+ struct userformat_want * w = context ;
865+
866+ if (* placeholder == '+' || * placeholder == '-' )
867+ placeholder ++ ;
868+
869+ switch (* placeholder ) {
870+ case 'N' :
871+ w -> notes = 1 ;
872+ break ;
873+ }
874+ return 0 ;
875+ }
876+
877+ void userformat_find_requirements (const char * fmt , struct userformat_want * w )
878+ {
879+ struct strbuf dummy = STRBUF_INIT ;
880+
881+ if (!fmt ) {
882+ if (!user_format )
883+ return ;
884+ fmt = user_format ;
885+ }
886+ strbuf_expand (& dummy , user_format , userformat_want_item , w );
887+ strbuf_release (& dummy );
888+ }
889+
858890void format_commit_message (const struct commit * commit ,
859891 const char * format , struct strbuf * sb ,
860892 const struct pretty_print_context * pretty_ctx )
0 commit comments