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
cc605e73
Commit
cc605e73
authored
Jun 23, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3222 from git-up/conflicted
Fixed GIT_DELTA_CONFLICTED not returned in some cases
parents
09f3364d
8d8a2eef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
src/diff.c
+4
-2
tests/diff/index.c
+30
-1
No files found.
src/diff.c
View file @
cc605e73
...
...
@@ -1090,8 +1090,10 @@ static int handle_unmatched_new_item(
/* item contained in ignored directory, so skip over it */
return
iterator_advance
(
&
info
->
nitem
,
info
->
new_iter
);
else
if
(
info
->
new_iter
->
type
!=
GIT_ITERATOR_TYPE_WORKDIR
)
delta_type
=
GIT_DELTA_ADDED
;
else
if
(
info
->
new_iter
->
type
!=
GIT_ITERATOR_TYPE_WORKDIR
)
{
if
(
delta_type
!=
GIT_DELTA_CONFLICTED
)
delta_type
=
GIT_DELTA_ADDED
;
}
else
if
(
nitem
->
mode
==
GIT_FILEMODE_COMMIT
)
{
/* ignore things that are not actual submodules */
...
...
tests/diff/index.c
View file @
cc605e73
...
...
@@ -183,7 +183,7 @@ static void do_conflicted_diff(diff_expects *exp, unsigned long flags)
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
ancestor
.
path
=
ours
.
path
=
theirs
.
path
=
"staged_changes"
;
ancestor
.
mode
=
ours
.
mode
=
theirs
.
mode
=
0100644
;
ancestor
.
mode
=
ours
.
mode
=
theirs
.
mode
=
GIT_FILEMODE_BLOB
;
git_oid_fromstr
(
&
ancestor
.
id
,
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
);
git_oid_fromstr
(
&
ours
.
id
,
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
);
...
...
@@ -239,3 +239,32 @@ void test_diff_index__reports_conflicts_when_reversed(void)
cl_assert_equal_i
(
2
,
exp
.
line_adds
);
cl_assert_equal_i
(
5
,
exp
.
line_dels
);
}
void
test_diff_index__not_in_head_conflicted
(
void
)
{
const
char
*
a_commit
=
"26a125ee1bf"
;
/* the current HEAD */
git_index_entry
theirs
=
{{
0
}};
git_index
*
index
;
git_diff
*
diff
;
const
git_diff_delta
*
delta
;
git_tree
*
a
=
resolve_commit_oid_to_tree
(
g_repo
,
a_commit
);
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_index_read_tree
(
index
,
a
));
theirs
.
path
=
"file_not_in_head"
;
theirs
.
mode
=
GIT_FILEMODE_BLOB
;
git_oid_fromstr
(
&
theirs
.
id
,
"deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"
);
cl_git_pass
(
git_index_conflict_add
(
index
,
NULL
,
NULL
,
&
theirs
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
g_repo
,
a
,
index
,
NULL
));
cl_assert_equal_i
(
git_diff_num_deltas
(
diff
),
1
);
delta
=
git_diff_get_delta
(
diff
,
0
);
cl_assert_equal_i
(
delta
->
status
,
GIT_DELTA_CONFLICTED
);
git_diff_free
(
diff
);
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