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
0d95f6ec
Commit
0d95f6ec
authored
Mar 07, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2169 from libgit2/valgrind
Plug leaks
parents
c81e4adf
ae32c54e
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
15 deletions
+44
-15
src/branch.c
+11
-5
src/commit.c
+8
-9
src/refdb_fs.c
+4
-1
src/reset.c
+1
-0
src/transports/local.c
+3
-0
tests/clone/empty.c
+2
-0
tests/odb/backend/nobackend.c
+5
-0
tests/reset/hard.c
+4
-0
tests/reset/mixed.c
+6
-0
No files found.
src/branch.c
View file @
0d95f6ec
...
...
@@ -66,16 +66,22 @@ int git_branch_create(
assert
(
branch_name
&&
commit
&&
ref_out
);
assert
(
git_object_owner
((
const
git_object
*
)
commit
)
==
repository
);
if
(
git_branch_lookup
(
&
branch
,
repository
,
branch_name
,
GIT_BRANCH_LOCAL
)
==
0
)
{
if
((
is_head
=
git_branch_is_head
(
branch
))
<
0
)
{
error
=
is_head
;
if
(
force
&&
git_branch_lookup
(
&
branch
,
repository
,
branch_name
,
GIT_BRANCH_LOCAL
)
==
0
)
{
error
=
git_branch_is_head
(
branch
);
git_reference_free
(
branch
);
branch
=
NULL
;
if
(
error
<
0
)
goto
cleanup
;
}
is_head
=
error
;
}
if
(
is_head
&&
force
)
{
giterr_set
(
GITERR_REFERENCE
,
"Cannot force update branch '%s' as it is "
"the current HEAD of the repository."
,
git_reference_name
(
branch
));
"the current HEAD of the repository."
,
branch_name
);
error
=
-
1
;
goto
cleanup
;
}
...
...
src/commit.c
View file @
0d95f6ec
...
...
@@ -455,19 +455,18 @@ int git_commit_nth_gen_ancestor(
assert
(
ancestor
&&
commit
);
current
=
(
git_commit
*
)
commit
;
if
(
git_object_dup
((
git_object
**
)
&
current
,
(
git_object
*
)
commit
)
<
0
)
return
-
1
;
if
(
n
==
0
)
return
git_commit_lookup
(
ancestor
,
commit
->
object
.
repo
,
git_object_id
((
const
git_object
*
)
commit
));
if
(
n
==
0
)
{
*
ancestor
=
current
;
return
0
;
}
while
(
n
--
)
{
error
=
git_commit_parent
(
&
parent
,
(
git_commit
*
)
current
,
0
);
error
=
git_commit_parent
(
&
parent
,
current
,
0
);
if
(
current
!=
commit
)
git_commit_free
(
current
);
git_commit_free
(
current
);
if
(
error
<
0
)
return
error
;
...
...
src/refdb_fs.c
View file @
0d95f6ec
...
...
@@ -1343,7 +1343,10 @@ static int refdb_reflog_fs__ensure_log(git_refdb_backend *_backend, const char *
if
((
error
=
retrieve_reflog_path
(
&
path
,
repo
,
name
))
<
0
)
return
error
;
return
create_new_reflog_file
(
git_buf_cstr
(
&
path
));
error
=
create_new_reflog_file
(
git_buf_cstr
(
&
path
));
git_buf_free
(
&
path
);
return
error
;
}
static
int
has_reflog
(
git_repository
*
repo
,
const
char
*
name
)
...
...
src/reset.c
View file @
0d95f6ec
...
...
@@ -167,6 +167,7 @@ cleanup:
git_object_free
(
commit
);
git_index_free
(
index
);
git_tree_free
(
tree
);
git_buf_free
(
&
log_message_buf
);
return
error
;
}
src/transports/local.c
View file @
0d95f6ec
...
...
@@ -194,6 +194,9 @@ static int local_connect(
GIT_UNUSED
(
cred_acquire_cb
);
GIT_UNUSED
(
cred_acquire_payload
);
if
(
t
->
connected
)
return
0
;
t
->
url
=
git__strdup
(
url
);
GITERR_CHECK_ALLOC
(
t
->
url
);
t
->
direction
=
direction
;
...
...
tests/clone/empty.c
View file @
0d95f6ec
...
...
@@ -53,11 +53,13 @@ void test_clone_empty__can_clone_an_empty_local_repo_barely(void)
cl_git_pass
(
git_branch_upstream_name
(
&
buf
,
g_repo_cloned
,
local_name
));
cl_assert_equal_s
(
expected_tracked_branch_name
,
buf
.
ptr
);
git_buf_free
(
&
buf
);
/* ...and the name of the remote... */
cl_git_pass
(
git_branch_remote_name
(
&
buf
,
g_repo_cloned
,
expected_tracked_branch_name
));
cl_assert_equal_s
(
expected_remote_name
,
buf
.
ptr
);
git_buf_free
(
&
buf
);
/* ...even when the remote HEAD is unborn as well */
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_reference_lookup
(
&
ref
,
g_repo_cloned
,
...
...
tests/odb/backend/nobackend.c
View file @
0d95f6ec
...
...
@@ -18,6 +18,11 @@ void test_odb_backend_nobackend__initialize(void)
git_repository_set_config
(
_repo
,
config
);
git_repository_set_odb
(
_repo
,
odb
);
git_repository_set_refdb
(
_repo
,
refdb
);
/* The set increases the refcount and we don't want them anymore */
git_config_free
(
config
);
git_odb_free
(
odb
);
git_refdb_free
(
refdb
);
}
void
test_odb_backend_nobackend__cleanup
(
void
)
...
...
tests/reset/hard.c
View file @
0d95f6ec
...
...
@@ -212,12 +212,16 @@ void test_reset_hard__reflog_is_correct(void)
reflog_check
(
repo
,
"HEAD"
,
3
,
"emeric.fermas@gmail.com"
,
exp_msg
);
reflog_check
(
repo
,
"refs/heads/master"
,
3
,
"emeric.fermas@gmail.com"
,
exp_msg
);
git_object_free
(
target
);
/* Moved branch, expect default message */
cl_git_pass
(
git_revparse_single
(
&
target
,
repo
,
"HEAD~^{commit}"
));
cl_git_pass
(
git_reset
(
repo
,
target
,
GIT_RESET_HARD
,
NULL
,
NULL
));
reflog_check
(
repo
,
"HEAD"
,
3
,
"emeric.fermas@gmail.com"
,
exp_msg
);
reflog_check
(
repo
,
"refs/heads/master"
,
4
,
NULL
,
"reset: moving"
);
git_object_free
(
target
);
/* Moved branch, expect custom message */
cl_git_pass
(
git_revparse_single
(
&
target
,
repo
,
"HEAD~^{commit}"
));
cl_git_pass
(
git_reset
(
repo
,
target
,
GIT_RESET_HARD
,
NULL
,
"message1"
));
...
...
tests/reset/mixed.c
View file @
0d95f6ec
...
...
@@ -61,12 +61,18 @@ void test_reset_mixed__reflog_is_correct(void)
reflog_check
(
repo
,
"HEAD"
,
9
,
"yoram.harmelin@gmail.com"
,
exp_msg
);
reflog_check
(
repo
,
"refs/heads/master"
,
9
,
"yoram.harmelin@gmail.com"
,
exp_msg
);
git_object_free
(
target
);
target
=
NULL
;
/* Moved branch, expect default message */
cl_git_pass
(
git_revparse_single
(
&
target
,
repo
,
"HEAD~^{commit}"
));
cl_git_pass
(
git_reset
(
repo
,
target
,
GIT_RESET_MIXED
,
NULL
,
NULL
));
reflog_check
(
repo
,
"HEAD"
,
9
,
"yoram.harmelin@gmail.com"
,
exp_msg
);
reflog_check
(
repo
,
"refs/heads/master"
,
10
,
NULL
,
"reset: moving"
);
git_object_free
(
target
);
target
=
NULL
;
/* Moved branch, expect custom message */
cl_git_pass
(
git_revparse_single
(
&
target
,
repo
,
"HEAD~^{commit}"
));
cl_git_pass
(
git_reset
(
repo
,
target
,
GIT_RESET_MIXED
,
NULL
,
"message1"
));
...
...
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