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
caf7a7a6
Commit
caf7a7a6
authored
Mar 28, 2017
by
Edward Thomson
Committed by
GitHub
Mar 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4182 from pks-t/pks/treebuilder
git_treebuilder_write_with_buffer refactorings
parents
a25df009
06abbb7f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
src/tree.c
+12
-10
No files found.
src/tree.c
View file @
caf7a7a6
...
@@ -818,7 +818,7 @@ int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_bu
...
@@ -818,7 +818,7 @@ int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_bu
size_t
i
,
entrycount
;
size_t
i
,
entrycount
;
git_odb
*
odb
;
git_odb
*
odb
;
git_tree_entry
*
entry
;
git_tree_entry
*
entry
;
git_vector
entries
;
git_vector
entries
=
GIT_VECTOR_INIT
;
assert
(
bld
);
assert
(
bld
);
assert
(
tree
);
assert
(
tree
);
...
@@ -826,35 +826,37 @@ int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_bu
...
@@ -826,35 +826,37 @@ int git_treebuilder_write_with_buffer(git_oid *oid, git_treebuilder *bld, git_bu
git_buf_clear
(
tree
);
git_buf_clear
(
tree
);
entrycount
=
git_strmap_num_entries
(
bld
->
map
);
entrycount
=
git_strmap_num_entries
(
bld
->
map
);
if
(
git_vector_init
(
&
entries
,
entrycount
,
entry_sort_cmp
)
<
0
)
if
(
(
error
=
git_vector_init
(
&
entries
,
entrycount
,
entry_sort_cmp
)
)
<
0
)
return
-
1
;
goto
out
;
if
(
tree
->
asize
==
0
&&
if
(
tree
->
asize
==
0
&&
(
error
=
git_buf_grow
(
tree
,
entrycount
*
72
))
<
0
)
(
error
=
git_buf_grow
(
tree
,
entrycount
*
72
))
<
0
)
return
error
;
goto
out
;
git_strmap_foreach_value
(
bld
->
map
,
entry
,
{
git_strmap_foreach_value
(
bld
->
map
,
entry
,
{
if
(
git_vector_insert
(
&
entries
,
entry
)
<
0
)
if
(
(
error
=
git_vector_insert
(
&
entries
,
entry
)
)
<
0
)
return
-
1
;
goto
out
;
});
});
git_vector_sort
(
&
entries
);
git_vector_sort
(
&
entries
);
for
(
i
=
0
;
i
<
entries
.
length
&&
!
error
;
++
i
)
{
for
(
i
=
0
;
i
<
entries
.
length
&&
!
error
;
++
i
)
{
git_tree_entry
*
entry
=
git_vector_get
(
&
entries
,
i
);
entry
=
git_vector_get
(
&
entries
,
i
);
git_buf_printf
(
tree
,
"%o "
,
entry
->
attr
);
git_buf_printf
(
tree
,
"%o "
,
entry
->
attr
);
git_buf_put
(
tree
,
entry
->
filename
,
entry
->
filename_len
+
1
);
git_buf_put
(
tree
,
entry
->
filename
,
entry
->
filename_len
+
1
);
git_buf_put
(
tree
,
(
char
*
)
entry
->
oid
->
id
,
GIT_OID_RAWSZ
);
git_buf_put
(
tree
,
(
char
*
)
entry
->
oid
->
id
,
GIT_OID_RAWSZ
);
if
(
git_buf_oom
(
tree
))
if
(
git_buf_oom
(
tree
))
{
error
=
-
1
;
error
=
-
1
;
goto
out
;
}
}
}
if
(
!
error
&&
if
((
error
=
git_repository_odb__weakptr
(
&
odb
,
bld
->
repo
))
==
0
)
!
(
error
=
git_repository_odb__weakptr
(
&
odb
,
bld
->
repo
)))
error
=
git_odb_write
(
oid
,
odb
,
tree
->
ptr
,
tree
->
size
,
GIT_OBJ_TREE
);
error
=
git_odb_write
(
oid
,
odb
,
tree
->
ptr
,
tree
->
size
,
GIT_OBJ_TREE
);
out:
git_vector_free
(
&
entries
);
git_vector_free
(
&
entries
);
return
error
;
return
error
;
...
...
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