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
51917d9c
Commit
51917d9c
authored
Jul 18, 2011
by
Kirill A. Shutemov
Committed by
Vicent Marti
Jul 25, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
index: extract index_entry_dup() from index_insert()
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
parent
7d9cc9f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
src/index.c
+20
-9
No files found.
src/index.c
View file @
51917d9c
...
...
@@ -331,6 +331,24 @@ git_index_entry *git_index_get(git_index *index, unsigned int n)
return
git_vector_get
(
&
index
->
entries
,
n
);
}
static
git_index_entry
*
index_entry_dup
(
const
git_index_entry
*
source_entry
)
{
git_index_entry
*
entry
;
entry
=
git__malloc
(
sizeof
(
git_index_entry
));
if
(
!
entry
)
return
NULL
;
memcpy
(
entry
,
source_entry
,
sizeof
(
git_index_entry
));
/* duplicate the path string so we own it */
entry
->
path
=
git__strdup
(
entry
->
path
);
if
(
!
entry
->
path
)
return
NULL
;
return
entry
;
}
static
int
index_insert
(
git_index
*
index
,
const
git_index_entry
*
source_entry
,
int
replace
)
{
git_index_entry
*
entry
;
...
...
@@ -343,15 +361,8 @@ static int index_insert(git_index *index, const git_index_entry *source_entry, i
if
(
source_entry
->
path
==
NULL
)
return
git__throw
(
GIT_EMISSINGOBJDATA
,
"Failed to insert into index. Entry has no path"
);
entry
=
git__malloc
(
sizeof
(
git_index_entry
));
if
(
entry
==
NULL
)
return
GIT_ENOMEM
;
memcpy
(
entry
,
source_entry
,
sizeof
(
git_index_entry
));
/* duplicate the path string so we own it */
entry
->
path
=
git__strdup
(
entry
->
path
);
if
(
entry
->
path
==
NULL
)
entry
=
index_entry_dup
(
source_entry
);
if
(
!
entry
)
return
GIT_ENOMEM
;
/* make sure that the path length flag is correct */
...
...
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