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(
GIT_DIR_MODE, GIT_MKDIR_VERIFY_DIR)) < 0)
goto cleanup;
if ((error = git_repository_index(&data->index, data->repo)) < 0)
goto cleanup;
/* refresh config and index content unless NO_REFRESH is given */
if ((data->opts.checkout_strategy & GIT_CHECKOUT_NO_REFRESH) == 0) {
git_config *cfg;
......@@ -2404,13 +2407,10 @@ static int checkout_data_init(
if ((error = git_repository_config__weakptr(&cfg, repo)) < 0)
goto cleanup;
/* Get the repository index and reload it (unless we're checking
* out the index; then it has the changes we're trying to check
* out and those should not be overwritten.)
/* Reload the repository index (unless we're checking out the
* index; then it has the changes we're trying to check out
* 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 ((error = git_index_read(data->index, true)) < 0)
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