commit a143fb78680e46194d8a68b0fcd96b57d164a6d0 from: Stefan Sperling date: Tue Dec 25 14:59:11 2018 UTC try to sync file index to disk if checkout hits an error commit - 271d2a38b1a788e9bbd0865e35ee14dce08b5197 commit + a143fb78680e46194d8a68b0fcd96b57d164a6d0 blob - 8ee905e2acc8ab92a9c22b4fee62e04990d46a0e blob + 65f2e530842a66c066ddafb9f0879a4bc0f8c9f5 --- lib/worktree.c +++ lib/worktree.c @@ -630,7 +630,7 @@ got_worktree_checkout_files(struct got_worktree *workt 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; @@ -668,11 +668,10 @@ got_worktree_checkout_files(struct got_worktree *workt 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; @@ -697,6 +696,8 @@ 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;