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
61838295
Commit
61838295
authored
Jan 26, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object: move oid header printing to object
parent
b7a46fa8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
22 deletions
+34
-22
src/libgit2/commit.c
+4
-2
src/libgit2/object.c
+15
-0
src/libgit2/object.h
+4
-1
src/libgit2/oid.c
+0
-10
src/libgit2/tag.c
+3
-1
tests/libgit2/refs/reflog/reflog_helpers.c
+8
-8
No files found.
src/libgit2/commit.c
View file @
61838295
...
...
@@ -56,11 +56,13 @@ static int git_commit__create_buffer_internal(
GIT_ASSERT_ARG
(
out
);
GIT_ASSERT_ARG
(
tree
);
git_oid__writebuf
(
out
,
"tree "
,
tree
);
if
(
git_object__write_oid_header
(
out
,
"tree "
,
tree
)
<
0
)
goto
on_error
;
for
(
i
=
0
;
i
<
git_array_size
(
*
parents
);
i
++
)
{
parent
=
git_array_get
(
*
parents
,
i
);
git_oid__writebuf
(
out
,
"parent "
,
parent
);
if
(
git_object__write_oid_header
(
out
,
"parent "
,
parent
)
<
0
)
goto
on_error
;
}
git_signature__writebuf
(
out
,
"author "
,
author
);
...
...
src/libgit2/object.c
View file @
61838295
...
...
@@ -628,3 +628,18 @@ int git_object__parse_oid_header(
return
0
;
}
int
git_object__write_oid_header
(
git_str
*
buf
,
const
char
*
header
,
const
git_oid
*
oid
)
{
char
hex_oid
[
GIT_OID_SHA1_HEXSIZE
];
git_oid_fmt
(
hex_oid
,
oid
);
git_str_puts
(
buf
,
header
);
git_str_put
(
buf
,
hex_oid
,
GIT_OID_SHA1_HEXSIZE
);
git_str_putc
(
buf
,
'\n'
);
return
git_str_oom
(
buf
)
?
-
1
:
0
;
}
src/libgit2/object.h
View file @
61838295
...
...
@@ -51,7 +51,10 @@ int git_object__parse_oid_header(
const
char
*
buffer_end
,
const
char
*
header
);
void
git_oid__writebuf
(
git_str
*
buf
,
const
char
*
header
,
const
git_oid
*
oid
);
int
git_object__write_oid_header
(
git_str
*
buf
,
const
char
*
header
,
const
git_oid
*
oid
);
bool
git_object__is_valid
(
git_repository
*
repo
,
const
git_oid
*
id
,
git_object_t
expected_type
);
...
...
src/libgit2/oid.c
View file @
61838295
...
...
@@ -143,16 +143,6 @@ char *git_oid_tostr(char *out, size_t n, const git_oid *oid)
return
out
;
}
void
git_oid__writebuf
(
git_str
*
buf
,
const
char
*
header
,
const
git_oid
*
oid
)
{
char
hex_oid
[
GIT_OID_SHA1_HEXSIZE
];
git_oid_fmt
(
hex_oid
,
oid
);
git_str_puts
(
buf
,
header
);
git_str_put
(
buf
,
hex_oid
,
GIT_OID_SHA1_HEXSIZE
);
git_str_putc
(
buf
,
'\n'
);
}
int
git_oid_fromraw
(
git_oid
*
out
,
const
unsigned
char
*
raw
)
{
memcpy
(
out
->
id
,
raw
,
sizeof
(
out
->
id
));
...
...
src/libgit2/tag.c
View file @
61838295
...
...
@@ -221,7 +221,9 @@ static int write_tag_annotation(
git_str
tag
=
GIT_STR_INIT
;
git_odb
*
odb
;
git_oid__writebuf
(
&
tag
,
"object "
,
git_object_id
(
target
));
if
(
git_object__write_oid_header
(
&
tag
,
"object "
,
git_object_id
(
target
))
<
0
)
goto
on_error
;
git_str_printf
(
&
tag
,
"type %s
\n
"
,
git_object_type2string
(
git_object_type
(
target
)));
git_str_printf
(
&
tag
,
"tag %s
\n
"
,
tag_name
);
git_signature__writebuf
(
&
tag
,
"tagger "
,
tagger
);
...
...
tests/libgit2/refs/reflog/reflog_helpers.c
View file @
61838295
...
...
@@ -46,8 +46,8 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
git_object
*
obj
=
NULL
;
if
(
git_revparse_single
(
&
obj
,
repo
,
old_spec
)
==
GIT_OK
)
{
if
(
git_oid_cmp
(
git_object_id
(
obj
),
git_reflog_entry_id_old
(
entry
))
!=
0
)
{
git_o
id__writebuf
(
&
result
,
"
\t
Old OID:
\"
"
,
git_object_id
(
obj
));
git_o
id__writebuf
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_old
(
entry
));
git_o
bject__write_oid_header
(
&
result
,
"
\t
Old OID:
\"
"
,
git_object_id
(
obj
));
git_o
bject__write_oid_header
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_old
(
entry
));
git_str_puts
(
&
result
,
"
\"\n
"
);
}
git_object_free
(
obj
);
...
...
@@ -55,8 +55,8 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
git_oid
*
oid
=
git__calloc
(
1
,
sizeof
(
*
oid
));
git_oid_fromstr
(
oid
,
old_spec
);
if
(
git_oid_cmp
(
oid
,
git_reflog_entry_id_old
(
entry
))
!=
0
)
{
git_o
id__writebuf
(
&
result
,
"
\t
Old OID:
\"
"
,
oid
);
git_o
id__writebuf
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_old
(
entry
));
git_o
bject__write_oid_header
(
&
result
,
"
\t
Old OID:
\"
"
,
oid
);
git_o
bject__write_oid_header
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_old
(
entry
));
git_str_puts
(
&
result
,
"
\"\n
"
);
}
git__free
(
oid
);
...
...
@@ -66,8 +66,8 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
git_object
*
obj
=
NULL
;
if
(
git_revparse_single
(
&
obj
,
repo
,
new_spec
)
==
GIT_OK
)
{
if
(
git_oid_cmp
(
git_object_id
(
obj
),
git_reflog_entry_id_new
(
entry
))
!=
0
)
{
git_o
id__writebuf
(
&
result
,
"
\t
New OID:
\"
"
,
git_object_id
(
obj
));
git_o
id__writebuf
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_new
(
entry
));
git_o
bject__write_oid_header
(
&
result
,
"
\t
New OID:
\"
"
,
git_object_id
(
obj
));
git_o
bject__write_oid_header
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_new
(
entry
));
git_str_puts
(
&
result
,
"
\"\n
"
);
}
git_object_free
(
obj
);
...
...
@@ -75,8 +75,8 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
git_oid
*
oid
=
git__calloc
(
1
,
sizeof
(
*
oid
));
git_oid_fromstr
(
oid
,
new_spec
);
if
(
git_oid_cmp
(
oid
,
git_reflog_entry_id_new
(
entry
))
!=
0
)
{
git_o
id__writebuf
(
&
result
,
"
\t
New OID:
\"
"
,
oid
);
git_o
id__writebuf
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_new
(
entry
));
git_o
bject__write_oid_header
(
&
result
,
"
\t
New OID:
\"
"
,
oid
);
git_o
bject__write_oid_header
(
&
result
,
"
\"
!=
\"
"
,
git_reflog_entry_id_new
(
entry
));
git_str_puts
(
&
result
,
"
\"\n
"
);
}
git__free
(
oid
);
...
...
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