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
db3462ce
Commit
db3462ce
authored
Jan 19, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support union merges
parent
0e1ba46c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
0 deletions
+48
-0
include/git2/merge.h
+3
-0
src/merge_file.c
+2
-0
tests/merge/workdir/simple.c
+43
-0
No files found.
include/git2/merge.h
View file @
db3462ce
...
...
@@ -43,6 +43,9 @@ typedef enum {
/* Produce a file containing the "theirs" side of conflicting regions. */
GIT_MERGE_FILE_FAVOR_THEIRS
=
2
,
/* Produce a file blending the sides in a union of conflicting regions */
GIT_MERGE_FILE_FAVOR_UNION
=
3
,
}
git_merge_file_favor_t
;
...
...
src/merge_file.c
View file @
db3462ce
...
...
@@ -156,6 +156,8 @@ int git_merge_files(
xmparam
.
favor
=
XDL_MERGE_FAVOR_OURS
;
else
if
(
opts
&&
opts
->
favor
==
GIT_MERGE_FILE_FAVOR_THEIRS
)
xmparam
.
favor
=
XDL_MERGE_FAVOR_THEIRS
;
else
if
(
opts
&&
opts
->
favor
==
GIT_MERGE_FILE_FAVOR_UNION
)
xmparam
.
favor
=
XDL_MERGE_FAVOR_UNION
;
xmparam
.
level
=
(
opts
&&
(
opts
->
flags
&
GIT_MERGE_FILE_SIMPLIFY_ALNUM
))
?
...
...
tests/merge/workdir/simple.c
View file @
db3462ce
...
...
@@ -109,6 +109,10 @@ static git_index *repo_index;
"this file is changed in branch and master\n" \
">>>>>>> 7cb63eed597130ba4abb87b3e544b85021905520\n"
#define CONFLICTING_UNION_FILE \
"this file is changed in master and branch\n" \
"this file is changed in branch and master\n"
// Fixture setup and teardown
void
test_merge_workdir_simple__initialize
(
void
)
{
...
...
@@ -329,6 +333,45 @@ void test_merge_workdir_simple__diff3(void)
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__union
(
void
)
{
git_merge_result
*
result
;
git_buf
conflicting_buf
=
GIT_BUF_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
ADDED_IN_MASTER_INDEX_ENTRY
,
AUTOMERGEABLE_INDEX_ENTRY
,
CHANGED_IN_BRANCH_INDEX_ENTRY
,
CHANGED_IN_MASTER_INDEX_ENTRY
,
{
0100644
,
"72cdb057b340205164478565e91eb71647e66891"
,
0
,
"conflicting.txt"
},
UNCHANGED_INDEX_ENTRY
,
};
struct
merge_reuc_entry
merge_reuc_entries
[]
=
{
AUTOMERGEABLE_REUC_ENTRY
,
CONFLICTING_REUC_ENTRY
,
REMOVED_IN_BRANCH_REUC_ENTRY
,
REMOVED_IN_MASTER_REUC_ENTRY
};
set_core_autocrlf_to
(
repo
,
false
);
cl_assert
(
result
=
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_UNION
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
cl_git_pass
(
git_futils_readbuffer
(
&
conflicting_buf
,
TEST_REPO_PATH
"/conflicting.txt"
));
cl_assert
(
strcmp
(
conflicting_buf
.
ptr
,
CONFLICTING_UNION_FILE
)
==
0
);
git_buf_free
(
&
conflicting_buf
);
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
6
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
4
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__diff3_from_config
(
void
)
{
git_merge_result
*
result
;
...
...
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