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
824f755f
Commit
824f755f
authored
May 20, 2014
by
Arthur Schreiber
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refs: Introduce `git_refname_t`.
parent
68f9d6b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
src/refs.c
+10
-13
src/refs.h
+2
-0
No files found.
src/refs.c
View file @
824f755f
...
@@ -159,8 +159,7 @@ int git_reference_name_to_id(
...
@@ -159,8 +159,7 @@ int git_reference_name_to_id(
}
}
static
int
reference_normalize_for_repo
(
static
int
reference_normalize_for_repo
(
char
*
out
,
git_refname_t
out
,
size_t
out_size
,
git_repository
*
repo
,
git_repository
*
repo
,
const
char
*
name
)
const
char
*
name
)
{
{
...
@@ -171,7 +170,7 @@ static int reference_normalize_for_repo(
...
@@ -171,7 +170,7 @@ static int reference_normalize_for_repo(
precompose
)
precompose
)
flags
|=
GIT_REF_FORMAT__PRECOMPOSE_UNICODE
;
flags
|=
GIT_REF_FORMAT__PRECOMPOSE_UNICODE
;
return
git_reference_normalize_name
(
out
,
out_size
,
name
,
flags
);
return
git_reference_normalize_name
(
out
,
GIT_REFNAME_MAX
,
name
,
flags
);
}
}
int
git_reference_lookup_resolved
(
int
git_reference_lookup_resolved
(
...
@@ -180,7 +179,7 @@ int git_reference_lookup_resolved(
...
@@ -180,7 +179,7 @@ int git_reference_lookup_resolved(
const
char
*
name
,
const
char
*
name
,
int
max_nesting
)
int
max_nesting
)
{
{
char
scan_name
[
GIT_REFNAME_MAX
]
;
git_refname_t
scan_name
;
git_ref_t
scan_type
;
git_ref_t
scan_type
;
int
error
=
0
,
nesting
;
int
error
=
0
,
nesting
;
git_reference
*
ref
=
NULL
;
git_reference
*
ref
=
NULL
;
...
@@ -197,8 +196,7 @@ int git_reference_lookup_resolved(
...
@@ -197,8 +196,7 @@ int git_reference_lookup_resolved(
scan_type
=
GIT_REF_SYMBOLIC
;
scan_type
=
GIT_REF_SYMBOLIC
;
if
((
error
=
reference_normalize_for_repo
(
if
((
error
=
reference_normalize_for_repo
(
scan_name
,
repo
,
name
))
<
0
)
scan_name
,
sizeof
(
scan_name
),
repo
,
name
))
<
0
)
return
error
;
return
error
;
if
((
error
=
git_repository_refdb__weakptr
(
&
refdb
,
repo
))
<
0
)
if
((
error
=
git_repository_refdb__weakptr
(
&
refdb
,
repo
))
<
0
)
...
@@ -354,7 +352,7 @@ static int reference__create(
...
@@ -354,7 +352,7 @@ static int reference__create(
const
git_oid
*
old_id
,
const
git_oid
*
old_id
,
const
char
*
old_target
)
const
char
*
old_target
)
{
{
char
normalized
[
GIT_REFNAME_MAX
]
;
git_refname_t
normalized
;
git_refdb
*
refdb
;
git_refdb
*
refdb
;
git_reference
*
ref
=
NULL
;
git_reference
*
ref
=
NULL
;
int
error
=
0
;
int
error
=
0
;
...
@@ -365,7 +363,7 @@ static int reference__create(
...
@@ -365,7 +363,7 @@ static int reference__create(
if
(
ref_out
)
if
(
ref_out
)
*
ref_out
=
NULL
;
*
ref_out
=
NULL
;
error
=
reference_normalize_for_repo
(
normalized
,
sizeof
(
normalized
),
repo
,
name
);
error
=
reference_normalize_for_repo
(
normalized
,
repo
,
name
);
if
(
error
<
0
)
if
(
error
<
0
)
return
error
;
return
error
;
...
@@ -390,10 +388,9 @@ static int reference__create(
...
@@ -390,10 +388,9 @@ static int reference__create(
ref
=
git_reference__alloc
(
normalized
,
oid
,
NULL
);
ref
=
git_reference__alloc
(
normalized
,
oid
,
NULL
);
}
else
{
}
else
{
char
normalized_target
[
GIT_REFNAME_MAX
]
;
git_refname_t
normalized_target
;
if
((
error
=
reference_normalize_for_repo
(
if
((
error
=
reference_normalize_for_repo
(
normalized_target
,
repo
,
symbolic
))
<
0
)
normalized_target
,
sizeof
(
normalized_target
),
repo
,
symbolic
))
<
0
)
return
error
;
return
error
;
ref
=
git_reference__alloc_symbolic
(
normalized
,
normalized_target
);
ref
=
git_reference__alloc_symbolic
(
normalized
,
normalized_target
);
...
@@ -569,14 +566,14 @@ int git_reference_symbolic_set_target(
...
@@ -569,14 +566,14 @@ int git_reference_symbolic_set_target(
static
int
reference__rename
(
git_reference
**
out
,
git_reference
*
ref
,
const
char
*
new_name
,
int
force
,
static
int
reference__rename
(
git_reference
**
out
,
git_reference
*
ref
,
const
char
*
new_name
,
int
force
,
const
git_signature
*
signature
,
const
char
*
message
)
const
git_signature
*
signature
,
const
char
*
message
)
{
{
char
normalized
[
GIT_REFNAME_MAX
]
;
git_refname_t
normalized
;
bool
should_head_be_updated
=
false
;
bool
should_head_be_updated
=
false
;
int
error
=
0
;
int
error
=
0
;
assert
(
ref
&&
new_name
&&
signature
);
assert
(
ref
&&
new_name
&&
signature
);
if
((
error
=
reference_normalize_for_repo
(
if
((
error
=
reference_normalize_for_repo
(
normalized
,
sizeof
(
normalized
),
git_reference_owner
(
ref
),
new_name
))
<
0
)
normalized
,
git_reference_owner
(
ref
),
new_name
))
<
0
)
return
error
;
return
error
;
...
...
src/refs.h
View file @
824f755f
...
@@ -51,6 +51,8 @@
...
@@ -51,6 +51,8 @@
#define GIT_REFNAME_MAX 1024
#define GIT_REFNAME_MAX 1024
typedef
char
git_refname_t
[
GIT_REFNAME_MAX
];
struct
git_reference
{
struct
git_reference
{
git_refdb
*
db
;
git_refdb
*
db
;
git_ref_t
type
;
git_ref_t
type
;
...
...
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