mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 22:25:04 +00:00
Implement matched pattern extract for fn headers
This commit is contained in:
parent
9bbc53d6d4
commit
b8e86c62f7
@ -460,16 +460,21 @@ static int diff_context_line__simple(
|
||||
static int diff_context_line__pattern_match(
|
||||
git_diff_driver *driver, git_buf *line)
|
||||
{
|
||||
size_t i;
|
||||
size_t i, maxi = git_array_size(driver->fn_patterns);
|
||||
regmatch_t pmatch[2];
|
||||
|
||||
for (i = 0; i < git_array_size(driver->fn_patterns); ++i) {
|
||||
for (i = 0; i < maxi; ++i) {
|
||||
git_diff_driver_pattern *pat = git_array_get(driver->fn_patterns, i);
|
||||
|
||||
if (!regexec(&pat->re, line->ptr, 2, pmatch, 0)) {
|
||||
if (pat->flags & REG_NEGATE)
|
||||
return false;
|
||||
/* TODO: use pmatch data to trim line data */
|
||||
|
||||
/* use pmatch data to trim line data */
|
||||
i = (pmatch[1].rm_so >= 0) ? 1 : 0;
|
||||
git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so);
|
||||
git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void test_diff_drivers__patterns(void)
|
||||
|
||||
cl_git_pass(git_repository_config(&cfg, g_repo));
|
||||
cl_git_pass(git_config_set_bool(cfg, "diff.kipling0.binary", 0));
|
||||
cl_git_pass(git_config_set_string(cfg, "diff.kipling0.xfuncname", "^H"));
|
||||
cl_git_pass(git_config_set_string(cfg, "diff.kipling0.xfuncname", "^H.*$"));
|
||||
git_config_free(cfg);
|
||||
|
||||
cl_git_pass(git_diff_tree_to_workdir(&diff, g_repo, one, NULL));
|
||||
|
Loading…
Reference in New Issue
Block a user