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
f824259e
Commit
f824259e
authored
Dec 16, 2015
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3549 from libgit2/vmg/index-fill
merge: Use `git_index__fill` to populate the index
parents
7f2c1469
879ebab3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
src/index.c
+37
-0
src/index.h
+2
-0
src/merge.c
+1
-4
No files found.
src/index.c
View file @
f824259e
...
...
@@ -1542,6 +1542,43 @@ int git_index_remove_bypath(git_index *index, const char *path)
return
0
;
}
int
git_index__fill
(
git_index
*
index
,
const
git_vector
*
source_entries
)
{
const
git_index_entry
*
source_entry
=
NULL
;
size_t
i
;
int
ret
=
0
;
assert
(
index
);
if
(
git_mutex_lock
(
&
index
->
lock
)
<
0
)
{
giterr_set
(
GITERR_OS
,
"Unable to acquire index lock"
);
return
-
1
;
}
git_vector_foreach
(
source_entries
,
i
,
source_entry
)
{
git_index_entry
*
entry
=
NULL
;
if
((
ret
=
index_entry_dup
(
&
entry
,
index
,
source_entry
))
<
0
)
break
;
entry
->
flags_extended
|=
GIT_IDXENTRY_UPTODATE
;
ret
=
git_vector_insert
(
&
index
->
entries
,
entry
);
if
(
ret
<
0
)
break
;
INSERT_IN_MAP
(
index
,
entry
,
ret
);
if
(
ret
<
0
)
break
;
}
if
(
!
ret
)
git_vector_sort
(
&
index
->
entries
);
git_mutex_unlock
(
&
index
->
lock
);
return
ret
;
}
int
git_index_add
(
git_index
*
index
,
const
git_index_entry
*
source_entry
)
{
...
...
src/index.h
View file @
f824259e
...
...
@@ -113,6 +113,8 @@ GIT_INLINE(bool) git_index_entry_newer_than_index(
extern
int
git_index__find_pos
(
size_t
*
at_pos
,
git_index
*
index
,
const
char
*
path
,
size_t
path_len
,
int
stage
);
extern
int
git_index__fill
(
git_index
*
index
,
const
git_vector
*
source_entries
);
extern
void
git_index__set_ignore_case
(
git_index
*
index
,
bool
ignore_case
);
extern
unsigned
int
git_index__create_mode
(
unsigned
int
mode
);
...
...
src/merge.c
View file @
f824259e
...
...
@@ -1739,7 +1739,6 @@ static int index_from_diff_list(git_index **out,
{
git_index
*
index
;
size_t
i
;
git_index_entry
*
entry
;
git_merge_diff
*
conflict
;
int
error
=
0
;
...
...
@@ -1748,10 +1747,8 @@ static int index_from_diff_list(git_index **out,
if
((
error
=
git_index_new
(
&
index
))
<
0
)
return
error
;
git_vector_foreach
(
&
diff_list
->
staged
,
i
,
entry
)
{
if
((
error
=
git_index_add
(
index
,
entry
))
<
0
)
if
((
error
=
git_index__fill
(
index
,
&
diff_list
->
staged
))
<
0
)
goto
on_error
;
}
git_vector_foreach
(
&
diff_list
->
conflicts
,
i
,
conflict
)
{
const
git_index_entry
*
ancestor
=
...
...
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