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
45a86bbf
Commit
45a86bbf
authored
Mar 09, 2015
by
Jacques Germishuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow for merges with whitespace discrepancies
parent
d675982a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
include/git2/merge.h
+23
-0
src/merge.c
+8
-4
src/merge_file.c
+7
-0
No files found.
include/git2/merge.h
View file @
45a86bbf
...
...
@@ -111,6 +111,23 @@ typedef enum {
}
git_merge_file_favor_t
;
/**
* Whitespace merging flags
*/
typedef
enum
{
/** Defaults */
GIT_MERGE_FILE_IGNORE_DEFAULT
=
0
,
/** Ignore all whitespace */
GIT_MERGE_FILE_IGNORE_WHITESPACE
=
(
1
<<
0
),
/** Ignore changes in amount of whitespace */
GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE
=
(
1
<<
1
),
/** Ignore whitespace at end of line */
GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL
=
(
1
<<
2
),
}
git_merge_file_whitespace_t
;
/**
* File merging flags
*/
typedef
enum
{
...
...
@@ -156,6 +173,9 @@ typedef struct {
/** Merge file flags. */
git_merge_file_flags_t
flags
;
/** Whitespace merge flags */
unsigned
int
whitespace_flags
;
}
git_merge_file_options
;
#define GIT_MERGE_FILE_OPTIONS_VERSION 1
...
...
@@ -230,6 +250,9 @@ typedef struct {
/** Flags for handling conflicting content. */
git_merge_file_favor_t
file_favor
;
/** Flags for handling whitespace */
unsigned
int
whitespace_flags
;
}
git_merge_options
;
#define GIT_MERGE_OPTIONS_VERSION 1
...
...
src/merge.c
View file @
45a86bbf
...
...
@@ -653,7 +653,8 @@ static int merge_conflict_resolve_automerge(
int
*
resolved
,
git_merge_diff_list
*
diff_list
,
const
git_merge_diff
*
conflict
,
unsigned
int
merge_file_favor
)
unsigned
int
merge_file_favor
,
unsigned
int
whitespace_flags
)
{
const
git_index_entry
*
ancestor
=
NULL
,
*
ours
=
NULL
,
*
theirs
=
NULL
;
git_merge_file_options
opts
=
GIT_MERGE_FILE_OPTIONS_INIT
;
...
...
@@ -708,6 +709,7 @@ static int merge_conflict_resolve_automerge(
&
conflict
->
their_entry
:
NULL
;
opts
.
favor
=
merge_file_favor
;
opts
.
whitespace_flags
=
whitespace_flags
;
if
((
error
=
git_repository_odb
(
&
odb
,
diff_list
->
repo
))
<
0
||
(
error
=
git_merge_file_from_index
(
&
result
,
diff_list
->
repo
,
ancestor
,
ours
,
theirs
,
&
opts
))
<
0
||
...
...
@@ -741,7 +743,8 @@ static int merge_conflict_resolve(
int
*
out
,
git_merge_diff_list
*
diff_list
,
const
git_merge_diff
*
conflict
,
unsigned
int
merge_file_favor
)
unsigned
int
merge_file_favor
,
unsigned
int
whitespace_flags
)
{
int
resolved
=
0
;
int
error
=
0
;
...
...
@@ -757,7 +760,8 @@ static int merge_conflict_resolve(
if
(
!
resolved
&&
(
error
=
merge_conflict_resolve_one_renamed
(
&
resolved
,
diff_list
,
conflict
))
<
0
)
goto
done
;
if
(
!
resolved
&&
(
error
=
merge_conflict_resolve_automerge
(
&
resolved
,
diff_list
,
conflict
,
merge_file_favor
))
<
0
)
if
(
!
resolved
&&
(
error
=
merge_conflict_resolve_automerge
(
&
resolved
,
diff_list
,
conflict
,
merge_file_favor
,
whitespace_flags
))
<
0
)
goto
done
;
*
out
=
resolved
;
...
...
@@ -1779,7 +1783,7 @@ int git_merge_trees(
git_vector_foreach
(
&
changes
,
i
,
conflict
)
{
int
resolved
=
0
;
if
((
error
=
merge_conflict_resolve
(
&
resolved
,
diff_list
,
conflict
,
opts
.
file_favor
))
<
0
)
if
((
error
=
merge_conflict_resolve
(
&
resolved
,
diff_list
,
conflict
,
opts
.
file_favor
,
opts
.
whitespace_flags
))
<
0
)
goto
done
;
if
(
!
resolved
)
...
...
src/merge_file.c
View file @
45a86bbf
...
...
@@ -151,6 +151,13 @@ static int git_merge_file__from_inputs(
if
(
options
.
flags
&
GIT_MERGE_FILE_STYLE_DIFF3
)
xmparam
.
style
=
XDL_MERGE_DIFF3
;
if
(
options
.
whitespace_flags
&
GIT_MERGE_FILE_IGNORE_WHITESPACE
)
xmparam
.
xpp
.
flags
|=
XDF_IGNORE_WHITESPACE
;
if
(
options
.
whitespace_flags
&
GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE
)
xmparam
.
xpp
.
flags
|=
XDF_IGNORE_WHITESPACE_CHANGE
;
if
(
options
.
whitespace_flags
&
GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL
)
xmparam
.
xpp
.
flags
|=
XDF_IGNORE_WHITESPACE_AT_EOL
;
if
((
xdl_result
=
xdl_merge
(
&
ancestor_mmfile
,
&
our_mmfile
,
&
their_mmfile
,
&
xmparam
,
&
mmbuffer
))
<
0
)
{
giterr_set
(
GITERR_MERGE
,
"Failed to merge files."
);
...
...
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