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
05719c55
Commit
05719c55
authored
Nov 24, 2020
by
Reginald McLean
Committed by
Edward Thomson
May 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor git_worktree_is_prunable slightly to fix memory leak
parent
86db1ad5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
+16
-10
src/libgit2/worktree.c
+16
-10
No files found.
src/libgit2/worktree.c
View file @
05719c55
...
@@ -566,6 +566,7 @@ int git_worktree_is_prunable(git_worktree *wt,
...
@@ -566,6 +566,7 @@ int git_worktree_is_prunable(git_worktree *wt,
{
{
git_worktree_prune_options
popts
=
GIT_WORKTREE_PRUNE_OPTIONS_INIT
;
git_worktree_prune_options
popts
=
GIT_WORKTREE_PRUNE_OPTIONS_INIT
;
git_buf
path
=
GIT_BUF_INIT
;
git_buf
path
=
GIT_BUF_INIT
;
int
ret
=
0
;
GIT_ERROR_CHECK_VERSION
(
GIT_ERROR_CHECK_VERSION
(
opts
,
GIT_WORKTREE_PRUNE_OPTIONS_VERSION
,
opts
,
GIT_WORKTREE_PRUNE_OPTIONS_VERSION
,
...
@@ -576,35 +577,40 @@ int git_worktree_is_prunable(git_worktree *wt,
...
@@ -576,35 +577,40 @@ int git_worktree_is_prunable(git_worktree *wt,
if
((
popts
.
flags
&
GIT_WORKTREE_PRUNE_LOCKED
)
==
0
)
{
if
((
popts
.
flags
&
GIT_WORKTREE_PRUNE_LOCKED
)
==
0
)
{
git_str
reason
=
GIT_STR_INIT
;
git_str
reason
=
GIT_STR_INIT
;
int
error
;
if
((
error
=
git_worktree_
_is_locked
(
&
reason
,
wt
))
<
0
)
if
((
ret
=
git_worktree
_is_locked
(
&
reason
,
wt
))
<
0
)
return
error
;
goto
out
;
if
(
error
)
{
if
(
ret
)
{
if
(
!
reason
.
size
)
if
(
!
reason
.
size
)
git_str_attach_notowned
(
&
reason
,
"no reason given"
,
15
);
git_str_attach_notowned
(
&
reason
,
"no reason given"
,
15
);
git_error_set
(
GIT_ERROR_WORKTREE
,
"not pruning locked working tree: '%s'"
,
reason
.
ptr
);
git_error_set
(
GIT_ERROR_WORKTREE
,
"not pruning locked working tree: '%s'"
,
reason
.
ptr
);
git_str_dispose
(
&
reason
);
git_str_dispose
(
&
reason
);
return
0
;
ret
=
0
;
goto
out
;
}
}
}
}
if
((
popts
.
flags
&
GIT_WORKTREE_PRUNE_VALID
)
==
0
&&
if
((
popts
.
flags
&
GIT_WORKTREE_PRUNE_VALID
)
==
0
&&
git_worktree_validate
(
wt
)
==
0
)
{
git_worktree_validate
(
wt
)
==
0
)
{
git_error_set
(
GIT_ERROR_WORKTREE
,
"not pruning valid working tree"
);
git_error_set
(
GIT_ERROR_WORKTREE
,
"not pruning valid working tree"
);
return
0
;
goto
out
;
}
}
if
(
git_buf_printf
(
&
path
,
"%s/worktrees/%s"
,
wt
->
commondir_path
,
wt
->
name
)
<
0
)
if
(
(
ret
=
git_buf_printf
(
&
path
,
"%s/worktrees/%s"
,
wt
->
commondir_path
,
wt
->
name
)
<
0
)
)
return
0
;
goto
out
;
if
(
!
git_path_exists
(
path
.
ptr
))
if
(
!
git_path_exists
(
path
.
ptr
))
{
{
git_error_set
(
GIT_ERROR_WORKTREE
,
"worktree gitdir '%s' does not exist"
,
path
.
ptr
);
git_error_set
(
GIT_ERROR_WORKTREE
,
"worktree gitdir '%s' does not exist"
,
path
.
ptr
);
return
0
;
goto
out
;
}
}
return
1
;
ret
=
1
;
out:
git_buf_dispose
(
&
path
);
return
ret
;
}
}
int
git_worktree_prune
(
git_worktree
*
wt
,
int
git_worktree_prune
(
git_worktree
*
wt
,
...
...
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