/** Display diff output with "--stat", "--numstat", or "--shortstat" */ static void diff_print_stats(git_diff *diff, struct opts *o) { git_diff_stats *stats; git_buf b = GIT_BUF_INIT_CONST(NULL, 0); git_diff_stats_format_t format = 0; check_lg2( git_diff_get_stats(&stats, diff), "generating stats for diff", NULL); if (o->output & OUTPUT_STAT) format |= GIT_DIFF_STATS_FULL; if (o->output & OUTPUT_SHORTSTAT) format |= GIT_DIFF_STATS_SHORT; if (o->output & OUTPUT_NUMSTAT) format |= GIT_DIFF_STATS_NUMBER; if (o->output & OUTPUT_SUMMARY) format |= GIT_DIFF_STATS_INCLUDE_SUMMARY; check_lg2( git_diff_stats_to_buf(&b, stats, format, 80), "formatting stats", NULL); fputs(b.ptr, stdout); git_buf_dispose(&b); git_diff_stats_free(stats); }
static int skip_bom(git_parse_ctx *parser) { git_buf buf = GIT_BUF_INIT_CONST(parser->content, parser->content_len); git_bom_t bom; int bom_offset = git_buf_text_detect_bom(&bom, &buf, parser->content_len); if (bom == GIT_BOM_UTF8) git_parse_advance_chars(parser, bom_offset); /* TODO: reference implementation is pretty stupid with BoM */ return 0; }
void test_filter_custom__to_odb(void) { git_filter_list *fl; git_buf out = { 0 }; git_buf in = GIT_BUF_INIT_CONST(workdir_data, strlen(workdir_data)); cl_git_pass(git_filter_list_load( &fl, g_repo, NULL, "herofile", GIT_FILTER_TO_ODB)); cl_git_pass(git_filter_list_apply_to_data(&out, fl, &in)); cl_assert_equal_i(BITFLIPPED_AND_REVERSED_DATA_LEN, out.size); cl_assert_equal_i( 0, memcmp(bitflipped_and_reversed_data, out.ptr, out.size)); git_filter_list_free(fl); git_buf_free(&out); }