Branch Coverage

deps/libgit2/src/diff_driver.c
Criterion Covered Total %
branch 15 178 8.4


line true false branch
65 0 0 if (!reg)
68 0 0 if (git_strmap_new(®->drivers) < 0) {
80 44 0 if (!reg)
83 0 0 git_strmap_foreach_value(reg->drivers, drv, git_diff_driver_free(drv));
96 0 0 for (scan = regex_str; scan; scan = end) {
98 0 0 if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) {
0 0 if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) {
0 0 if ((pat = git_array_alloc(drv->fn_patterns)) == NULL) {
103 0 0 if (*scan == '!') {
108 0 0 if ((end = strchr(scan, '\n')) != NULL) {
114 0 0 if (error < 0)
124 0 0 if (error && pat != NULL)
0 0 if (error && pat != NULL)
125 0 0 (void)git_array_pop(drv->fn_patterns); /* release last item */
145 0 0 if (!repo->diff_drivers) {
149 0 0 if (reg != NULL) /* if we race, free losing allocation */
153 0 0 if (!repo->diff_drivers)
167 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, driverlen, namelen);
168 0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
0 0 GIT_ERROR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
171 0 0 GIT_ERROR_CHECK_ALLOC(driver);
177 0 0 if (namelen_out)
193 0 0 for (idx = 0; idx < ARRAY_SIZE(builtin_defs); ++idx) {
194 0 0 if (!strcasecmp(driver_name, builtin_defs[idx].name)) {
199 0 0 if (!ddef)
202 0 0 if ((error = diff_driver_alloc(&drv, NULL, ddef->name)) < 0)
207 0 0 if (ddef->fns &&
0 0 if (ddef->fns &&
212 0 0 if (ddef->words &&
0 0 if (ddef->words &&
216 0 0 if ((error = git_strmap_set(reg->drivers, drv->name, drv)) < 0)
220 0 0 if (error && drv)
0 0 if (error && drv)
240 0 0 if ((reg = git_repository_driver_registry(repo)) == NULL)
243 0 0 if ((drv = git_strmap_get(reg->drivers, driver_name)) != NULL) {
248 0 0 if ((error = diff_driver_alloc(&drv, &namelen, driver_name)) < 0)
254 0 0 if (git_repository_config_snapshot(&cfg, repo) < 0) {
259 0 0 if ((error = git_buf_printf(&name, "diff.%s.binary", driver_name)) < 0)
281 0 0 if ((error = git_buf_PUTS(&name, "xfuncname")) < 0)
284 0 0 if ((error = git_config_get_multivar_foreach(
286 0 0 if (error != GIT_ENOTFOUND)
292 0 0 if ((error = git_buf_PUTS(&name, "funcname")) < 0)
295 0 0 if ((error = git_config_get_multivar_foreach(
297 0 0 if (error != GIT_ENOTFOUND)
303 0 0 if (git_array_size(drv->fn_patterns) > 0) {
309 0 0 if ((error = git_buf_PUTS(&name, "wordregex")) < 0)
312 0 0 if ((error = git_config__lookup_entry(&ce, cfg, name.ptr, false)) < 0)
314 0 0 if (!ce || !ce->value)
0 0 if (!ce || !ce->value)
316 0 0 else if (!(error = git_regexp_compile(&drv->word_pattern, ce->value, 0)))
328 0 0 if (!found_driver)
332 0 0 if ((error = git_strmap_set(reg->drivers, drv->name, drv)) < 0)
342 0 0 if (!*out) {
344 0 0 if (!error)
348 0 0 if (drv && drv != *out)
0 0 if (drv && drv != *out)
361 0 100 assert(out);
364 100 0 if (!repo || !path || !strlen(path))
100 0 if (!repo || !path || !strlen(path))
100 0 if (!repo || !path || !strlen(path))
366 100 0 else if ((error = git_attr_get_many_with_session(values, repo,
370 0 100 else if (GIT_ATTR_IS_UNSPECIFIED(values[0]))
372 0 0 else if (GIT_ATTR_IS_FALSE(values[0]))
374 0 0 else if (GIT_ATTR_IS_TRUE(values[0]))
378 0 0 else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) {
379 0 0 if (error == GIT_ENOTFOUND) {
385 100 0 if (!*out)
395 0 0 if (!driver)
398 0 0 for (i = 0; i < git_array_size(driver->fn_patterns); ++i)
399 0 0 git_regexp_dispose(& git_array_get(driver->fn_patterns, i)->re);
410 96 4 if ((*option_flags & FORCE_DIFFABLE) == 0)
432 0 60 if (git_buf_text_contains_nul(&search))
443 0 0 return (git__isalpha(firstch) || firstch == '_' || firstch == '$');
0 0 return (git__isalpha(firstch) || firstch == '_' || firstch == '$');
0 0 return (git__isalpha(firstch) || firstch == '_' || firstch == '$');
452 0 0 for (i = 0; i < maxi; ++i) {
453 0 0 git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i);
455 0 0 if (!git_regexp_search(&pat->re, line->ptr, 2, pmatch)) {
456 0 0 if (pat->flags & REG_NEGATE)
481 0 0 if (git_buf_set(&ctxt->line, line, (size_t)line_len) < 0)
485 0 0 if (!ctxt->line.size)
488 0 0 if (!ctxt->match_line || !ctxt->match_line(ctxt->driver, &ctxt->line))
0 0 if (!ctxt->match_line || !ctxt->match_line(ctxt->driver, &ctxt->line))
491 0 0 if (out_size > (long)ctxt->line.size)
503 38 0 *findfn_out = driver ? diff_context_find : NULL;
506 38 0 if (driver) {
509 0 38 diff_context_line__pattern_match : diff_context_line__simple;
516 38 0 if (payload) {