On Thu, May 19, 2016 at 11:45 PM, David Turner <[email protected]> wrote:
> From: Nguyễn Thái Ngọc Duy <[email protected]>
>
> The previous patch has the logic to clear bits in 'WAMA' bitmap. This
> patch has logic to set bits as told by watchman. The missing bit,
> _using_ these bits, are not here yet.
>
> A lot of this code is written by David Turner originally, mostly from
> [1]. I'm just copying and polishing it a bit.
>
> [1] http://article.gmane.org/gmane.comp.version-control.git/248006
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
> Signed-off-by: David Turner <[email protected]>
> ---
> Makefile | 12 +++++
> cache.h | 1 +
> config.c | 5 ++
> configure.ac | 8 ++++
> environment.c | 3 ++
> watchman-support.c | 135
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
> watchman-support.h | 7 +++
> 7 files changed, 171 insertions(+)
> create mode 100644 watchman-support.c
> create mode 100644 watchman-support.h
>
> diff --git a/Makefile b/Makefile
> index c8be0e7..65ab0f4 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -451,6 +451,7 @@ MSGFMT = msgfmt
> CURL_CONFIG = curl-config
> PTHREAD_LIBS = -lpthread
> PTHREAD_CFLAGS =
> +WATCHMAN_LIBS =
> GCOV = gcov
>
> export TCL_PATH TCLTK_PATH
> @@ -1416,6 +1417,13 @@ else
> LIB_OBJS += thread-utils.o
> endif
>
> +ifdef USE_WATCHMAN
> + LIB_H += watchman-support.h
> + LIB_OBJS += watchman-support.o
> + WATCHMAN_LIBS = -lwatchman
> + BASIC_CFLAGS += -DUSE_WATCHMAN
> +endif
> +
> ifdef HAVE_PATHS_H
> BASIC_CFLAGS += -DHAVE_PATHS_H
> endif
> @@ -2025,6 +2033,9 @@ git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS
> $(GITLIBS) $(VCSSVN_LIB)
> $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter
> %.o,$^) $(LIBS) \
> $(VCSSVN_LIB)
>
> +git-index-helper$X: index-helper.o GIT-LDFLAGS $(GITLIBS)
> + $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter
> %.o,$^) $(LIBS) $(WATCHMAN_LIBS)
> +
> $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
> $(QUIET_LNCP)$(RM) $@ && \
> ln $< $@ 2>/dev/null || \
> @@ -2164,6 +2175,7 @@ GIT-BUILD-OPTIONS: FORCE
> @echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\'
> >>$@+
> @echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst
> ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@+
> @echo NO_MMAP=\''$(subst ','\'',$(subst ','\'',$(NO_MMAP)))'\' >>$@+
> + @echo USE_WATCHMAN=\''$(subst ','\'',$(subst
> ','\'',$(USE_WATCHMAN)))'\' >>$@+
> ifdef TEST_OUTPUT_DIRECTORY
> @echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst
> ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
> endif
> diff --git a/cache.h b/cache.h
> index f10992d..452aea2 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -696,6 +696,7 @@ extern char *git_replace_ref_base;
>
> extern int fsync_object_files;
> extern int core_preload_index;
> +extern int core_watchman_sync_timeout;
> extern int core_apply_sparse_checkout;
> extern int precomposed_unicode;
> extern int protect_hfs;
> diff --git a/config.c b/config.c
> index 9ba40bc..e6dc141 100644
> --- a/config.c
> +++ b/config.c
> @@ -882,6 +882,11 @@ static int git_default_core_config(const char *var,
> const char *value)
> return 0;
> }
>
> + if (!strcmp(var, "core.watchmansynctimeout")) {
> + core_watchman_sync_timeout = git_config_int(var, value);
> + return 0;
> + }
> +
> if (!strcmp(var, "core.createobject")) {
> if (!strcmp(value, "rename"))
> object_creation_mode = OBJECT_CREATION_USES_RENAMES;
> diff --git a/configure.ac b/configure.ac
> index 0cd9f46..334d63b 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1099,6 +1099,14 @@ AC_COMPILE_IFELSE([BSD_SYSCTL_SRC],
> HAVE_BSD_SYSCTL=])
> GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
>
> +#
> +# Check for watchman client library
> +
> +AC_CHECK_LIB([watchman], [watchman_connect],
> + [USE_WATCHMAN=YesPlease],
> + [USE_WATCHMAN=])
> +GIT_CONF_SUBST([USE_WATCHMAN])
> +
> ## Other checks.
> # Define USE_PIC if you need the main git objects to be built with -fPIC
> # in order to build and link perl/Git.so. x86-64 seems to need this.
> diff --git a/environment.c b/environment.c
> index 6dec9d0..35e03c7 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -94,6 +94,9 @@ int core_preload_index = 1;
> */
> int ignore_untracked_cache_config;
>
> +int core_watchman_sync_timeout = 300;
> +
> +
Maybe remove one blank line above.
[...]
> +
> + if (!connection) {
> + warning("Watchman watch error: %s", wm_error.message);
> + return -1;
> + }
> +
> + if (watchman_watch(connection, fs_path, &wm_error)) {
> + warning("Watchman watch error: %s", wm_error.message);
> + watchman_connection_close(connection);
> + return -1;
> + }
> +
> +
Here also.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html