commit - 247140b28268236ea5c77457b01d6dec936ffb51
commit + c7f4312fa3469fb36fb0cc087ca64846744a5533
blob - 7634022d459777ec21a6b7f7af7c711f06879feb
blob + 97264cf27d57e9cd53202e2485893ca73899d36b
--- got/got.c
+++ got/got.c
if (error != NULL)
goto done;
- error = apply_unveil(got_repo_get_path(repo), worktree_path);
+ error = apply_unveil(got_repo_get_path(repo),
+ got_worktree_get_root_path(worktree));
if (error)
goto done;
blob - eb06c1c83638358bcdb853f29755a94983b589d3
blob + 768ca6a234213e1f696abed31c0a4266f2e2e612
--- include/got_worktree.h
+++ include/got_worktree.h
void got_worktree_close(struct got_worktree *);
/*
+ * Get the path to the root directory of a worktree.
+ */
+const char *got_worktree_get_root_path(struct got_worktree *);
+
+/*
* Get the path to the repository associated with a worktree.
*/
const char *got_worktree_get_repo_path(struct got_worktree *);
blob - 77ab90b75f8f9d50abc0ed34fd125ec5cb522153
blob + b5a1c93ac214af54a1e83bcb21763aee46b40e61
--- lib/fileindex.c
+++ lib/fileindex.c
static const struct got_error *
diff_fileindex_dir(struct got_fileindex *, struct got_fileindex_entry **, DIR *,
- const char *, struct got_repository *, struct got_fileindex_diff_dir_cb *,
- void *);
+ const char *, const char *, struct got_repository *,
+ struct got_fileindex_diff_dir_cb *, void *);
static const struct got_error *
walk_dir(struct got_pathlist_entry **next, struct got_fileindex *fileindex,
struct got_fileindex_entry **ie, struct got_pathlist_entry *dle,
- const char *path, DIR *dir, struct got_repository *repo,
- struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
+ const char *path, DIR *dir, const char *rootpath,
+ struct got_repository *repo, struct got_fileindex_diff_dir_cb *cb,
+ void *cb_arg)
{
const struct got_error *err = NULL;
struct dirent *de = dle->data;
if (de->d_type == DT_DIR) {
char *subpath;
+ char *subdirpath;
DIR *subdir;
if (asprintf(&subpath, "%s%s%s", path,
path[0] == '\0' ? "" : "/", de->d_name) == -1)
return got_error_from_errno();
- subdir = opendir(subpath);
+ if (asprintf(&subdirpath, "%s/%s", rootpath, subpath) == -1) {
+ free(subpath);
+ return got_error_from_errno();
+ }
+
+ subdir = opendir(subdirpath);
if (subdir == NULL) {
+ #if 0
free(subpath);
+ free(subdirpath);
+ #endif
return got_error_from_errno();
}
- err = diff_fileindex_dir(fileindex, ie, subdir, subpath, repo,
- cb, cb_arg);
+ err = diff_fileindex_dir(fileindex, ie, subdir, rootpath,
+ subpath, repo, cb, cb_arg);
free(subpath);
+ free(subdirpath);
closedir(subdir);
if (err)
return err;
static const struct got_error *
diff_fileindex_dir(struct got_fileindex *fileindex,
- struct got_fileindex_entry **ie, DIR *dir, const char *path,
- struct got_repository *repo, struct got_fileindex_diff_dir_cb *cb,
- void *cb_arg)
+ struct got_fileindex_entry **ie, DIR *dir, const char *rootpath,
+ const char *path, struct got_repository *repo,
+ struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
{
const struct got_error *err = NULL;
struct dirent *de = NULL;
break;
*ie = walk_fileindex(fileindex, *ie);
err = walk_dir(&dle, fileindex, ie, dle, path,
- dir, repo, cb, cb_arg);
+ dir, rootpath, repo, cb, cb_arg);
} else if (cmp < 0 ) {
next = walk_fileindex(fileindex, *ie);
err = cb->diff_old(cb_arg, *ie, path);
if (err)
break;
err = walk_dir(&dle, fileindex, ie, dle, path,
- dir, repo, cb, cb_arg);
+ dir, rootpath, repo, cb, cb_arg);
}
if (err)
break;
if (err)
break;
err = walk_dir(&dle, fileindex, ie, dle, path, dir,
- repo, cb, cb_arg);
+ rootpath, repo, cb, cb_arg);
if (err)
break;
}
}
const struct got_error *
-got_fileindex_diff_dir(struct got_fileindex *fileindex, DIR *dir,
- struct got_repository *repo, struct got_fileindex_diff_dir_cb *cb,
- void *cb_arg)
+got_fileindex_diff_dir(struct got_fileindex *fileindex, DIR *rootdir,
+ const char *rootpath, struct got_repository *repo,
+ struct got_fileindex_diff_dir_cb *cb, void *cb_arg)
{
struct got_fileindex_entry *min;
min = RB_MIN(got_fileindex_tree, &fileindex->entries);
- return diff_fileindex_dir(fileindex, &min, dir, "", repo, cb, cb_arg);
+ return diff_fileindex_dir(fileindex, &min, rootdir, rootpath, "",
+ repo, cb, cb_arg);
}
RB_GENERATE(got_fileindex_tree, got_fileindex_entry, entry, got_fileindex_cmp);
blob - f0befafd414a2ddcc56bb4f17a888939a7824d52
blob + 64bfc70abd5e42a3ce6e3949277cf7b625f4a843
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
got_fileindex_diff_dir_new_cb diff_new;
};
const struct got_error *got_fileindex_diff_dir(struct got_fileindex *, DIR *,
- struct got_repository *, struct got_fileindex_diff_dir_cb *, void *);
+ const char *, struct got_repository *, struct got_fileindex_diff_dir_cb *,
+ void *);
blob - 66bb12d1ff6c5832e73f92e7f73928f0892a631a
blob + f4d98f7208b7cbd0bf5d9a9ea8b0af5fe29a606c
--- lib/worktree.c
+++ lib/worktree.c
}
const char *
+got_worktree_get_root_path(struct got_worktree *worktree)
+{
+ return worktree->root_path;
+}
+
+const char *
got_worktree_get_repo_path(struct got_worktree *worktree)
{
return worktree->repo_path;
arg.status_arg = status_arg;
arg.cancel_cb = cancel_cb;
arg.cancel_arg = cancel_arg;
- err = got_fileindex_diff_dir(fileindex, workdir, repo, &fdiff_cb, &arg);
+ err = got_fileindex_diff_dir(fileindex, workdir, worktree->root_path,
+ repo, &fdiff_cb, &arg);
done:
if (workdir)
closedir(workdir);