commit - 70cea17ff7df1d1c70cefb074ffba2d8749ca4a3
commit + ce725b8f7be2659fcbebc5ec00062bac1ca85d29
blob - b64451095294474244135e83c0947ddcc71fdb8a
blob + b3efb7a1754e389658c138d5f0b67b755f923bf8
--- include/got_worktree.h
+++ include/got_worktree.h
/* Complete the patch operation. */
const struct got_error *
-got_worktree_patch_complete(struct got_fileindex *, const char *);
+got_worktree_patch_complete(struct got_worktree *, struct got_fileindex *,
+ const char *);
blob - 91c3f6f39b56d17a00286c9df20fe296b864650c
blob + 199fbf39d0ab1b0f251632eac6e1152e9b8d27ae
--- lib/patch.c
+++ lib/patch.c
}
done:
- if (fileindex != NULL)
- complete_err = got_worktree_patch_complete(fileindex,
- fileindex_path);
+ complete_err = got_worktree_patch_complete(worktree, fileindex,
+ fileindex_path);
if (complete_err && err == NULL)
err = complete_err;
free(fileindex_path);
blob - 56a6662106eec9f8fe5d71909c8c9712a67c3eed
blob + d77591144bbc72cce50b033ae51afa7a8c5cfb6b
--- lib/worktree.c
+++ lib/worktree.c
char **fileindex_path, struct got_worktree *worktree,
struct got_repository *repo)
{
+ const struct got_error *err;
+
+ err = lock_worktree(worktree, LOCK_EX);
+ if (err)
+ return err;
+
return open_fileindex(fileindex, fileindex_path, worktree,
got_repo_get_object_format(repo));
}
}
const struct got_error *
-got_worktree_patch_complete(struct got_fileindex *fileindex,
+got_worktree_patch_complete(struct got_worktree *worktree,
+ struct got_fileindex *fileindex,
const char *fileindex_path)
{
- const struct got_error *err = NULL;
+ const struct got_error *err = NULL, *unlock_err;
- err = sync_fileindex(fileindex, fileindex_path);
- got_fileindex_free(fileindex);
+ if (fileindex) {
+ err = sync_fileindex(fileindex, fileindex_path);
+ got_fileindex_free(fileindex);
+ }
+ unlock_err = lock_worktree(worktree, LOCK_UN);
+ if (unlock_err && err == NULL)
+ err = unlock_err;
+
return err;
}