commit - affd85fdd69bb67d27045196a798015ad4479e0d
commit + ad10f64ebeae9e8625205b8ef468ce58e03db95b
blob - 110ff29fdcc380ec042d16545ed9b818b713b3c7
blob + d5843bbce4cf6da211bc8e9a2c23bddcd868ba19
--- cvg/cvg.1
+++ cvg/cvg.1
.Pa config
file.
.Pp
-.It Pa .got/got.conf
+.It Pa .cvg/got.conf
Worktree-specific configuration settings for
.Nm .
If present, a
.Xr got.conf 5
configuration file in the
-.Pa .got
+.Pa .cvg
meta-data directory of a work tree supersedes any relevant settings in
the repository's
.Xr got.conf 5
blob - 95de495e64d65f7ef5087c0ae6d7afebcfafd007
blob + 713ac6213adf64d341195a912b6044a3298a0c80
--- cvg/cvg.c
+++ cvg/cvg.c
if (error != NULL)
goto done;
- error = got_worktree_init(worktree_path, head_ref, path_prefix, repo);
+ error = got_worktree_init(worktree_path, head_ref, path_prefix,
+ GOT_WORKTREE_CVG_DIR, repo);
if (error != NULL && !(error->code == GOT_ERR_ERRNO && errno == EEXIST))
goto done;
- error = got_worktree_open(&worktree, worktree_path);
+ error = got_worktree_open(&worktree, worktree_path, GOT_WORKTREE_CVG_DIR);
if (error != NULL)
goto done;
error = got_error_from_errno("getcwd");
goto done;
}
- error = got_worktree_open(&worktree, worktree_path);
+ error = got_worktree_open(&worktree, worktree_path, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "update",
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
error = NULL;
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "status", cwd);
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "add", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "remove", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error != NULL)
goto done;
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "revert", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "commit", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (list_refs || remove_refs) {
if (error->code != GOT_ERR_NOT_WORKTREE)
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (list_refs || remove_refs) {
if (error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree) {
goto done;
}
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_CVG_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "info", cwd);
blob - 722e3f26795dd133e885ae9c4d0ddd32ae4ef4b8
blob + 0681017334f8726d46e09b4d07a0ff76ca7f5b98
--- got/got.c
+++ got/got.c
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
if (error != NULL)
goto done;
- error = got_worktree_init(worktree_path, head_ref, path_prefix, repo);
+ error = got_worktree_init(worktree_path, head_ref, path_prefix,
+ GOT_WORKTREE_GOT_DIR, repo);
if (error != NULL && !(error->code == GOT_ERR_ERRNO && errno == EEXIST))
goto done;
- error = got_worktree_open(&worktree, worktree_path);
+ error = got_worktree_open(&worktree, worktree_path,
+ GOT_WORKTREE_GOT_DIR);
if (error != NULL)
goto done;
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, worktree_path);
+ error = got_worktree_open(&worktree, worktree_path,
+ GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "update",
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
error = NULL;
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "status", cwd);
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd,
+ GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "add", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "remove", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error != NULL)
goto done;
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "revert", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "commit", cwd);
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
else
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (list_refs || remove_refs) {
if (error->code != GOT_ERR_NOT_WORKTREE)
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (list_refs || remove_refs) {
if (error->code != GOT_ERR_NOT_WORKTREE)
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (list_backups || delete_backups) {
if (error->code != GOT_ERR_NOT_WORKTREE)
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (list_backups || delete_backups) {
if (error->code != GOT_ERR_NOT_WORKTREE)
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "integrate",
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error,
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "stage", cwd);
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "unstage", cwd);
goto done;
if (repo_path == NULL) {
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree) {
goto done;
}
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, GOT_WORKTREE_GOT_DIR);
if (error) {
if (error->code == GOT_ERR_NOT_WORKTREE)
error = wrap_not_worktree_error(error, "info", cwd);
blob - afce9e2f9b1e5a863de3014628402fe232f36894
blob + d99d2c4bcdc53e7934088a9b34c228b51e84daf1
--- gotadmin/gotadmin.c
+++ gotadmin/gotadmin.c
if (cwd == NULL)
return got_error_from_errno("getcwd");
- err = got_worktree_open(&worktree, cwd);
+ err = got_worktree_open(&worktree, cwd, NULL);
if (err) {
if (err->code != GOT_ERR_NOT_WORKTREE)
goto done;
blob - 5b0b7259e6ff5fc0edf8711ac6780dd49315fe54
blob + 53e320eef8622a3384a31606d0cd2fe64d9ea60a
--- include/got_worktree.h
+++ include/got_worktree.h
#define GOT_STATUS_BASE_REF_ERR 'B'
#define GOT_STATUS_CANNOT_UPDATE '#'
+/* Also defined in got_lib_worktree.h in case got_worktree.h is not included. */
+#define GOT_WORKTREE_GOT_DIR ".got"
+#define GOT_WORKTREE_CVG_DIR ".cvg"
+
/*
* Attempt to initialize a new work tree on disk.
* The first argument is the path to a directory where the work tree
* of the path must already exist.
* The reference provided will be used to determine the new worktree's
* base commit. The third argument speficies the work tree's path prefix.
+ * The fourth argument specifies the meta data directory to use, which
+ * should be either GOT_WORKTREE_GOT_DIR or GOT_WORKTREE_CVG_DIR.
*/
const struct got_error *got_worktree_init(const char *, struct got_reference *,
- const char *, struct got_repository *);
+ const char *, const char *, struct got_repository *);
/*
- * Attempt to open a worktree at or above the specified path.
+ * Attempt to open a worktree at or above the specified path, using
+ * the specified meta data directory which should be either be NULL
+ * in which case a meta directory is auto-discovered, or be one of
+ * GOT_WORKTREE_GOT_DIR and GOT_WORKTREE_CVG_DIR.
* The caller must dispose of it with got_worktree_close().
*/
-const struct got_error *got_worktree_open(struct got_worktree **, const char *);
+const struct got_error *got_worktree_open(struct got_worktree **,
+ const char *path, const char *meta_dir);
/* Dispose of an open work tree. */
const struct got_error *got_worktree_close(struct got_worktree *);
blob - 6a29089f0442bf1d89182fbe94b4324e943dfb94
blob + 633fbef71fbfd1a5c044f93fc954198b06d9fb18
--- lib/error.c
+++ lib/error.c
{ GOT_ERR_BAD_REF_DATA, "could not parse reference data" },
{ GOT_ERR_TREE_DUP_ENTRY,"duplicate entry in tree object" },
{ GOT_ERR_DIR_DUP_ENTRY,"duplicate entry in directory" },
- { GOT_ERR_NOT_WORKTREE, "no got work tree found" },
+ { GOT_ERR_NOT_WORKTREE, "no work tree found" },
{ GOT_ERR_UUID_VERSION, "bad uuid version" },
{ GOT_ERR_UUID_INVALID, "uuid invalid" },
{ GOT_ERR_UUID, "uuid error" },
blob - ea52f0b95b730a506409d1fee9c8f88c42b9ca11
blob + 1c024e5aeeb4acd603dceef48511e13ebd6a8389
--- lib/fileindex.c
+++ lib/fileindex.c
if (strcmp(de->d_name, ".") == 0 ||
strcmp(de->d_name, "..") == 0 ||
(path[0] == '\0' &&
- strcmp(de->d_name, GOT_WORKTREE_GOT_DIR) == 0)) {
+ strcmp(de->d_name, GOT_WORKTREE_GOT_DIR) == 0) ||
+ (path[0] == '\0' &&
+ strcmp(de->d_name, GOT_WORKTREE_CVG_DIR) == 0)) {
free(de);
continue;
}
blob - ad838e489f8aceca0aa34848ae7cb128cb78dd53
blob + 8404383b2b9474368777c6f7dcb3a552605c907a
--- lib/got_lib_worktree.h
+++ lib/got_lib_worktree.h
struct got_worktree {
char *root_path;
+ const char *meta_dir;
char *repo_path;
int root_fd;
char *path_prefix;
#define GOT_COMMITABLE_ADDED 0x01
};
+/* Also defined in got_worktree.h */
+#ifndef GOT_WORKTREE_GOT_DIR
#define GOT_WORKTREE_GOT_DIR ".got"
+#endif
+#ifndef GOT_WORKTREE_CVG_DIR
+#define GOT_WORKTREE_CVG_DIR ".cvg"
+#endif
+
#define GOT_WORKTREE_FILE_INDEX "file-index"
#define GOT_WORKTREE_REPOSITORY "repository"
#define GOT_WORKTREE_PATH_PREFIX "path-prefix"
blob - 5016750ce73d6b7a793df2a669389225f19ad9c0
blob + 7cfa2e83d5c136bc98a0f67c5afab910de51a462
--- lib/worktree.c
+++ lib/worktree.c
const struct got_error *
got_worktree_init(const char *path, struct got_reference *head_ref,
- const char *prefix, struct got_repository *repo)
+ const char *prefix, const char *meta_dir, struct got_repository *repo)
{
const struct got_error *err = NULL;
struct got_object_id *commit_id = NULL;
goto done;
}
- /* Create .got directory (may already exist). */
- if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
+ /* Create .got/.cvg directory (may already exist). */
+ if (asprintf(&path_got, "%s/%s", path, meta_dir) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
char *path_got = NULL, *head_ref_name = NULL;
if (asprintf(&path_got, "%s/%s", worktree->root_path,
- GOT_WORKTREE_GOT_DIR) == -1) {
+ worktree->meta_dir) == -1) {
err = got_error_from_errno("asprintf");
path_got = NULL;
goto done;
char *path_got = NULL;
if (asprintf(&path_got, "%s/%s", worktree->root_path,
- GOT_WORKTREE_GOT_DIR) == -1) {
+ worktree->meta_dir) == -1) {
err = got_error_from_errno("asprintf");
path_got = NULL;
goto done;
static const struct got_error *
is_bad_symlink_target(int *is_bad_symlink, const char *target_path,
- size_t target_len, const char *ondisk_path, const char *wtroot_path)
+ size_t target_len, const char *ondisk_path, const char *wtroot_path,
+ const char *meta_dir)
{
const struct got_error *err = NULL;
char canonpath[PATH_MAX];
return NULL;
}
- /* Do not allow symlinks pointing into the .got directory. */
- if (asprintf(&path_got, "%s/%s", wtroot_path,
- GOT_WORKTREE_GOT_DIR) == -1)
+ /* Do not allow symlinks pointing into the meta directory. */
+ if (asprintf(&path_got, "%s/%s", wtroot_path, meta_dir) == -1)
return got_error_from_errno("asprintf");
if (got_path_is_child(canonpath, path_got, strlen(path_got)))
*is_bad_symlink = 1;
target_path[target_len] = '\0';
err = is_bad_symlink_target(is_bad_symlink, target_path, target_len,
- ondisk_path, worktree->root_path);
+ ondisk_path, worktree->root_path, worktree->meta_dir);
if (err)
return err;
struct got_worktree *worktree)
{
if (asprintf(path, "%s/%s/%s", worktree->root_path,
- GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_HISTEDIT_SCRIPT) == -1) {
+ worktree->meta_dir, GOT_WORKTREE_HISTEDIT_SCRIPT) == -1) {
*path = NULL;
return got_error_from_errno("asprintf");
}
const struct got_error *err = NULL;
if (asprintf(fileindex_path, "%s/%s/%s", worktree->root_path,
- GOT_WORKTREE_GOT_DIR, GOT_WORKTREE_FILE_INDEX) == -1) {
+ worktree->meta_dir, GOT_WORKTREE_FILE_INDEX) == -1) {
err = got_error_from_errno("asprintf");
*fileindex_path = NULL;
}
goto done;
}
err = is_bad_symlink_target(&is_bad_symlink, target_path,
- target_len, ct->ondisk_path, a->worktree->root_path);
+ target_len, ct->ondisk_path, a->worktree->root_path,
+ a->worktree->meta_dir);
if (err)
goto done;
if (is_bad_symlink) {
}
err = is_bad_symlink_target(&is_bad_symlink,
target_path, target_len, ondisk_path,
- a->worktree->root_path);
+ a->worktree->root_path,
+ a->worktree->meta_dir);
if (err)
break;
if (is_bad_symlink) {
blob - da26fa9ba9a5717c35d77d398c8661e5fa721527
blob + 5e907496b89f49a5b541e0d5556b7bff8d65f838
--- lib/worktree_open.c
+++ lib/worktree_open.c
#include "got_lib_worktree.h"
#include "got_lib_gotconfig.h"
+#ifndef nitems
+#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
+#endif
+
static const struct got_error *
read_meta_file(char **content, const char *path_got, const char *name)
{
}
static const struct got_error *
-open_worktree(struct got_worktree **worktree, const char *path)
+open_worktree(struct got_worktree **worktree, const char *path,
+ const char *meta_dir)
{
const struct got_error *err = NULL;
- char *path_got;
+ char *path_meta;
char *formatstr = NULL;
char *uuidstr = NULL;
char *path_lock = NULL;
*worktree = NULL;
- if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
+ if (asprintf(&path_meta, "%s/%s", path, meta_dir) == -1) {
err = got_error_from_errno("asprintf");
- path_got = NULL;
+ path_meta = NULL;
goto done;
}
- if (asprintf(&path_lock, "%s/%s", path_got, GOT_WORKTREE_LOCK) == -1) {
+ if (asprintf(&path_lock, "%s/%s", path_meta, GOT_WORKTREE_LOCK) == -1) {
err = got_error_from_errno("asprintf");
path_lock = NULL;
goto done;
goto done;
}
- err = read_meta_file(&formatstr, path_got, GOT_WORKTREE_FORMAT);
+ err = read_meta_file(&formatstr, path_meta, GOT_WORKTREE_FORMAT);
if (err)
goto done;
err = got_error_from_errno2("realpath", path);
goto done;
}
- err = read_meta_file(&(*worktree)->repo_path, path_got,
+ (*worktree)->meta_dir = meta_dir;
+ err = read_meta_file(&(*worktree)->repo_path, path_meta,
GOT_WORKTREE_REPOSITORY);
if (err)
goto done;
- err = read_meta_file(&(*worktree)->path_prefix, path_got,
+ err = read_meta_file(&(*worktree)->path_prefix, path_meta,
GOT_WORKTREE_PATH_PREFIX);
if (err)
goto done;
- err = read_meta_file(&base_commit_id_str, path_got,
+ err = read_meta_file(&base_commit_id_str, path_meta,
GOT_WORKTREE_BASE_COMMIT);
if (err)
goto done;
- err = read_meta_file(&uuidstr, path_got, GOT_WORKTREE_UUID);
+ err = read_meta_file(&uuidstr, path_meta, GOT_WORKTREE_UUID);
if (err)
goto done;
uuid_from_string(uuidstr, &(*worktree)->uuid, &uuid_status);
if (err)
goto done;
- err = read_meta_file(&(*worktree)->head_ref_name, path_got,
+ err = read_meta_file(&(*worktree)->head_ref_name, path_meta,
GOT_WORKTREE_HEAD_REF);
if (err)
goto done;
if (asprintf(&(*worktree)->gotconfig_path, "%s/%s/%s",
- (*worktree)->root_path,
- GOT_WORKTREE_GOT_DIR, GOT_GOTCONFIG_FILENAME) == -1) {
+ (*worktree)->root_path, (*worktree)->meta_dir,
+ GOT_GOTCONFIG_FILENAME) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
if (err == NULL)
err = pack_err;
}
- free(path_got);
+ free(path_meta);
free(path_lock);
free(base_commit_id_str);
free(uuidstr);
}
const struct got_error *
-got_worktree_open(struct got_worktree **worktree, const char *path)
+got_worktree_open(struct got_worktree **worktree, const char *path,
+ const char *meta_dir)
{
const struct got_error *err = NULL;
char *worktree_path;
+ const char *meta_dirs[] = {
+ GOT_WORKTREE_GOT_DIR,
+ GOT_WORKTREE_CVG_DIR
+ };
+ int i;
worktree_path = strdup(path);
if (worktree_path == NULL)
for (;;) {
char *parent_path;
- err = open_worktree(worktree, worktree_path);
+ if (meta_dir == NULL) {
+ for (i = 0; i < nitems(meta_dirs); i++) {
+ err = open_worktree(worktree, worktree_path,
+ meta_dirs[i]);
+ if (err == NULL)
+ break;
+ }
+ } else
+ err = open_worktree(worktree, worktree_path, meta_dir);
if (err && !(err->code == GOT_ERR_ERRNO && errno == ENOENT)) {
free(worktree_path);
return err;
blob - 592e477643b13ce4e2a8ce6037f11ee4ba539cdf
blob + c4c9f0b2ff7a958007c590e9b66a21cb9ad13a07
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
# 'got diff' in a repository without any arguments is an error
(cd $testroot/repo && got diff 2> $testroot/stderr)
- echo "got: no got work tree found" > $testroot/stderr.expected
+ echo "got: no work tree found" > $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret=$?
if [ $ret -ne 0 ]; then
test_done "$testroot" "1"
return 1
fi
- echo "got: specified paths cannot be resolved: no got work tree found" \
+ echo "got: specified paths cannot be resolved: no work tree found" \
> $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret=$?
blob - 22c6366282c4b644e5f36a4e1ab4a639793c4c0b
blob + abf8c21edb245a96720b8a92f3d1ea6fe1c6a36b
--- tog/tog.c
+++ tog/tog.c
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return got_error_from_errno("getcwd");
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, NULL);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree)
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return got_error_from_errno("getcwd");
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, NULL);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree)
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return got_error_from_errno("getcwd");
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, NULL);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree)
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return got_error_from_errno("getcwd");
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, NULL);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree)
cwd = getcwd(NULL, 0);
if (cwd == NULL)
return got_error_from_errno("getcwd");
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, NULL);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;
if (worktree)
if (error != NULL)
goto done;
- error = got_worktree_open(&worktree, cwd);
+ error = got_worktree_open(&worktree, cwd, NULL);
if (error && error->code != GOT_ERR_NOT_WORKTREE)
goto done;