diff options
| author | Vicent Martà <vicent@github.com> | 2013-05-06 06:51:21 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2013-05-06 06:51:21 -0700 |
| commit | 3405f78754703948475b4677d03fcdbfb099b6a4 (patch) | |
| tree | d9c99f66802bb9ba5aefa92b80c77678184c2a0d | |
| parent | 03c28d92d00074f1501cb0d7ce9f5e3e0154a244 (diff) | |
| parent | 00a4c4793890e9a8f6ad6f538d445111d6c73d54 (diff) | |
| download | libgit2-3405f78754703948475b4677d03fcdbfb099b6a4.tar.gz | |
Merge pull request #1547 from ethomson/win32_stat
p_stat() should follow symlinks on windows
| -rw-r--r-- | src/win32/posix_w32.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c index a817d4245..52eb4638a 100644 --- a/src/win32/posix_w32.c +++ b/src/win32/posix_w32.c @@ -295,7 +295,18 @@ int p_getcwd(char *buffer_out, size_t size) int p_stat(const char* path, struct stat* buf) { - return do_lstat(path, buf, 0); + char target[GIT_WIN_PATH]; + int error = 0; + + error = do_lstat(path, buf, 0); + + /* We need not do this in a loop to unwind chains of symlinks since + * p_readlink calls GetFinalPathNameByHandle which does it for us. */ + if (error >= 0 && S_ISLNK(buf->st_mode) && + (error = p_readlink(path, target, GIT_WIN_PATH)) >= 0) + error = do_lstat(target, buf, 0); + + return error; } int p_chdir(const char* path) |
