Subject: Re: [PATCH v6 4/8] core.fsyncobjectfiles: add windows support for batch mode

From: Junio C Hamano <[email-masked]>
Date: Mon, 27 Sep 2021 13:07:11 -0700

"Neeraj Singh via GitGitGadget" <[email-masked]> writes:

> diff --git a/compat/mingw.h b/compat/mingw.h
> index c9a52ad64a6..6074a3d3ced 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -329,6 +329,9 @@ int mingw_getpagesize(void);
>  #define getpagesize mingw_getpagesize
>  #endif
>  
> +int win32_fsync_no_flush(int fd);
> +#define fsync_no_flush win32_fsync_no_flush

...

> diff --git a/wrapper.c b/wrapper.c
> index bb4f9f043ce..1a1e2fba9c9 100644
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -567,6 +567,10 @@ int git_fsync(int fd, enum fsync_action action)
>  						 SYNC_FILE_RANGE_WAIT_AFTER);
>  #endif
>  
> +#ifdef fsync_no_flush
> +		return fsync_no_flush(fd);
> +#endif
> +
>  		errno = ENOSYS;
>  		return -1;

This almost makes me wonder if we want to have a fallback
implementation of fsync_no_flush() that does

   int fsync_no_flush(int unused)
   {
	errno = ENOSYS;
	return -1;
   }

when nobody (like Windows) define their own fsync_no_flush().  That
way, this codepath does not have to have #ifdef/#endif here.

This function is already #ifdef ridden anyway, so reducing just one
instance may not make much difference, but since I noticed it ...

Thanks.