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
4ec197f3
Commit
4ec197f3
authored
Nov 30, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deploy GIT_SIGNATURE_INIT
parent
10711769
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
1 deletions
+38
-1
src/commit.c
+3
-0
src/notes.c
+9
-0
src/reflog.c
+4
-0
src/signature.c
+3
-1
src/signature.h
+12
-0
src/stash.c
+4
-0
src/tag.c
+3
-0
No files found.
src/commit.c
View file @
4ec197f3
...
...
@@ -93,6 +93,9 @@ int git_commit_create(
git_odb
*
odb
;
assert
(
git_object_owner
((
const
git_object
*
)
tree
)
==
repo
);
if
(
!
git_signature__has_valid_version
(
author
)
||
!
git_signature__has_valid_version
(
committer
))
return
-
1
;
git_oid__writebuf
(
&
commit
,
"tree "
,
git_object_id
((
const
git_object
*
)
tree
));
...
...
src/notes.c
View file @
4ec197f3
...
...
@@ -11,6 +11,7 @@
#include "refs.h"
#include "config.h"
#include "iterator.h"
#include "signature.h"
static
int
find_subtree_in_current_level
(
git_tree
**
out
,
...
...
@@ -455,6 +456,10 @@ int git_note_create(
git_commit
*
commit
=
NULL
;
git_tree
*
tree
=
NULL
;
if
(
!
git_signature__has_valid_version
(
author
)
||
!
git_signature__has_valid_version
(
committer
))
return
-
1
;
target
=
git_oid_allocfmt
(
oid
);
GITERR_CHECK_ALLOC
(
target
);
...
...
@@ -482,6 +487,10 @@ int git_note_remove(git_repository *repo, const char *notes_ref,
git_commit
*
commit
=
NULL
;
git_tree
*
tree
=
NULL
;
if
(
!
git_signature__has_valid_version
(
author
)
||
!
git_signature__has_valid_version
(
committer
))
return
-
1
;
target
=
git_oid_allocfmt
(
oid
);
GITERR_CHECK_ALLOC
(
target
);
...
...
src/reflog.c
View file @
4ec197f3
...
...
@@ -112,6 +112,7 @@ static int reflog_parse(git_reflog *log, const char *buf, size_t buf_size)
entry
->
committer
=
git__malloc
(
sizeof
(
git_signature
));
GITERR_CHECK_ALLOC
(
entry
->
committer
);
entry
->
committer
->
version
=
GIT_SIGNATURE_VERSION
;
if
(
git_oid_fromstrn
(
&
entry
->
oid_old
,
buf
,
GIT_OID_HEXSZ
)
<
0
)
goto
fail
;
...
...
@@ -297,6 +298,9 @@ int git_reflog_append(git_reflog *reflog, const git_oid *new_oid,
assert
(
reflog
&&
new_oid
&&
committer
);
if
(
!
git_signature__has_valid_version
(
committer
))
return
-
1
;
if
(
reflog_entry_new
(
&
entry
)
<
0
)
return
-
1
;
...
...
src/signature.c
View file @
4ec197f3
...
...
@@ -90,6 +90,7 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
p
=
git__calloc
(
1
,
sizeof
(
git_signature
));
GITERR_CHECK_ALLOC
(
p
);
p
->
version
=
GIT_SIGNATURE_VERSION
;
if
(
process_trimming
(
name
,
&
p
->
name
,
name
+
strlen
(
name
),
1
)
<
0
||
process_trimming
(
email
,
&
p
->
email
,
email
+
strlen
(
email
),
1
)
<
0
)
...
...
@@ -263,8 +264,9 @@ int git_signature__parse(git_signature *sig, const char **buffer_out,
const
char
*
buffer
=
*
buffer_out
;
const
char
*
line_end
,
*
name_end
,
*
email_end
,
*
tz_start
,
*
time_start
;
int
error
=
0
;
git_signature
initsig
=
GIT_SIGNATURE_INIT
;
mem
set
(
sig
,
0x0
,
sizeof
(
git_signature
));
mem
move
(
sig
,
&
initsig
,
sizeof
(
git_signature
));
if
((
line_end
=
memchr
(
buffer
,
ender
,
buffer_end
-
buffer
))
==
NULL
)
return
signature_error
(
"no newline given"
);
...
...
src/signature.h
View file @
4ec197f3
...
...
@@ -15,4 +15,16 @@
int
git_signature__parse
(
git_signature
*
sig
,
const
char
**
buffer_out
,
const
char
*
buffer_end
,
const
char
*
header
,
char
ender
);
void
git_signature__writebuf
(
git_buf
*
buf
,
const
char
*
header
,
const
git_signature
*
sig
);
GIT_INLINE
(
bool
)
git_signature__has_valid_version
(
const
git_signature
*
sig
)
{
if
(
!
sig
)
return
true
;
if
(
sig
->
version
>
0
&&
sig
->
version
<=
GIT_SIGNATURE_VERSION
)
return
true
;
giterr_set
(
GITERR_INVALID
,
"Invalid version %d on git_signature"
,
sig
->
version
);
return
false
;
}
#endif
src/stash.c
View file @
4ec197f3
...
...
@@ -14,6 +14,7 @@
#include "git2/stash.h"
#include "git2/status.h"
#include "git2/checkout.h"
#include "signature.h"
static
int
create_error
(
int
error
,
const
char
*
msg
)
{
...
...
@@ -522,6 +523,9 @@ int git_stash_save(
assert
(
out
&&
repo
&&
stasher
);
if
(
!
git_signature__has_valid_version
(
stasher
))
return
-
1
;
if
((
error
=
ensure_non_bare_repository
(
repo
))
<
0
)
return
error
;
...
...
src/tag.c
View file @
4ec197f3
...
...
@@ -244,6 +244,9 @@ static int git_tag_create__internal(
assert
(
repo
&&
tag_name
&&
target
);
assert
(
!
create_tag_annotation
||
(
tagger
&&
message
));
if
(
!
git_signature__has_valid_version
(
tagger
))
return
-
1
;
if
(
git_object_owner
(
target
)
!=
repo
)
{
giterr_set
(
GITERR_INVALID
,
"The given target does not belong to this repository"
);
return
-
1
;
...
...
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