Commit f4b02671 by Edward Thomson Committed by Edward Thomson

submodule: reload HEAD/index after reading config

Reload the HEAD and index data for a submodule after reading the
configuration.  The configuration may specify a `path`, so we must
update HEAD and index data with that path in mind.
parent 790012ce
...@@ -1423,7 +1423,6 @@ static int submodule_update_head(git_submodule *submodule) ...@@ -1423,7 +1423,6 @@ static int submodule_update_head(git_submodule *submodule)
return 0; return 0;
} }
int git_submodule_reload(git_submodule *sm, int force) int git_submodule_reload(git_submodule *sm, int force)
{ {
int error = 0; int error = 0;
...@@ -1433,35 +1432,30 @@ int git_submodule_reload(git_submodule *sm, int force) ...@@ -1433,35 +1432,30 @@ int git_submodule_reload(git_submodule *sm, int force)
assert(sm); assert(sm);
/* refresh index data */ if (!git_repository_is_bare(sm->repo)) {
if ((error = submodule_update_index(sm)) < 0) /* refresh config data */
return error; mods = gitmodules_snapshot(sm->repo);
if (mods != NULL) {
/* refresh HEAD tree data */ error = submodule_read_config(sm, mods);
if ((error = submodule_update_head(sm)) < 0) git_config_free(mods);
return error;
/* done if bare */ if (error < 0)
if (git_repository_is_bare(sm->repo)) return error;
return error; }
/* refresh config data */ /* refresh wd data */
mods = gitmodules_snapshot(sm->repo); sm->flags &=
if (mods != NULL) { ~(GIT_SUBMODULE_STATUS_IN_WD |
error = submodule_read_config(sm, mods); GIT_SUBMODULE_STATUS__WD_OID_VALID |
git_config_free(mods); GIT_SUBMODULE_STATUS__WD_FLAGS);
if (error < 0) { error = submodule_load_from_wd_lite(sm);
return error;
}
} }
/* refresh wd data */ if (error == 0 && (error = submodule_update_index(sm)) == 0)
sm->flags &= error = submodule_update_head(sm);
~(GIT_SUBMODULE_STATUS_IN_WD | GIT_SUBMODULE_STATUS__WD_OID_VALID |
GIT_SUBMODULE_STATUS__WD_FLAGS);
return submodule_load_from_wd_lite(sm); return error;
} }
static void submodule_copy_oid_maybe( static void submodule_copy_oid_maybe(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment