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
0c34fa50
Commit
0c34fa50
authored
Jun 23, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3228 from git-up/diff_merge
Explicitly handle GIT_DELTA_CONFLICTED in git_diff_merge()
parents
91c1833a
cb63e7e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
src/diff_tform.c
+11
-0
tests/diff/workdir.c
+36
-0
No files found.
src/diff_tform.c
View file @
0c34fa50
...
...
@@ -65,6 +65,12 @@ static git_diff_delta *diff_delta__merge_like_cgit(
* f3 = b->new_file
*/
/* If one of the diffs is a conflict, just dup it */
if
(
b
->
status
==
GIT_DELTA_CONFLICTED
)
return
diff_delta__dup
(
b
,
pool
);
if
(
a
->
status
==
GIT_DELTA_CONFLICTED
)
return
diff_delta__dup
(
a
,
pool
);
/* if f2 == f3 or f2 is deleted, then just dup the 'a' diff */
if
(
b
->
status
==
GIT_DELTA_UNMODIFIED
||
a
->
status
==
GIT_DELTA_DELETED
)
return
diff_delta__dup
(
a
,
pool
);
...
...
@@ -111,6 +117,11 @@ static git_diff_delta *diff_delta__merge_like_cgit_reversed(
/* reversed version of above logic */
if
(
a
->
status
==
GIT_DELTA_CONFLICTED
)
return
diff_delta__dup
(
a
,
pool
);
if
(
b
->
status
==
GIT_DELTA_CONFLICTED
)
return
diff_delta__dup
(
b
,
pool
);
if
(
a
->
status
==
GIT_DELTA_UNMODIFIED
)
return
diff_delta__dup
(
b
,
pool
);
...
...
tests/diff/workdir.c
View file @
0c34fa50
...
...
@@ -1745,3 +1745,39 @@ void test_diff_workdir__binary_detection(void)
git_index_free
(
idx
);
git_buf_free
(
&
b
);
}
void
test_diff_workdir__to_index_conflicted
(
void
)
{
const
char
*
a_commit
=
"26a125ee1bf"
;
/* the current HEAD */
git_index_entry
ancestor
=
{{
0
}},
ours
=
{{
0
}},
theirs
=
{{
0
}};
git_tree
*
a
;
git_index
*
index
;
git_diff
*
diff1
,
*
diff2
;
const
git_diff_delta
*
delta
;
g_repo
=
cl_git_sandbox_init
(
"status"
);
a
=
resolve_commit_oid_to_tree
(
g_repo
,
a_commit
);
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
ancestor
.
path
=
ours
.
path
=
theirs
.
path
=
"_file"
;
ancestor
.
mode
=
ours
.
mode
=
theirs
.
mode
=
0100644
;
git_oid_fromstr
(
&
ancestor
.
id
,
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
);
git_oid_fromstr
(
&
ours
.
id
,
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
);
git_oid_fromstr
(
&
theirs
.
id
,
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
);
cl_git_pass
(
git_index_conflict_add
(
index
,
&
ancestor
,
&
ours
,
&
theirs
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff1
,
g_repo
,
a
,
index
,
NULL
));
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff2
,
g_repo
,
index
,
NULL
));
cl_git_pass
(
git_diff_merge
(
diff1
,
diff2
));
cl_assert_equal_i
(
git_diff_num_deltas
(
diff1
),
12
);
delta
=
git_diff_get_delta
(
diff1
,
0
);
cl_assert_equal_s
(
delta
->
old_file
.
path
,
"_file"
);
cl_assert_equal_i
(
delta
->
nfiles
,
1
);
cl_assert_equal_i
(
delta
->
status
,
GIT_DELTA_CONFLICTED
);
git_diff_free
(
diff2
);
git_diff_free
(
diff1
);
git_index_free
(
index
);
git_tree_free
(
a
);
}
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