Commit 88b30f51 by Edward Thomson

checkout: always set the index in checkout data

Always set the `index` in the `checkout_data`, even in the case that we
are not reloading the index.  Other functionality in checkout examines
the index (for example: determining whether the workdir is modified) and
we need it even in the (uncommon) case that we are not reloading.
parent 7330ae67
...@@ -2397,6 +2397,9 @@ static int checkout_data_init( ...@@ -2397,6 +2397,9 @@ static int checkout_data_init(
GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0) GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0)
goto cleanup; goto cleanup;
if ((error = git_repository_index(&data->index, data->repo)) < 0)
goto cleanup;
/* refresh config and index content unless NO_REFRESH is given */ /* refresh config and index content unless NO_REFRESH is given */
if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) { if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
git_config *cfg; git_config *cfg;
...@@ -2404,13 +2407,10 @@ static int checkout_data_init( ...@@ -2404,13 +2407,10 @@ static int checkout_data_init(
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0) if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
goto cleanup; goto cleanup;
/* Get the repository index and reload it (unless we're checking /* Reload the repository index (unless we're checking out the
* out the index; then it has the changes we're trying to check * index; then it has the changes we're trying to check out
* out and those should not be overwritten.) * and those should not be overwritten.)
*/ */
if ((error = git_repository_index(&data->index, data->repo)) < 0)
goto cleanup;
if (data->index != git_iterator_index(target)) { if (data->index != git_iterator_index(target)) {
if ((error = git_index_read(data->index, true)) < 0) if ((error = git_index_read(data->index, true)) < 0)
goto cleanup; goto cleanup;
......
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