commit - 55bd499d8ff69fab8462d256adae072aa762727f
commit + 347d1d3e2dfb259ebdcaf3ce280b6dcdcedcaa6f
blob - cf788412d7d82a9e76021c6f880b299fe5b307f2
blob + 1bd7e852da64d1f96f8debd8b8ab459dff0a64a8
--- lib/worktree.c
+++ lib/worktree.c
return err;
}
-const struct got_error *
-got_worktree_status(struct got_worktree *worktree, const char *path,
- struct got_repository *repo, got_worktree_status_cb status_cb,
- void *status_arg, got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+static const struct got_error *
+worktree_status(struct got_worktree *worktree, const char *path,
+ struct got_fileindex *fileindex, struct got_repository *repo,
+ got_worktree_status_cb status_cb, void *status_arg,
+ got_worktree_cancel_cb cancel_cb, void *cancel_arg)
{
const struct got_error *err = NULL;
DIR *workdir = NULL;
- char *fileindex_path = NULL;
- struct got_fileindex *fileindex = NULL;
struct got_fileindex_diff_dir_cb fdiff_cb;
struct diff_dir_cb_arg arg;
char *ondisk_path = NULL;
- err = open_fileindex(&fileindex, &fileindex_path, worktree);
- if (err)
- return err;
-
if (asprintf(&ondisk_path, "%s%s%s",
worktree->root_path, path[0] ? "/" : "", path) == -1) {
err = got_error_from_errno("asprintf");
if (workdir)
closedir(workdir);
free(ondisk_path);
+ return err;
+}
+
+const struct got_error *
+got_worktree_status(struct got_worktree *worktree, const char *path,
+ struct got_repository *repo, got_worktree_status_cb status_cb,
+ void *status_arg, got_worktree_cancel_cb cancel_cb, void *cancel_arg)
+{
+ const struct got_error *err = NULL;
+ char *fileindex_path = NULL;
+ struct got_fileindex *fileindex = NULL;
+
+ err = open_fileindex(&fileindex, &fileindex_path, worktree);
+ if (err)
+ return err;
+
+ err = worktree_status(worktree, path, fileindex, repo,
+ status_cb, status_arg, cancel_cb, cancel_arg);
free(fileindex_path);
got_fileindex_free(fileindex);
return err;
if (err)
goto done;
+ err = open_fileindex(&fileindex, &fileindex_path, worktree);
+ if (err)
+ goto done;
+
err = got_ref_open(&head_ref, repo, worktree->head_ref_name, 0);
if (err)
goto done;
cc_arg.commitable_paths = &commitable_paths;
cc_arg.worktree = worktree;
cc_arg.repo = repo;
- err = got_worktree_status(worktree, relpath ? relpath : "",
- repo, collect_commitables, &cc_arg, NULL, NULL);
+ err = worktree_status(worktree, relpath ? relpath : "",
+ fileindex, repo, collect_commitables, &cc_arg, NULL, NULL);
if (err)
goto done;
if (err)
goto done;
- err = open_fileindex(&fileindex, &fileindex_path, worktree);
- if (err)
- goto done;
-
err = update_fileindex_after_commit(&commitable_paths,
*new_commit_id, fileindex, worktree);
if (err)
if (err)
goto done;
- crp_arg.revertible_paths = &revertible_paths;
- crp_arg.worktree = worktree;
- err = got_worktree_status(worktree, "", repo,
- collect_revertible_paths, &crp_arg, NULL, NULL);
+ err = open_fileindex(&fileindex, &fileindex_path, worktree);
if (err)
goto done;
- err = open_fileindex(&fileindex, &fileindex_path, worktree);
+ crp_arg.revertible_paths = &revertible_paths;
+ crp_arg.worktree = worktree;
+ err = worktree_status(worktree, "", fileindex, repo,
+ collect_revertible_paths, &crp_arg, NULL, NULL);
if (err)
goto done;