Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b0fc6a

Browse files
author
Edward Thomson
committed
diff: on win32, treat fake "symlinks" specially
On platforms that lack `core.symlinks`, we should not go looking for symbolic links and `p_readlink` their target. Instead, we should examine the file's contents.
1 parent f20480a commit 6b0fc6a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/diff_file.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,35 @@ static int diff_file_content_load_blob(
259259
return error;
260260
}
261261

262+
static int diff_file_content_load_workdir_symlink_fake(
263+
git_diff_file_content *fc, git_buf *path)
264+
{
265+
git_buf target = GIT_BUF_INIT;
266+
int error;
267+
268+
if ((error = git_futils_readbuffer(&target, path->ptr)) < 0)
269+
return error;
270+
271+
fc->map.len = git_buf_len(&target);
272+
fc->map.data = git_buf_detach(&target);
273+
fc->flags |= GIT_DIFF_FLAG__FREE_DATA;
274+
275+
git_buf_free(&target);
276+
return error;
277+
}
278+
262279
static int diff_file_content_load_workdir_symlink(
263280
git_diff_file_content *fc, git_buf *path)
264281
{
265282
ssize_t alloc_len, read_len;
283+
int symlink_supported, error;
284+
285+
if ((error = git_repository__cvar(
286+
&symlink_supported, fc->repo, GIT_CVAR_SYMLINKS)) < 0)
287+
return -1;
288+
289+
if (!symlink_supported)
290+
return diff_file_content_load_workdir_symlink_fake(fc, path);
266291

267292
/* link path on disk could be UTF-16, so prepare a buffer that is
268293
* big enough to handle some UTF-8 data expansion

0 commit comments

Comments
 (0)