Commit 37214324 by Edward Thomson

worktree: update prunable to reflect refactorings

PR #5712 predates several refactorings to move the utility code into a
more general purpose codebase. Update to reflect the refactorings.
parent 05719c55
...@@ -565,7 +565,7 @@ int git_worktree_is_prunable(git_worktree *wt, ...@@ -565,7 +565,7 @@ int git_worktree_is_prunable(git_worktree *wt,
git_worktree_prune_options *opts) git_worktree_prune_options *opts)
{ {
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_str path = GIT_STR_INIT;
int ret = 0; int ret = 0;
GIT_ERROR_CHECK_VERSION( GIT_ERROR_CHECK_VERSION(
...@@ -578,13 +578,14 @@ int git_worktree_is_prunable(git_worktree *wt, ...@@ -578,13 +578,14 @@ 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;
if ((ret = git_worktree_is_locked(&reason, wt)) < 0) if ((ret = git_worktree__is_locked(&reason, wt)) < 0)
goto out; goto out;
if (ret) { if (ret) {
if (!reason.size) git_error_set(GIT_ERROR_WORKTREE,
git_str_attach_notowned(&reason, "no reason given", 15); "not pruning locked working tree: '%s'",
git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr); reason.size ? reason.ptr : "is locked");
git_str_dispose(&reason); git_str_dispose(&reason);
ret = 0; ret = 0;
goto out; goto out;
...@@ -597,19 +598,18 @@ int git_worktree_is_prunable(git_worktree *wt, ...@@ -597,19 +598,18 @@ int git_worktree_is_prunable(git_worktree *wt,
goto out; goto out;
} }
if ((ret = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0)) if ((ret = git_str_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0))
goto out; goto out;
if (!git_path_exists(path.ptr))
{ if (!git_fs_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);
goto out; goto out;
} }
ret = 1; ret = 1;
out: out:
git_str_dispose(&path);
git_buf_dispose(&path);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment