git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/6] fsmonitor: Update helper tool, now that flags are filled later

From
AVAlex Vandiver <alexmv@dropbox.com>
Date
Dec 20, 2017, 21:12 UTC
Message-ID
<alpine.DEB.2.10.1712201259520.10810@alexmv-linux>
In-Reply-To
<e3246bad10b891d8e3f751b6ed368a9e3f37c425.1513642743.git.alexmv@dropbox.com>
On Mon, 18 Dec 2017, Alex Vandiver wrote:
Show 5 quoted lines
> dd9005a0a ("fsmonitor: delay updating state until after split index is
> merged", 2017-10-27) began deferring the setting of the
> CE_FSMONITOR_VALID flag until later, such that do_read_index() does
> not perform those steps.  This means that t/helper/test-dump-fsmonitor
> showed all bits as always unset.

This isn't the right fix, actually. With split indexes, this puts us right back into "only shows a few bits" territory, because do_read_index doesn't know about split indexes.

Which means we need a way to do the whole index load but _not_ add/remove the fsmonitor cache, even if the config says to do so.

The best I'm coming up with is the below -- but I'm not happy with it, because 'keep' is meaningless as a configuration value outside of testing, since it's normally treated as an executable path. This uses the fact that fsmonitor.c currently has a:

        switch (fsmonitor_enabled) {
        case -1: /* keep: do nothing */
                break;

...despite get_config_get_fsmonitor() havong no way to return -1 at present.

Is this sort of testing generally done via environment variables,
rather than magic config values?
 - Alex
---------------------8<----------------
diff --git a/config.c b/config.c
index 6fb06c213..75fcf1a52 100644
--- a/config.c
+++ b/config.c
@@ -2164,8 +2164,13 @@ int git_config_get_fsmonitor(void)
        if (core_fsmonitor && !*core_fsmonitor)
                core_fsmonitor = NULL;

-       if (core_fsmonitor)
-               return 1;
+
+       if (core_fsmonitor) {
+               if (!strcasecmp(core_fsmonitor, "keep"))
+                       return -1;
+               else
+                       return 1;
+       }

        return 0;
 }
diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c
index ad452707e..12e131530 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
@@ -5,8 +5,9 @@ int cmd_main(int ac, const char **av)
        struct index_state *istate = &the_index;
        int i;

+       git_config_push_parameter("core.fsmonitor=keep");
        setup_git_directory();
-       if (do_read_index(istate, get_index_file(), 0) < 0)
+       if (read_index_from(istate, get_index_file()) < 0)
                die("unable to read index file");
        if (!istate->fsmonitor_last_update) {
                printf("no fsmonitor\n");
-----------------8<---------------------
Previous: Alex VandiverNext: Alex Vandiver
Message 12 of 16 in “Minor fsmonitor bugfixes, use with `git diff`”
  1. 0/6 Minor fsmonitor bugfixes, use with `git diff`Alex Vandiver, Dec 19, 2017
  2. 1/6 Fix comments to agree with argument nameAlex Vandiver, Dec 19, 2017
  3. 2/6 fsmonitor: Add dir.h include, for untracked_cache_invalidate_pathAlex Vandiver, Dec 19, 2017
  4. Junio C HamanoDec 19, 2017
  5. Alex VandiverDec 20, 2017
  6. Junio C HamanoDec 21, 2017
  7. 4/6 fsmonitor: Add a trailing newline to test-dump-fsmonitorAlex Vandiver, Dec 19, 2017
  8. Junio C HamanoDec 19, 2017
  9. Alex VandiverDec 21, 2017
  10. Junio C HamanoDec 21, 2017
  11. 3/6 fsmonitor: Update helper tool, now that flags are filled laterAlex Vandiver, Dec 19, 2017
  12. Alex VandiverDec 20, 2017
  13. 6/6 fsmonitor: Use fsmonitor data in `git diff`Alex Vandiver, Dec 19, 2017
  14. 5/6 fsmonitor: Remove debugging lines from t/t7519-status-fsmonitor.shAlex Vandiver, Dec 19, 2017
  15. Junio C HamanoDec 19, 2017
  16. Johannes SchindelinDec 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.