Merge branch 'bp/mv-submodules-with-fsmonitor' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 13:57:43 +0000 (22:57 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Nov 2018 13:57:43 +0000 (22:57 +0900)
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

1  2 
submodule.c
diff --combined submodule.c
index a2b266fbfae2cd89b00a11008fbcd28bf09777e2,1c6d4215f56d425b93a42232caecf658240e66b3..4a5212bdfb4ab9ce5aac4a4c4460fbc9c9ecff38
@@@ -65,8 -65,7 +65,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;
        }
  
@@@ -93,7 -92,7 +92,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);
@@@ -127,7 -126,7 +126,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);
@@@ -188,7 -187,7 +187,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;
        }
  }
@@@ -258,7 -257,7 +257,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);
@@@ -517,8 -516,8 +516,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
@@@ -740,14 -739,12 +739,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;
                        }
                }
@@@ -1670,7 -1667,7 +1669,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;
        }