Skip to content

Commit 3721432

Browse files
committed
worktree: update prunable to reflect refactorings
PR libgit2#5712 predates several refactorings to move the utility code into a more general purpose codebase. Update to reflect the refactorings.
1 parent 05719c5 commit 3721432

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/libgit2/worktree.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ int git_worktree_is_prunable(git_worktree *wt,
565565
git_worktree_prune_options *opts)
566566
{
567567
git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT;
568-
git_buf path = GIT_BUF_INIT;
568+
git_str path = GIT_STR_INIT;
569569
int ret = 0;
570570

571571
GIT_ERROR_CHECK_VERSION(
@@ -578,13 +578,14 @@ int git_worktree_is_prunable(git_worktree *wt,
578578
if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) {
579579
git_str reason = GIT_STR_INIT;
580580

581-
if ((ret = git_worktree_is_locked(&reason, wt)) < 0)
581+
if ((ret = git_worktree__is_locked(&reason, wt)) < 0)
582582
goto out;
583583

584584
if (ret) {
585-
if (!reason.size)
586-
git_str_attach_notowned(&reason, "no reason given", 15);
587-
git_error_set(GIT_ERROR_WORKTREE, "not pruning locked working tree: '%s'", reason.ptr);
585+
git_error_set(GIT_ERROR_WORKTREE,
586+
"not pruning locked working tree: '%s'",
587+
reason.size ? reason.ptr : "is locked");
588+
588589
git_str_dispose(&reason);
589590
ret = 0;
590591
goto out;
@@ -597,19 +598,18 @@ int git_worktree_is_prunable(git_worktree *wt,
597598
goto out;
598599
}
599600

600-
if ((ret = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0))
601+
if ((ret = git_str_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name) < 0))
601602
goto out;
602-
if (!git_path_exists(path.ptr))
603-
{
604-
git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir '%s' does not exist", path.ptr);
603+
604+
if (!git_fs_path_exists(path.ptr)) {
605+
git_error_set(GIT_ERROR_WORKTREE, "worktree gitdir ('%s') does not exist", path.ptr);
605606
goto out;
606607
}
607608

608609
ret = 1;
609610

610611
out:
611-
612-
git_buf_dispose(&path);
612+
git_str_dispose(&path);
613613
return ret;
614614
}
615615

0 commit comments

Comments
 (0)