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
cf6faa88
Commit
cf6faa88
authored
Apr 06, 2023
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert: support SHA256 oids
parent
14fc473a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
11 deletions
+8
-11
src/libgit2/revert.c
+8
-11
No files found.
src/libgit2/revert.c
View file @
cf6faa88
...
...
@@ -107,12 +107,10 @@ static int revert_state_cleanup(git_repository *repo)
static
int
revert_seterr
(
git_commit
*
commit
,
const
char
*
fmt
)
{
char
commit_
oidstr
[
GIT_OID_SHA1
_HEXSIZE
+
1
];
char
commit_
id
[
GIT_OID_MAX
_HEXSIZE
+
1
];
git_oid_fmt
(
commit_oidstr
,
git_commit_id
(
commit
));
commit_oidstr
[
GIT_OID_SHA1_HEXSIZE
]
=
'\0'
;
git_error_set
(
GIT_ERROR_REVERT
,
fmt
,
commit_oidstr
);
git_oid_tostr
(
commit_id
,
GIT_OID_MAX_HEXSIZE
+
1
,
git_commit_id
(
commit
));
git_error_set
(
GIT_ERROR_REVERT
,
fmt
,
commit_id
);
return
-
1
;
}
...
...
@@ -176,7 +174,7 @@ int git_revert(
git_revert_options
opts
;
git_reference
*
our_ref
=
NULL
;
git_commit
*
our_commit
=
NULL
;
char
commit_
oidstr
[
GIT_OID_SHA1
_HEXSIZE
+
1
];
char
commit_
id
[
GIT_OID_MAX
_HEXSIZE
+
1
];
const
char
*
commit_msg
;
git_str
their_label
=
GIT_STR_INIT
;
git_index
*
index
=
NULL
;
...
...
@@ -191,19 +189,18 @@ int git_revert(
if
((
error
=
git_repository__ensure_not_bare
(
repo
,
"revert"
))
<
0
)
return
error
;
git_oid_fmt
(
commit_oidstr
,
git_commit_id
(
commit
));
commit_oidstr
[
GIT_OID_SHA1_HEXSIZE
]
=
'\0'
;
git_oid_tostr
(
commit_id
,
GIT_OID_MAX_HEXSIZE
+
1
,
git_commit_id
(
commit
));
if
((
commit_msg
=
git_commit_summary
(
commit
))
==
NULL
)
{
error
=
-
1
;
goto
on_error
;
}
if
((
error
=
git_str_printf
(
&
their_label
,
"parent of %.7s... %s"
,
commit_
oidstr
,
commit_msg
))
<
0
||
if
((
error
=
git_str_printf
(
&
their_label
,
"parent of %.7s... %s"
,
commit_
id
,
commit_msg
))
<
0
||
(
error
=
revert_normalize_opts
(
repo
,
&
opts
,
given_opts
,
git_str_cstr
(
&
their_label
)))
<
0
||
(
error
=
git_indexwriter_init_for_operation
(
&
indexwriter
,
repo
,
&
opts
.
checkout_opts
.
checkout_strategy
))
<
0
||
(
error
=
write_revert_head
(
repo
,
commit_
oidstr
))
<
0
||
(
error
=
write_merge_msg
(
repo
,
commit_
oidstr
,
commit_msg
))
<
0
||
(
error
=
write_revert_head
(
repo
,
commit_
id
))
<
0
||
(
error
=
write_merge_msg
(
repo
,
commit_
id
,
commit_msg
))
<
0
||
(
error
=
git_repository_head
(
&
our_ref
,
repo
))
<
0
||
(
error
=
git_reference_peel
((
git_object
**
)
&
our_commit
,
our_ref
,
GIT_OBJECT_COMMIT
))
<
0
||
(
error
=
git_revert_commit
(
&
index
,
repo
,
commit
,
our_commit
,
opts
.
mainline
,
&
opts
.
merge_opts
))
<
0
||
...
...
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