Commit 6405ce29753000e84d485d18d6b0fde893a38f84

Reginald McLean 2020-11-06T11:36:25

worktree: Added worktree_dir check Fixes #5280

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/src/worktree.c b/src/worktree.c
index fda9b0b..ea5a403 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -259,7 +259,14 @@ int git_worktree_validate(const git_worktree *wt)
 			wt->commondir_path);
 		return GIT_ERROR;
 	}
-
+	
+	if (!git_path_exists(wt->worktree_path)) {
+		git_error_set(GIT_ERROR_WORKTREE,
+			"worktree directory ('%s') does not exist ",
+			wt->worktree_path);
+		return GIT_ERROR;
+	}
+	
 	return 0;
 }