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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
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 */