Skip to content

Commit

Permalink
symlinks: make watchman report symlinks
Browse files Browse the repository at this point in the history
Summary:
This diff makes Watchman report the proper filemode for symlinks on Windows, which makes `hg status` and other related commands work for the old Python status. Note that some additional changes are still needed to make the new Rust status command work with watchman.

This change also makes `test-symlinks.t` work with watchman on Windows

Reviewed By: quark-zju

Differential Revision: D47451133

fbshipit-source-id: c9f93ea7a2add7684983f92b9daec0846c766f5d
  • Loading branch information
sggutier authored and facebook-github-bot committed Aug 22, 2023
1 parent caa55ad commit 465d7d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions watchman/fs/FileInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ FileInformation::FileInformation(uint32_t dwFileAttributes)
mode = 0666;
}
if (fileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
// It's a symlink, but to be msvc compatible, we report
// this as a file. Note that a reparse point can also
// have FILE_ATTRIBUTE_DIRECTORY set if the symlink was
// created with the intention of it appearing as a file.
mode |= _S_IFREG;
// Report it as a symlink. This is used by source control
// to detect symlinks.
mode |= S_IFLNK;
} else if (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
mode |= _S_IFDIR | 0111 /* executable/searchable */;
} else {
Expand Down
1 change: 1 addition & 0 deletions watchman/fs/FileInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static_assert(S_IFMT == 0xF000, "The S_IFMT on Windows should be 0xF000");
#define DT_CHR ((_S_IFCHR) >> 12)
#define DT_DIR ((_S_IFDIR) >> 12)
#define DT_REG ((_S_IFREG) >> 12)
#define S_IFLNK 0xA000

#endif

Expand Down

0 comments on commit 465d7d8

Please sign in to comment.