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
620ac9c2
Commit
620ac9c2
authored
Apr 11, 2017
by
Jason Haslam
Committed by
Edward Thomson
Nov 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patch: add tests for aborting hunk callback
parent
72630572
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
tests/apply/partial.c
+71
-0
No files found.
tests/apply/partial.c
View file @
620ac9c2
...
...
@@ -46,6 +46,33 @@ static int skip_change(
return
(
hunk
->
new_lines
==
hunk
->
old_lines
)
?
1
:
0
;
}
static
int
abort_addition
(
const
git_diff_hunk
*
hunk
,
void
*
payload
)
{
GIT_UNUSED
(
payload
);
return
(
hunk
->
new_lines
>
hunk
->
old_lines
)
?
GIT_EUSER
:
0
;
}
static
int
abort_deletion
(
const
git_diff_hunk
*
hunk
,
void
*
payload
)
{
GIT_UNUSED
(
payload
);
return
(
hunk
->
new_lines
<
hunk
->
old_lines
)
?
GIT_EUSER
:
0
;
}
static
int
abort_change
(
const
git_diff_hunk
*
hunk
,
void
*
payload
)
{
GIT_UNUSED
(
payload
);
return
(
hunk
->
new_lines
==
hunk
->
old_lines
)
?
GIT_EUSER
:
0
;
}
static
int
apply_buf
(
const
char
*
old
,
const
char
*
oldname
,
...
...
@@ -103,6 +130,17 @@ void test_apply_partial__prepend_and_change_nocontext_skip_addition(void)
FILE_CHANGE_MIDDLE
,
&
diff_opts
,
skip_addition
,
NULL
));
}
void
test_apply_partial__prepend_and_change_nocontext_abort_addition
(
void
)
{
git_diff_options
diff_opts
=
GIT_DIFF_OPTIONS_INIT
;
diff_opts
.
context_lines
=
0
;
cl_git_fail
(
apply_buf
(
FILE_ORIGINAL
,
"file.txt"
,
FILE_PREPEND_AND_CHANGE
,
"file.txt"
,
FILE_ORIGINAL
,
&
diff_opts
,
abort_addition
,
NULL
));
}
void
test_apply_partial__prepend_and_change_skip_change
(
void
)
{
cl_git_pass
(
apply_buf
(
...
...
@@ -122,6 +160,17 @@ void test_apply_partial__prepend_and_change_nocontext_skip_change(void)
FILE_PREPEND
,
&
diff_opts
,
skip_change
,
NULL
));
}
void
test_apply_partial__prepend_and_change_nocontext_abort_change
(
void
)
{
git_diff_options
diff_opts
=
GIT_DIFF_OPTIONS_INIT
;
diff_opts
.
context_lines
=
0
;
cl_git_fail
(
apply_buf
(
FILE_ORIGINAL
,
"file.txt"
,
FILE_PREPEND_AND_CHANGE
,
"file.txt"
,
FILE_PREPEND
,
&
diff_opts
,
abort_change
,
NULL
));
}
void
test_apply_partial__delete_and_change_skip_deletion
(
void
)
{
cl_git_pass
(
apply_buf
(
...
...
@@ -141,6 +190,17 @@ void test_apply_partial__delete_and_change_nocontext_skip_deletion(void)
FILE_CHANGE_MIDDLE
,
&
diff_opts
,
skip_deletion
,
NULL
));
}
void
test_apply_partial__delete_and_change_nocontext_abort_deletion
(
void
)
{
git_diff_options
diff_opts
=
GIT_DIFF_OPTIONS_INIT
;
diff_opts
.
context_lines
=
0
;
cl_git_fail
(
apply_buf
(
FILE_ORIGINAL
,
"file.txt"
,
FILE_DELETE_AND_CHANGE
,
"file.txt"
,
FILE_ORIGINAL
,
&
diff_opts
,
abort_deletion
,
NULL
));
}
void
test_apply_partial__delete_and_change_skip_change
(
void
)
{
cl_git_pass
(
apply_buf
(
...
...
@@ -159,3 +219,14 @@ void test_apply_partial__delete_and_change_nocontext_skip_change(void)
FILE_DELETE_AND_CHANGE
,
"file.txt"
,
FILE_DELETE_FIRSTLINE
,
&
diff_opts
,
skip_change
,
NULL
));
}
void
test_apply_partial__delete_and_change_nocontext_abort_change
(
void
)
{
git_diff_options
diff_opts
=
GIT_DIFF_OPTIONS_INIT
;
diff_opts
.
context_lines
=
0
;
cl_git_fail
(
apply_buf
(
FILE_ORIGINAL
,
"file.txt"
,
FILE_DELETE_AND_CHANGE
,
"file.txt"
,
FILE_DELETE_FIRSTLINE
,
&
diff_opts
,
abort_change
,
NULL
));
}
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