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
3cf11eef
Commit
3cf11eef
authored
Jan 28, 2014
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc cleanups
parent
c0644c3f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
24 deletions
+25
-24
src/attr.c
+9
-0
src/branch.c
+16
-23
tests/status/renames.c
+0
-1
No files found.
src/attr.c
View file @
3cf11eef
...
@@ -49,6 +49,8 @@ int git_attr_get(
...
@@ -49,6 +49,8 @@ int git_attr_get(
git_attr_name
attr
;
git_attr_name
attr
;
git_attr_rule
*
rule
;
git_attr_rule
*
rule
;
assert
(
value
&&
repo
&&
name
);
*
value
=
NULL
;
*
value
=
NULL
;
if
(
git_attr_path__init
(
&
path
,
pathname
,
git_repository_workdir
(
repo
))
<
0
)
if
(
git_attr_path__init
(
&
path
,
pathname
,
git_repository_workdir
(
repo
))
<
0
)
...
@@ -103,6 +105,11 @@ int git_attr_get_many(
...
@@ -103,6 +105,11 @@ int git_attr_get_many(
attr_get_many_info
*
info
=
NULL
;
attr_get_many_info
*
info
=
NULL
;
size_t
num_found
=
0
;
size_t
num_found
=
0
;
if
(
!
num_attr
)
return
0
;
assert
(
values
&&
repo
&&
names
);
if
(
git_attr_path__init
(
&
path
,
pathname
,
git_repository_workdir
(
repo
))
<
0
)
if
(
git_attr_path__init
(
&
path
,
pathname
,
git_repository_workdir
(
repo
))
<
0
)
return
-
1
;
return
-
1
;
...
@@ -169,6 +176,8 @@ int git_attr_foreach(
...
@@ -169,6 +176,8 @@ int git_attr_foreach(
git_attr_assignment
*
assign
;
git_attr_assignment
*
assign
;
git_strmap
*
seen
=
NULL
;
git_strmap
*
seen
=
NULL
;
assert
(
repo
&&
callback
);
if
(
git_attr_path__init
(
&
path
,
pathname
,
git_repository_workdir
(
repo
))
<
0
)
if
(
git_attr_path__init
(
&
path
,
pathname
,
git_repository_workdir
(
repo
))
<
0
)
return
-
1
;
return
-
1
;
...
...
src/branch.c
View file @
3cf11eef
...
@@ -21,27 +21,22 @@ static int retrieve_branch_reference(
...
@@ -21,27 +21,22 @@ static int retrieve_branch_reference(
const
char
*
branch_name
,
const
char
*
branch_name
,
int
is_remote
)
int
is_remote
)
{
{
git_reference
*
branch
;
git_reference
*
branch
=
NULL
;
int
error
=
-
1
;
int
error
=
0
;
char
*
prefix
;
char
*
prefix
;
git_buf
ref_name
=
GIT_BUF_INIT
;
git_buf
ref_name
=
GIT_BUF_INIT
;
*
branch_reference_out
=
NULL
;
prefix
=
is_remote
?
GIT_REFS_REMOTES_DIR
:
GIT_REFS_HEADS_DIR
;
prefix
=
is_remote
?
GIT_REFS_REMOTES_DIR
:
GIT_REFS_HEADS_DIR
;
if
(
git_buf_joinpath
(
&
ref_name
,
prefix
,
branch_name
)
<
0
)
if
((
error
=
git_buf_joinpath
(
&
ref_name
,
prefix
,
branch_name
))
<
0
)
goto
cleanup
;
/* OOM */
;
else
if
((
error
=
git_reference_lookup
(
&
branch
,
repo
,
ref_name
.
ptr
))
<
0
)
giterr_set
(
GITERR_REFERENCE
,
"Cannot locate %s branch '%s'"
,
is_remote
?
"remote-tracking"
:
"local"
,
branch_name
);
if
((
error
=
git_reference_lookup
(
&
branch
,
repo
,
ref_name
.
ptr
))
<
0
)
{
*
branch_reference_out
=
branch
;
/* will be NULL on error */
giterr_set
(
GITERR_REFERENCE
,
"Cannot locate %s branch '%s'."
,
is_remote
?
"remote-tracking"
:
"local"
,
branch_name
);
goto
cleanup
;
}
*
branch_reference_out
=
branch
;
cleanup:
git_buf_free
(
&
ref_name
);
git_buf_free
(
&
ref_name
);
return
error
;
return
error
;
}
}
...
@@ -63,21 +58,19 @@ int git_branch_create(
...
@@ -63,21 +58,19 @@ int git_branch_create(
{
{
git_reference
*
branch
=
NULL
;
git_reference
*
branch
=
NULL
;
git_buf
canonical_branch_name
=
GIT_BUF_INIT
;
git_buf
canonical_branch_name
=
GIT_BUF_INIT
;
int
error
=
-
1
;
int
error
=
0
;
assert
(
branch_name
&&
commit
&&
ref_out
);
assert
(
branch_name
&&
commit
&&
ref_out
);
assert
(
git_object_owner
((
const
git_object
*
)
commit
)
==
repository
);
assert
(
git_object_owner
((
const
git_object
*
)
commit
)
==
repository
);
if
(
git_buf_joinpath
(
&
canonical_branch_name
,
GIT_REFS_HEADS_DIR
,
branch_name
)
<
0
)
if
(
!
(
error
=
git_buf_joinpath
(
goto
cleanup
;
&
canonical_branch_name
,
GIT_REFS_HEADS_DIR
,
branch_name
)))
error
=
git_reference_create
(
error
=
git_reference_create
(
&
branch
,
repository
,
&
branch
,
repository
,
git_buf_cstr
(
&
canonical_branch_name
)
,
git_buf_cstr
(
&
canonical_branch_name
),
git_commit_id
(
commit
),
force
,
NULL
,
NULL
);
git_commit_id
(
commit
),
force
,
NULL
,
NULL
);
if
(
!
error
)
*
ref_out
=
branch
;
*
ref_out
=
branch
;
cleanup:
git_buf_free
(
&
canonical_branch_name
);
git_buf_free
(
&
canonical_branch_name
);
return
error
;
return
error
;
}
}
...
...
tests/status/renames.c
View file @
3cf11eef
...
@@ -560,7 +560,6 @@ void test_status_renames__zero_byte_file_does_not_fail(void)
...
@@ -560,7 +560,6 @@ void test_status_renames__zero_byte_file_does_not_fail(void)
{
{
git_status_list
*
statuslist
;
git_status_list
*
statuslist
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
git_status_options
opts
=
GIT_STATUS_OPTIONS_INIT
;
status_entry_counts
counts
=
{
0
};
struct
status_entry
expected
[]
=
{
struct
status_entry
expected
[]
=
{
{
GIT_STATUS_WT_DELETED
,
"ikeepsix.txt"
,
"ikeepsix.txt"
},
{
GIT_STATUS_WT_DELETED
,
"ikeepsix.txt"
,
"ikeepsix.txt"
},
...
...
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