From: Junio C Hamano Date: Mon, 24 Sep 2018 17:30:46 +0000 (-0700) Subject: Merge branch 'bp/mv-submodules-with-fsmonitor' X-Git-Tag: v2.20.0-rc0~221 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9715f10e4206c681313d45efa239a594a0027e60?hp=-c Merge branch 'bp/mv-submodules-with-fsmonitor' When fsmonitor is in use, after operation on submodules updates .gitmodules, we lost track of the fact that we did so and relied on stale fsmonitor data. * bp/mv-submodules-with-fsmonitor: git-mv: allow submodules and fsmonitor to work together --- 9715f10e4206c681313d45efa239a594a0027e60 diff --combined submodule.c index ed05339b58,1c6d4215f5..b53cb6e9c4 --- a/submodule.c +++ b/submodule.c @@@ -22,7 -22,6 +22,7 @@@ #include "worktree.h" #include "parse-options.h" #include "object-store.h" +#include "commit-reach.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; static struct string_list changed_submodule_names = STRING_LIST_INIT_DUP; @@@ -66,8 -65,7 +66,7 @@@ int is_staging_gitmodules_ok(struct ind if ((pos >= 0) && (pos < istate->cache_nr)) { struct stat st; if (lstat(GITMODULES_FILE, &st) == 0 && - ie_match_stat(istate, istate->cache[pos], &st, - CE_MATCH_IGNORE_FSMONITOR) & DATA_CHANGED) + ie_match_stat(istate, istate->cache[pos], &st, 0) & DATA_CHANGED) return 0; } @@@ -94,7 -92,7 +93,7 @@@ int update_path_in_gitmodules(const cha if (!file_exists(GITMODULES_FILE)) /* Do nothing without .gitmodules */ return -1; - if (is_gitmodules_unmerged(&the_index)) + if (is_gitmodules_unmerged(the_repository->index)) die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first")); submodule = submodule_from_path(the_repository, &null_oid, oldpath); @@@ -128,7 -126,7 +127,7 @@@ int remove_path_from_gitmodules(const c if (!file_exists(GITMODULES_FILE)) /* Do nothing without .gitmodules */ return -1; - if (is_gitmodules_unmerged(&the_index)) + if (is_gitmodules_unmerged(the_repository->index)) die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first")); submodule = submodule_from_path(the_repository, &null_oid, path); @@@ -189,7 -187,7 +188,7 @@@ void set_diffopt_flags_from_submodule_c if (ignore) handle_ignore_submodules_arg(diffopt, ignore); - else if (is_gitmodules_unmerged(&the_index)) + else if (is_gitmodules_unmerged(the_repository->index)) diffopt->flags.ignore_submodules = 1; } } @@@ -259,7 -257,7 +258,7 @@@ int is_submodule_active(struct reposito } parse_pathspec(&ps, 0, 0, NULL, args.argv); - ret = match_pathspec(&ps, path, strlen(path), 0, NULL, 1); + ret = match_pathspec(repo->index, &ps, path, strlen(path), 0, NULL, 1); argv_array_clear(&args); clear_pathspec(&ps); @@@ -518,8 -516,8 +517,8 @@@ static void show_submodule_header(struc * Attempt to lookup the commit references, and determine if this is * a fast forward or fast backwards update. */ - *left = lookup_commit_reference(one); - *right = lookup_commit_reference(two); + *left = lookup_commit_reference(the_repository, one); + *right = lookup_commit_reference(the_repository, two); /* * Warn about missing commits in the submodule project, but only if @@@ -537,7 -535,7 +536,7 @@@ fast_backward = 1; } - if (!oidcmp(one, two)) { + if (oideq(one, two)) { strbuf_release(&sb); return; } @@@ -741,14 -739,12 +740,14 @@@ static void collect_changed_submodules_ else { name = default_name_or_path(p->two->path); /* make sure name does not collide with existing one */ - submodule = submodule_from_name(the_repository, commit_oid, name); + if (name) + submodule = submodule_from_name(the_repository, + commit_oid, name); if (submodule) { warning("Submodule in commit %s at path: " "'%s' collides with a submodule named " "the same. Skipping it.", - oid_to_hex(commit_oid), name); + oid_to_hex(commit_oid), p->two->path); name = NULL; } } @@@ -1671,7 -1667,7 +1670,7 @@@ int submodule_move_head(const char *pat argv_array_push(&cp.args, new_head ? new_head : empty_tree_oid_hex()); if (run_command(&cp)) { - ret = -1; + ret = error(_("Submodule '%s' could not be updated."), path); goto out; }