commit - 271d2a38b1a788e9bbd0865e35ee14dce08b5197
commit + a143fb78680e46194d8a68b0fcd96b57d164a6d0
blob - 8ee905e2acc8ab92a9c22b4fee62e04990d46a0e
blob + 65f2e530842a66c066ddafb9f0879a4bc0f8c9f5
--- lib/worktree.c
+++ lib/worktree.c
struct got_repository *repo, got_worktree_checkout_cb progress_cb,
void *progress_arg, got_worktree_cancel_cb cancel_cb, void *cancel_arg)
{
- const struct got_error *err = NULL, *unlockerr;
+ const struct got_error *err = NULL, *unlockerr, *checkout_err = NULL;
struct got_commit_object *commit = NULL;
struct got_tree_object *tree = NULL;
char *fileindex_path = NULL, *new_fileindex_path = NULL;
if (err)
goto done;
- err = tree_checkout(worktree, fileindex, tree, "/", repo,
- progress_cb, progress_arg, cancel_cb, cancel_arg);
- if (err)
- goto done;
+ checkout_err = tree_checkout(worktree, fileindex, tree, "/", repo,
+ progress_cb, progress_arg, cancel_cb, cancel_arg);
+ /* Try to sync the fileindex back to disk in any case. */
err = got_fileindex_write(fileindex, new_index);
if (err)
goto done;
free(new_fileindex_path);
free(fileindex_path);
got_fileindex_free(fileindex);
+ if (checkout_err)
+ err = checkout_err;
unlockerr = lock_worktree(worktree, LOCK_SH);
if (unlockerr && err == NULL)
err = unlockerr;