commit - 97bcb0b4a3c4503d5e035bac764bfbd0f156c8c6
commit + fc231b0cbd4f9b7b4821015419df075df8f074d4
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 - b559a190d58cd65bb489e31cdd7a513cd617ad23
blob + 3585d3fd9e9dfed09d79bb77c765b02a02ed8ecc
--- 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 - 40f181f83c2ab22ed7603f5e5e399bb86752005b
blob + e7c1581010362a4731ab5cf5b603663f3282aac3
--- 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;
}