[PATCH] git-mv: allow submodules and fsmonitor to work together
- From
Stefan Beller <sbeller@google.com>
- Date
- Sep 6, 2018, 20:34 UTC
- Message-ID
- <20180906203444.162213-1-sbeller@google.com>
- In-Reply-To
- <CAGZ79kY_+jNAu4jwVOhd+gVMELDSjk_MACKBRf51tksrzZMx-A@mail.gmail.com>
It was reported that
GIT_FSMONITOR_TEST=$PWD/t7519/fsmonitor-all ./t7411-submodule-config.sh
breaks as the .gitmodules file is modified and staged after the fsmonitor considers it clean. Mark the .gitmodules file to be not clean before staging.
Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Inspired-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Stefan Beller <sbeller@google.com> ---
I am not quite sure if this is the correct approach and handling of the fsmonitor API, but it unbreaks the test.
> Just naively adding mark_fsmonitor_invalid doesn't work, as then ...
Adding it before the staging, works.
Please double check!
Thanks, Stefan
submodule.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/submodule.c b/submodule.c index 50cbf5f13ed..56b0d5fe24e 100644 --- a/submodule.c +++ b/submodule.c @@ -22,6 +22,7 @@ #include "worktree.h" #include "parse-options.h" #include "object-store.h" +#include "fsmonitor.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP; @@ -149,6 +150,15 @@ int remove_path_from_gitmodules(const char *path) void stage_updated_gitmodules(struct index_state *istate) { + struct cache_entry *ce; + int pos; + + pos = index_name_pos(istate, GITMODULES_FILE, strlen(GITMODULES_FILE)); + ce = (0 <= pos) ? istate->cache[pos] : NULL; + + if (ce) + mark_fsmonitor_invalid(istate, ce); + if (add_file_to_index(istate, GITMODULES_FILE, 0)) die(_("staging updated .gitmodules failed")); }
-- 2.19.0.rc2.392.g5ba43deb5a-goog