Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
b8e86c62
Commit
b8e86c62
authored
Jan 21, 2014
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement matched pattern extract for fn headers
parent
9bbc53d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
src/diff_driver.c
+8
-3
tests/diff/drivers.c
+2
-2
No files found.
src/diff_driver.c
View file @
b8e86c62
...
...
@@ -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
;
}
}
...
...
tests/diff/drivers.c
View file @
b8e86c62
...
...
@@ -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
));
...
...
@@ -196,7 +196,7 @@ void test_diff_drivers__builtins(void)
const
char
*
expected_nodriver
=
"diff --git a/file.html b/file.html
\n
index 97b34db..c7dbed3 100644
\n
--- a/file.html
\n
+++ b/file.html
\n
@@ -5,4 +5,4 @@
\n
<li>item 1.1</li>
\n
- <li>item 1.2</li>
\n
- <li>item 1.3</li>
\n
+ <li>item 1.2 changed</li>
\n
+ <li>item 1.3 changed</li>
\n
<li>item 1.4</li>
\n
@@ -13,2 +13,3 @@
\n
<li>item 1.9</li>
\n
+ <li>item 1.10 added</li>
\n
</ol>
\n
@@ -23,3 +24,4 @@
\n
<li>item 2.6</li>
\n
- <li>item 2.7</li>
\n
+ <li>item 2.7 changed</li>
\n
+ <li>item 2.7.1 added</li>
\n
<li>item 2.8</li>
\n
@@ -35,4 +37,2 @@
\n
<li>item 3.6</li>
\n
- <li>item 3.7</li>
\n
- <li>item 3.8</li>
\n
</ol>
\n
"
;
const
char
*
expected_driver
=
"diff --git a/file.html b/file.html
\n
index 97b34db..c7dbed3 100644
\n
--- a/file.html
\n
+++ b/file.html
\n
@@ -5,4 +5,4 @@
<h1 id=
\"
first section
\"
>
\n
<li>item 1.1</li>
\n
- <li>item 1.2</li>
\n
- <li>item 1.3</li>
\n
+ <li>item 1.2 changed</li>
\n
+ <li>item 1.3 changed</li>
\n
<li>item 1.4</li>
\n
@@ -13,2 +13,3 @@ <h1 id=
\"
first section
\"
>
\n
<li>item 1.9</li>
\n
+ <li>item 1.10 added</li>
\n
</ol>
\n
@@ -23,3 +24,4 @@ <h1 id=
\"
second section
\"
>
\n
<li>item 2.6</li>
\n
- <li>item 2.7</li>
\n
+ <li>item 2.7 changed</li>
\n
+ <li>item 2.7.1 added</li>
\n
<li>item 2.8</li>
\n
@@ -35,4 +37,2 @@
<h1 id=
\"
third section
\"
>
\n
<li>item 3.6</li>
\n
- <li>item 3.7</li>
\n
- <li>item 3.8</li>
\n
</ol>
\n
"
;
"diff --git a/file.html b/file.html
\n
index 97b34db..c7dbed3 100644
\n
--- a/file.html
\n
+++ b/file.html
\n
@@ -5,4 +5,4 @@
<h1 id=
\"
first section
\"
>
\n
<li>item 1.1</li>
\n
- <li>item 1.2</li>
\n
- <li>item 1.3</li>
\n
+ <li>item 1.2 changed</li>
\n
+ <li>item 1.3 changed</li>
\n
<li>item 1.4</li>
\n
@@ -13,2 +13,3 @@ <h1 id=
\"
first section
\"
>
\n
<li>item 1.9</li>
\n
+ <li>item 1.10 added</li>
\n
</ol>
\n
@@ -23,3 +24,4 @@ <h1 id=
\"
second section
\"
>
\n
<li>item 2.6</li>
\n
- <li>item 2.7</li>
\n
+ <li>item 2.7 changed</li>
\n
+ <li>item 2.7.1 added</li>
\n
<li>item 2.8</li>
\n
@@ -35,4 +37,2 @@
<h1 id=
\"
third section
\"
>
\n
<li>item 3.6</li>
\n
- <li>item 3.7</li>
\n
- <li>item 3.8</li>
\n
</ol>
\n
"
;
g_repo
=
cl_git_sandbox_init
(
"empty_standard_repo"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment