fsm-listen-win32: handle shortnames
commit40f865dc025cfb91ee6338f688c06cdc65b53fa0
authorJeff Hostetler <jeffhost@microsoft.com>
Thu, 26 May 2022 21:46:55 +0000 (26 21:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 22:59:25 +0000 (26 15:59 -0700)
tree78a83118b1d5439d86af60bddf1c6a3708893266
parent852e2c84f847d99e29fd08feb8cea881dca63c79
fsm-listen-win32: handle shortnames

Teach FSMonitor daemon on Windows to recognize shortname paths as
aliases of normal longname paths.  FSMonitor clients, such as `git
status`, should receive the longname spelling of changed files (when
possible).

Sometimes we receive FS events using the shortname, such as when a CMD
shell runs "RENAME GIT~1 FOO" or "RMDIR GIT~1".  The FS notification
arrives using whatever combination of long and shortnames were used by
the other process.  (Shortnames do seem to be case normalized,
however.)

Use Windows GetLongPathNameW() to try to map the pathname spelling in
the notification event into the normalized longname spelling.  (This
can fail if the file/directory is deleted, moved, or renamed, because
we are asking the FS for the mapping in response to the event and
after it has already happened, but we try.)

Special case the shortname spelling of ".git" to avoid under-reporting
these events.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/fsmonitor/fsm-listen-win32.c
t/t7527-builtin-fsmonitor.sh