summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-11-12 20:50:00 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2018-06-26 12:38:35 +0100
commit88b30f51e4af4bf75400ae4252365f851546642a (patch)
treed3536359966cf7dd8e745c9a5934b89762b3813d /src/checkout.c
parent7330ae670f59a79257d1de2e40324ccfcf966448 (diff)
downloadlibgit2-88b30f51e4af4bf75400ae4252365f851546642a.tar.gz
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.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/checkout.c b/src/checkout.c
index c6936bf28..0ab2c6aca 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -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;