MCPcopy Create free account
hub / github.com/git/git / print_stat_summary_inserts_deletes

Function print_stat_summary_inserts_deletes

diff.c:2880–2919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2878}
2879
2880static void print_stat_summary_inserts_deletes(struct diff_options *options,
2881 int files, int insertions, int deletions)
2882{
2883 struct strbuf sb = STRBUF_INIT;
2884
2885 if (!files) {
2886 assert(insertions == 0 && deletions == 0);
2887 emit_diff_symbol(options, DIFF_SYMBOL_STATS_SUMMARY_NO_FILES,
2888 NULL, 0, 0);
2889 return;
2890 }
2891
2892 strbuf_addf(&sb,
2893 (files == 1) ? " %d file changed" : " %d files changed",
2894 files);
2895
2896 /*
2897 * For binary diff, the caller may want to print "x files
2898 * changed" with insertions == 0 && deletions == 0.
2899 *
2900 * Not omitting "0 insertions(+), 0 deletions(-)" in this case
2901 * is probably less confusing (i.e skip over "2 files changed
2902 * but nothing about added/removed lines? Is this a bug in Git?").
2903 */
2904 if (insertions || deletions == 0) {
2905 strbuf_addf(&sb,
2906 (insertions == 1) ? ", %d insertion(+)" : ", %d insertions(+)",
2907 insertions);
2908 }
2909
2910 if (deletions || insertions == 0) {
2911 strbuf_addf(&sb,
2912 (deletions == 1) ? ", %d deletion(-)" : ", %d deletions(-)",
2913 deletions);
2914 }
2915 strbuf_addch(&sb, '\n');
2916 emit_diff_symbol(options, DIFF_SYMBOL_STATS_SUMMARY_INSERTS_DELETES,
2917 sb.buf, sb.len, 0);
2918 strbuf_release(&sb);
2919}
2920
2921void print_stat_summary(FILE *fp, int files,
2922 int insertions, int deletions)

Callers 3

print_stat_summaryFunction · 0.85
show_statsFunction · 0.85
show_shortstatsFunction · 0.85

Calls 4

emit_diff_symbolFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected