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
1ba242c9
Commit
1ba242c9
authored
Feb 03, 2017
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
worktree: extract git_worktree_is_prunable
parent
3f3a4ce7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
include/git2/worktree.h
+18
-0
src/worktree.c
+17
-7
No files found.
include/git2/worktree.h
View file @
1ba242c9
...
...
@@ -126,6 +126,24 @@ typedef enum {
}
git_worktree_prune_t
;
/**
* Is the worktree prunable with the given set of flags?
*
* A worktree is not prunable in the following scenarios:
*
* - the worktree is linking to a valid on-disk worktree. The
* GIT_WORKTREE_PRUNE_VALID flag will cause this check to be
* ignored.
* - the worktree is not valid but locked. The
* GIT_WORKRTEE_PRUNE_LOCKED flag will cause this check to be
* ignored.
*
* If the worktree is not valid and not locked or if the above
* flags have been passed in, this function will return a
* positive value.
*/
GIT_EXTERN
(
int
)
git_worktree_is_prunable
(
git_worktree
*
wt
,
unsigned
flags
);
/**
* Prune working tree
*
* Prune the working tree, that is remove the git data
...
...
src/worktree.c
View file @
1ba242c9
...
...
@@ -357,11 +357,9 @@ out:
return
ret
;
}
int
git_worktree_
prun
e
(
git_worktree
*
wt
,
unsigned
flags
)
int
git_worktree_
is_prunabl
e
(
git_worktree
*
wt
,
unsigned
flags
)
{
git_buf
reason
=
GIT_BUF_INIT
,
path
=
GIT_BUF_INIT
;
char
*
wtpath
;
int
err
;
git_buf
reason
=
GIT_BUF_INIT
;
if
((
flags
&
GIT_WORKTREE_PRUNE_LOCKED
)
==
0
&&
git_worktree_is_locked
(
&
reason
,
wt
))
...
...
@@ -369,15 +367,28 @@ int git_worktree_prune(git_worktree *wt, unsigned flags)
if
(
!
reason
.
size
)
git_buf_attach_notowned
(
&
reason
,
"no reason given"
,
15
);
giterr_set
(
GITERR_WORKTREE
,
"Not pruning locked working tree: '%s'"
,
reason
.
ptr
);
git_buf_free
(
&
reason
);
err
=
-
1
;
goto
out
;
return
0
;
}
if
((
flags
&
GIT_WORKTREE_PRUNE_VALID
)
==
0
&&
git_worktree_validate
(
wt
)
==
0
)
{
giterr_set
(
GITERR_WORKTREE
,
"Not pruning valid working tree"
);
return
0
;
}
return
1
;
}
int
git_worktree_prune
(
git_worktree
*
wt
,
unsigned
flags
)
{
git_buf
path
=
GIT_BUF_INIT
;
char
*
wtpath
;
int
err
;
if
(
!
git_worktree_is_prunable
(
wt
,
flags
))
{
err
=
-
1
;
goto
out
;
}
...
...
@@ -415,7 +426,6 @@ int git_worktree_prune(git_worktree *wt, unsigned flags)
goto
out
;
out:
git_buf_free
(
&
reason
);
git_buf_free
(
&
path
);
return
err
;
...
...
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