diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-11-03 09:43:18 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-11-03 12:06:49 -0500 |
commit | 6b0fc6abc159c6f15f49bf5ab40b1152d8c6165f (patch) | |
tree | c8d08c6de41a97e04b298eaf3cb2340f93093f67 | |
parent | f20480ab0ccbba077e6ec060d3b4ef7f74650828 (diff) | |
download | libgit2-6b0fc6abc159c6f15f49bf5ab40b1152d8c6165f.tar.gz |
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.
-rw-r--r-- | src/diff_file.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/diff_file.c b/src/diff_file.c index c60362865..ecc34cf55 100644 --- a/src/diff_file.c +++ b/src/diff_file.c @@ -259,10 +259,35 @@ static int diff_file_content_load_blob( return error; } +static int diff_file_content_load_workdir_symlink_fake( + git_diff_file_content *fc, git_buf *path) +{ + git_buf target = GIT_BUF_INIT; + int error; + + if ((error = git_futils_readbuffer(&target, path->ptr)) < 0) + return error; + + fc->map.len = git_buf_len(&target); + fc->map.data = git_buf_detach(&target); + fc->flags |= GIT_DIFF_FLAG__FREE_DATA; + + git_buf_free(&target); + return error; +} + static int diff_file_content_load_workdir_symlink( git_diff_file_content *fc, git_buf *path) { ssize_t alloc_len, read_len; + int symlink_supported, error; + + if ((error = git_repository__cvar( + &symlink_supported, fc->repo, GIT_CVAR_SYMLINKS)) < 0) + return -1; + + if (!symlink_supported) + return diff_file_content_load_workdir_symlink_fake(fc, path); /* link path on disk could be UTF-16, so prepare a buffer that is * big enough to handle some UTF-8 data expansion |