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
d3f0875a
Commit
d3f0875a
authored
Dec 25, 2015
by
Edward Thomson
Committed by
Edward Thomson
Mar 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge driver: tests for custom default merge drivers
parent
30a94ab7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
tests/merge/driver.c
+59
-0
No files found.
tests/merge/driver.c
View file @
d3f0875a
...
...
@@ -391,3 +391,62 @@ void test_merge_driver__apply_can_conflict(void)
git_merge_driver_unregister
(
"conflict"
);
}
void
test_merge_driver__default_can_be_specified
(
void
)
{
git_oid
their_id
;
git_annotated_commit
*
their_head
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
const
char
*
expected
=
"This is the `custom` driver.
\n
"
;
merge_opts
.
default_driver
=
"custom"
;
cl_git_pass
(
git_oid_fromstr
(
&
their_id
,
BRANCH_ID
));
cl_git_pass
(
git_annotated_commit_lookup
(
&
their_head
,
repo
,
&
their_id
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_annotated_commit
**
)
&
their_head
,
1
,
&
merge_opts
,
NULL
));
git_annotated_commit_free
(
their_head
);
cl_assert_equal_file
(
expected
,
strlen
(
expected
),
TEST_REPO_PATH
"/applied.txt"
);
}
void
test_merge_driver__honors_builtin_mergedefault
(
void
)
{
const
git_index_entry
*
ancestor
,
*
ours
,
*
theirs
;
cl_repo_set_string
(
repo
,
"merge.default"
,
"binary"
);
merge_branch
();
cl_git_pass
(
git_index_conflict_get
(
&
ancestor
,
&
ours
,
&
theirs
,
repo_index
,
"automergeable.txt"
));
}
void
test_merge_driver__honors_custom_mergedefault
(
void
)
{
const
char
*
expected
=
"This is the `custom` driver.
\n
"
;
cl_repo_set_string
(
repo
,
"merge.default"
,
"custom"
);
merge_branch
();
cl_assert_equal_file
(
expected
,
strlen
(
expected
),
TEST_REPO_PATH
"/applied.txt"
);
}
void
test_merge_driver__mergedefault_deferring_falls_back_to_text
(
void
)
{
const
git_index_entry
*
idx
;
cl_git_pass
(
git_merge_driver_register
(
"defer"
,
&
test_driver_defer_check
.
base
));
cl_repo_set_string
(
repo
,
"merge.default"
,
"defer"
);
merge_branch
();
cl_assert
((
idx
=
git_index_get_bypath
(
repo_index
,
"automergeable.txt"
,
0
)));
cl_assert_equal_oid
(
&
automergeable_id
,
&
idx
->
id
);
git_merge_driver_unregister
(
"defer"
);
}
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