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
92550398
Commit
92550398
authored
Jan 29, 2013
by
John Wiegley
Committed by
Russell Belfer
Apr 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added git_commit_create_oid
parent
1384b688
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
10 deletions
+60
-10
include/git2/commit.h
+20
-0
src/commit.c
+40
-10
No files found.
include/git2/commit.h
View file @
92550398
...
...
@@ -287,6 +287,26 @@ GIT_EXTERN(int) git_commit_create_v(
int
parent_count
,
...);
/**
* Create a new commit in the repository, as with `git_commit_create`,
* using `git_oid` instances as parameters instead of `git_object`.
*
* See documentation for `git_commit_create` for information about the
* parameters, as the meaning is identical excepting that `tree` and
* `parents` now take `git_oid`.
*/
GIT_EXTERN
(
int
)
git_commit_create_oid
(
git_oid
*
oid
,
git_repository
*
repo
,
const
char
*
update_ref
,
const
git_signature
*
author
,
const
git_signature
*
committer
,
const
char
*
message_encoding
,
const
char
*
message
,
const
git_oid
*
tree
,
int
parent_count
,
const
git_oid
*
parents
[]);
/** @} */
GIT_END_DECL
#endif
src/commit.c
View file @
92550398
...
...
@@ -76,7 +76,7 @@ int git_commit_create_v(
return
res
;
}
int
git_commit_create
(
int
git_commit_create
_oid
(
git_oid
*
oid
,
git_repository
*
repo
,
const
char
*
update_ref
,
...
...
@@ -84,22 +84,18 @@ int git_commit_create(
const
git_signature
*
committer
,
const
char
*
message_encoding
,
const
char
*
message
,
const
git_
tree
*
tree
,
const
git_
oid
*
tree
,
int
parent_count
,
const
git_
commit
*
parents
[])
const
git_
oid
*
parents
[])
{
git_buf
commit
=
GIT_BUF_INIT
;
int
i
;
git_odb
*
odb
;
assert
(
git_object_owner
((
const
git_object
*
)
tree
)
==
repo
);
git_oid__writebuf
(
&
commit
,
"tree "
,
git_object_id
((
const
git_object
*
)
tree
));
git_oid__writebuf
(
&
commit
,
"tree "
,
tree
);
for
(
i
=
0
;
i
<
parent_count
;
++
i
)
{
assert
(
git_object_owner
((
const
git_object
*
)
parents
[
i
])
==
repo
);
git_oid__writebuf
(
&
commit
,
"parent "
,
git_object_id
((
const
git_object
*
)
parents
[
i
]));
}
for
(
i
=
0
;
i
<
parent_count
;
++
i
)
git_oid__writebuf
(
&
commit
,
"parent "
,
parents
[
i
]);
git_signature__writebuf
(
&
commit
,
"author "
,
author
);
git_signature__writebuf
(
&
commit
,
"committer "
,
committer
);
...
...
@@ -131,6 +127,40 @@ on_error:
return
-
1
;
}
int
git_commit_create
(
git_oid
*
oid
,
git_repository
*
repo
,
const
char
*
update_ref
,
const
git_signature
*
author
,
const
git_signature
*
committer
,
const
char
*
message_encoding
,
const
char
*
message
,
const
git_tree
*
tree
,
int
parent_count
,
const
git_commit
*
parents
[])
{
int
retval
,
i
;
const
git_oid
**
parent_oids
;
assert
(
git_object_owner
((
const
git_object
*
)
tree
)
==
repo
);
parent_oids
=
git__malloc
(
parent_count
*
sizeof
(
git_oid
*
));
GITERR_CHECK_ALLOC
(
parent_oids
);
for
(
i
=
0
;
i
<
parent_count
;
++
i
)
{
assert
(
git_object_owner
((
const
git_object
*
)
parents
[
i
])
==
repo
);
parent_oids
[
i
]
=
git_object_id
((
const
git_object
*
)
parents
[
i
]);
}
retval
=
git_commit_create_oid
(
oid
,
repo
,
update_ref
,
author
,
committer
,
message_encoding
,
message
,
git_object_id
((
const
git_object
*
)
tree
),
parent_count
,
parent_oids
);
git__free
((
void
*
)
parent_oids
);
return
retval
;
}
int
git_commit__parse_buffer
(
git_commit
*
commit
,
const
void
*
data
,
size_t
len
)
{
const
char
*
buffer
=
data
;
...
...
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