Commit 91156a0f2ebfd5bc674d5825c45bce0efb225754

Edward Thomson 2021-04-04T10:44:29

diff: use git_repository_workdir_path The new git_repository_workdir_path function does error checking on working directory inputs on Windows; use it to construct paths within working directories.

diff --git a/src/diff_file.c b/src/diff_file.c
index 015e070..2116f00 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -394,8 +394,7 @@ static int diff_file_content_load_workdir(
 	if (fc->file->mode == GIT_FILEMODE_TREE)
 		return 0;
 
-	if (git_buf_joinpath(
-			&path, git_repository_workdir(fc->repo), fc->file->path) < 0)
+	if (git_repository_workdir_path(&path, fc->repo, fc->file->path) < 0)
 		return -1;
 
 	if (S_ISLNK(fc->file->mode))
diff --git a/src/diff_generate.c b/src/diff_generate.c
index f05ae37..aba9e52 100644
--- a/src/diff_generate.c
+++ b/src/diff_generate.c
@@ -596,8 +596,7 @@ int git_diff__oid_for_entry(
 
 	memset(out, 0, sizeof(*out));
 
-	if (git_buf_joinpath(&full_path,
-		git_repository_workdir(diff->base.repo), entry.path) < 0)
+	if (git_repository_workdir_path(&full_path, diff->base.repo, entry.path) < 0)
 		return -1;
 
 	if (!mode) {
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 03fc2b0..4091420 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -476,8 +476,8 @@ static int similarity_sig(
 	git_diff_file *file = info->file;
 
 	if (info->src == GIT_ITERATOR_WORKDIR) {
-		if ((error = git_buf_joinpath(
-			&info->data, git_repository_workdir(info->repo), file->path)) < 0)
+		if ((error = git_repository_workdir_path(
+			&info->data, info->repo, file->path)) < 0)
 			return error;
 
 		/* if path is not a regular file, just skip this item */