@@ -566,6 +566,7 @@ int git_worktree_is_prunable(git_worktree *wt,
566566{
567567 git_worktree_prune_options popts = GIT_WORKTREE_PRUNE_OPTIONS_INIT ;
568568 git_buf path = GIT_BUF_INIT ;
569+ int ret = 0 ;
569570
570571 GIT_ERROR_CHECK_VERSION (
571572 opts , GIT_WORKTREE_PRUNE_OPTIONS_VERSION ,
@@ -576,35 +577,40 @@ int git_worktree_is_prunable(git_worktree *wt,
576577
577578 if ((popts .flags & GIT_WORKTREE_PRUNE_LOCKED ) == 0 ) {
578579 git_str reason = GIT_STR_INIT ;
579- int error ;
580580
581- if ((error = git_worktree__is_locked (& reason , wt )) < 0 )
582- return error ;
581+ if ((ret = git_worktree_is_locked (& reason , wt )) < 0 )
582+ goto out ;
583583
584- if (error ) {
584+ if (ret ) {
585585 if (!reason .size )
586586 git_str_attach_notowned (& reason , "no reason given" , 15 );
587587 git_error_set (GIT_ERROR_WORKTREE , "not pruning locked working tree: '%s'" , reason .ptr );
588588 git_str_dispose (& reason );
589- return 0 ;
589+ ret = 0 ;
590+ goto out ;
590591 }
591592 }
592593
593594 if ((popts .flags & GIT_WORKTREE_PRUNE_VALID ) == 0 &&
594595 git_worktree_validate (wt ) == 0 ) {
595596 git_error_set (GIT_ERROR_WORKTREE , "not pruning valid working tree" );
596- return 0 ;
597+ goto out ;
597598 }
598599
599- if (git_buf_printf (& path , "%s/worktrees/%s" , wt -> commondir_path , wt -> name ) < 0 )
600- return 0 ;
600+ if (( ret = git_buf_printf (& path , "%s/worktrees/%s" , wt -> commondir_path , wt -> name ) < 0 ) )
601+ goto out ;
601602 if (!git_path_exists (path .ptr ))
602603 {
603604 git_error_set (GIT_ERROR_WORKTREE , "worktree gitdir '%s' does not exist" , path .ptr );
604- return 0 ;
605+ goto out ;
605606 }
606607
607- return 1 ;
608+ ret = 1 ;
609+
610+ out :
611+
612+ git_buf_dispose (& path );
613+ return ret ;
608614}
609615
610616int git_worktree_prune (git_worktree * wt ,
0 commit comments