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
d67f270e
Commit
d67f270e
authored
May 14, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index: validate mode of new conflicts
parent
3ab5a659
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletions
+23
-1
src/index.c
+9
-0
tests/index/conflicts.c
+8
-1
tests/status/worktree.c
+6
-0
No files found.
src/index.c
View file @
d67f270e
...
...
@@ -1317,6 +1317,15 @@ int git_index_conflict_add(git_index *index,
(
ret
=
index_entry_dup
(
&
entries
[
2
],
INDEX_OWNER
(
index
),
their_entry
))
<
0
)
goto
on_error
;
/* Validate entries */
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
entries
[
i
]
&&
!
valid_filemode
(
entries
[
i
]
->
mode
))
{
giterr_set
(
GITERR_INDEX
,
"invalid filemode for stage %d entry"
,
i
);
return
-
1
;
}
}
/* Remove existing index entries for each path */
for
(
i
=
0
;
i
<
3
;
i
++
)
{
if
(
entries
[
i
]
==
NULL
)
...
...
tests/index/conflicts.c
View file @
d67f270e
...
...
@@ -47,14 +47,17 @@ void test_index_conflicts__add(void)
memset
(
&
their_entry
,
0x0
,
sizeof
(
git_index_entry
));
ancestor_entry
.
path
=
"test-one.txt"
;
ancestor_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
1
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
ancestor_entry
.
id
,
TEST_ANCESTOR_OID
);
our_entry
.
path
=
"test-one.txt"
;
our_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
2
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
our_entry
.
id
,
TEST_OUR_OID
);
their_entry
.
path
=
"test-one.txt"
;
their_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
3
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
their_entry
.
id
,
TEST_THEIR_OID
);
...
...
@@ -75,14 +78,17 @@ void test_index_conflicts__add_fixes_incorrect_stage(void)
memset
(
&
their_entry
,
0x0
,
sizeof
(
git_index_entry
));
ancestor_entry
.
path
=
"test-one.txt"
;
ancestor_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
3
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
ancestor_entry
.
id
,
TEST_ANCESTOR_OID
);
our_entry
.
path
=
"test-one.txt"
;
our_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
1
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
our_entry
.
id
,
TEST_OUR_OID
);
their_entry
.
path
=
"test-one.txt"
;
their_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
2
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
their_entry
.
id
,
TEST_THEIR_OID
);
...
...
@@ -109,8 +115,8 @@ void test_index_conflicts__add_removes_stage_zero(void)
memset
(
&
our_entry
,
0x0
,
sizeof
(
git_index_entry
));
memset
(
&
their_entry
,
0x0
,
sizeof
(
git_index_entry
));
staged
.
mode
=
0100644
;
staged
.
path
=
"test-one.txt"
;
staged
.
mode
=
0100644
;
git_oid_fromstr
(
&
staged
.
id
,
TEST_STAGED_OID
);
cl_git_pass
(
git_index_add
(
repo_index
,
&
staged
));
cl_assert
(
git_index_entrycount
(
repo_index
)
==
9
);
...
...
@@ -322,6 +328,7 @@ void test_index_conflicts__partial(void)
memset
(
&
their_entry
,
0x0
,
sizeof
(
git_index_entry
));
ancestor_entry
.
path
=
"test-one.txt"
;
ancestor_entry
.
mode
=
0100644
;
ancestor_entry
.
flags
|=
(
1
<<
GIT_IDXENTRY_STAGESHIFT
);
git_oid_fromstr
(
&
ancestor_entry
.
id
,
TEST_ANCESTOR_OID
);
...
...
tests/status/worktree.c
View file @
d67f270e
...
...
@@ -461,14 +461,17 @@ void test_status_worktree__conflict_with_diff3(void)
memset
(
&
their_entry
,
0x0
,
sizeof
(
git_index_entry
));
ancestor_entry
.
path
=
"modified_file"
;
ancestor_entry
.
mode
=
0100644
;
git_oid_fromstr
(
&
ancestor_entry
.
id
,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a"
);
our_entry
.
path
=
"modified_file"
;
our_entry
.
mode
=
0100644
;
git_oid_fromstr
(
&
our_entry
.
id
,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a"
);
their_entry
.
path
=
"modified_file"
;
their_entry
.
mode
=
0100644
;
git_oid_fromstr
(
&
their_entry
.
id
,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a"
);
...
...
@@ -614,14 +617,17 @@ void test_status_worktree__conflicted_item(void)
memset
(
&
our_entry
,
0x0
,
sizeof
(
git_index_entry
));
memset
(
&
their_entry
,
0x0
,
sizeof
(
git_index_entry
));
ancestor_entry
.
mode
=
0100644
;
ancestor_entry
.
path
=
"modified_file"
;
git_oid_fromstr
(
&
ancestor_entry
.
id
,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a"
);
our_entry
.
mode
=
0100644
;
our_entry
.
path
=
"modified_file"
;
git_oid_fromstr
(
&
our_entry
.
id
,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a"
);
their_entry
.
mode
=
0100644
;
their_entry
.
path
=
"modified_file"
;
git_oid_fromstr
(
&
their_entry
.
id
,
"452e4244b5d083ddf0460acf1ecc74db9dcfa11a"
);
...
...
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