Subject: Re: [PATCH v6 16/30] compat/fsmonitor/fsm-listen-darwin: add MacOS header files for FSEvent

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Mon, 07 Mar 2022 11:37:25 +0100

On Tue, Mar 01 2022, Jeff Hostetler via GitGitGadget wrote:

> From: Jeff Hostetler <[email-masked]>
> [...]
> +#define kFSEventStreamEventFlagNone               0x00000000
> +#define kFSEventStreamEventFlagMustScanSubDirs    0x00000001
> +#define kFSEventStreamEventFlagUserDropped        0x00000002
> +#define kFSEventStreamEventFlagKernelDropped      0x00000004
> +#define kFSEventStreamEventFlagEventIdsWrapped    0x00000008
> +#define kFSEventStreamEventFlagHistoryDone        0x00000010
> +#define kFSEventStreamEventFlagRootChanged        0x00000020
> +#define kFSEventStreamEventFlagMount              0x00000040
> +#define kFSEventStreamEventFlagUnmount            0x00000080
> +#define kFSEventStreamEventFlagItemCreated        0x00000100
> +#define kFSEventStreamEventFlagItemRemoved        0x00000200
> +#define kFSEventStreamEventFlagItemInodeMetaMod   0x00000400
> +#define kFSEventStreamEventFlagItemRenamed        0x00000800
> +#define kFSEventStreamEventFlagItemModified       0x00001000
> +#define kFSEventStreamEventFlagItemFinderInfoMod  0x00002000
> +#define kFSEventStreamEventFlagItemChangeOwner    0x00004000
> +#define kFSEventStreamEventFlagItemXattrMod       0x00008000
> +#define kFSEventStreamEventFlagItemIsFile         0x00010000
> +#define kFSEventStreamEventFlagItemIsDir          0x00020000
> +#define kFSEventStreamEventFlagItemIsSymlink      0x00040000
> +#define kFSEventStreamEventFlagOwnEvent           0x00080000
> +#define kFSEventStreamEventFlagItemIsHardlink     0x00100000
> +#define kFSEventStreamEventFlagItemIsLastHardlink 0x00200000
> +#define kFSEventStreamEventFlagItemCloned         0x00400000

Can we define these as 1<<0, 1<<1, 1<<2 etc.? We do that in most other
places, and it helps to quickly eyeball these and see that they don't
have gaps.

> +#define kCFStringEncodingUTF8 0x08000100

Should this be an OR of some of the above, or is it unrelated?

> +typedef struct FSEventStreamContext FSEventStreamContext;
> +typedef unsigned int FSEventStreamEventFlags;
> +#define kFSEventStreamCreateFlagNoDefer 0x02
> +#define kFSEventStreamCreateFlagWatchRoot 0x04
> +#define kFSEventStreamCreateFlagFileEvents 0x10

Ditto 1<<0 etc.

> +#else
> +/*
> + * Let Apple's headers declare `isalnum()` first, before
> + * Git's headers override it via a constant
> + */

> +#include <string.h>
> +#include <CoreFoundation/CoreFoundation.h>
> +#include <CoreServices/CoreServices.h>
> +#endif

In cache.h which you'rejust about to include we don't include string.h,
but we do in git-compat-util.h, but that one includes string.h before
doing those overrides.

This either isn't needed, or really should be some addition to
git-compat-util.h instead. I.e. if we've missed some edge case with
string.h and ctype.h on OSX we should handle that in git-compat-util.h
rather than <some other file/header> needing a portability workaround.

> +
>  #include "cache.h"
>  #include "fsmonitor.h"
>  #include "fsm-listen.h"