commit - fdf001a7fe7090e3571dfbbfd1d49159c2416756
commit + 7ac97322017b91dbd1c5468717efc62243a851df
blob - 39e5396de674d23b30ab7cdcfc555a29b0187952
blob + ae61678471cf7d1a0be8eb2f6793a23954d2637e
--- lib/worktree.c
+++ lib/worktree.c
#include "got_path_priv.h"
static const struct got_error *
-create_meta_file(const char *gotpath, const char *name, const char *content)
+create_meta_file(const char *path_got, const char *name, const char *content)
{
const struct got_error *err = NULL;
char *path;
char buf[4];
ssize_t n;
- if (asprintf(&path, "%s/%s", gotpath, name) == -1) {
+ if (asprintf(&path, "%s/%s", path_got, name) == -1) {
err = got_error(GOT_ERR_NO_MEM);
path = NULL;
goto done;
}
static const struct got_error *
-read_meta_file(char **content, const char *gotpath, const char *name)
+read_meta_file(char **content, const char *path_got, const char *name)
{
const struct got_error *err = NULL;
char *path;
*content = NULL;
- if (asprintf(&path, "%s/%s", gotpath, name) == -1) {
+ if (asprintf(&path, "%s/%s", path_got, name) == -1) {
err = got_error(GOT_ERR_NO_MEM);
path = NULL;
goto done;
const char *prefix, struct got_repository *repo)
{
const struct got_error *err = NULL;
- char *gotpath = NULL;
+ char *path_got = NULL;
char *refstr = NULL;
char *path_repos = NULL;
char *formatstr = NULL;
}
/* Create .got directory (may already exist). */
- if (asprintf(&gotpath, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
+ if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
err = got_error(GOT_ERR_NO_MEM);
goto done;
}
- if (mkdir(gotpath, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
+ if (mkdir(path_got, GOT_DEFAULT_DIR_MODE) == -1 && errno != EEXIST) {
err = got_error_from_errno();
goto done;
}
/* Create an empty lock file. */
- err = create_meta_file(gotpath, GOT_WORKTREE_LOCK, NULL);
+ err = create_meta_file(path_got, GOT_WORKTREE_LOCK, NULL);
if (err)
goto done;
/* Create an empty file index. */
- err = create_meta_file(gotpath, GOT_WORKTREE_FILE_INDEX, NULL);
+ err = create_meta_file(path_got, GOT_WORKTREE_FILE_INDEX, NULL);
if (err)
goto done;
/* Set base commit to empty. */
- err = create_meta_file(gotpath, GOT_WORKTREE_BASE_COMMIT, NULL);
+ err = create_meta_file(path_got, GOT_WORKTREE_BASE_COMMIT, NULL);
if (err)
goto done;
err = got_error(GOT_ERR_NO_MEM);
goto done;
}
- err = create_meta_file(gotpath, GOT_WORKTREE_HEAD, refstr);
+ err = create_meta_file(path_got, GOT_WORKTREE_HEAD, refstr);
if (err)
goto done;
err = got_error(GOT_ERR_NO_MEM);
goto done;
}
- err = create_meta_file(gotpath, GOT_WORKTREE_REPOSITORY, path_repos);
+ err = create_meta_file(path_got, GOT_WORKTREE_REPOSITORY, path_repos);
if (err)
goto done;
/* Store in-repository path prefix. */
- err = create_meta_file(gotpath, GOT_WORKTREE_PATH_PREFIX, prefix);
+ err = create_meta_file(path_got, GOT_WORKTREE_PATH_PREFIX, prefix);
if (err)
goto done;
err = got_error(GOT_ERR_NO_MEM);
goto done;
}
- err = create_meta_file(gotpath, GOT_WORKTREE_FORMAT, formatstr);
+ err = create_meta_file(path_got, GOT_WORKTREE_FORMAT, formatstr);
if (err)
goto done;
done:
- free(gotpath);
+ free(path_got);
free(formatstr);
free(refstr);
free(path_repos);
got_worktree_open(struct got_worktree **worktree, const char *path)
{
const struct got_error *err = NULL;
- char *gotpath;
+ char *path_got;
char *refstr = NULL;
char *path_repos = NULL;
char *formatstr = NULL;
*worktree = NULL;
- if (asprintf(&gotpath, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
+ if (asprintf(&path_got, "%s/%s", path, GOT_WORKTREE_GOT_DIR) == -1) {
err = got_error(GOT_ERR_NO_MEM);
- gotpath = NULL;
+ path_got = NULL;
goto done;
}
- if (asprintf(&path_lock, "%s/%s", gotpath, GOT_WORKTREE_LOCK) == -1) {
+ if (asprintf(&path_lock, "%s/%s", path_got, GOT_WORKTREE_LOCK) == -1) {
err = got_error(GOT_ERR_NO_MEM);
path_lock = NULL;
goto done;
goto done;
}
- err = read_meta_file(&formatstr, gotpath, GOT_WORKTREE_FORMAT);
+ err = read_meta_file(&formatstr, path_got, GOT_WORKTREE_FORMAT);
if (err)
goto done;
err = got_error(GOT_ERR_NO_MEM);
goto done;
}
- err = read_meta_file(&(*worktree)->path_repo, gotpath,
+ err = read_meta_file(&(*worktree)->path_repo, path_got,
GOT_WORKTREE_REPOSITORY);
if (err)
goto done;
- err = read_meta_file(&(*worktree)->path_prefix, gotpath,
+ err = read_meta_file(&(*worktree)->path_prefix, path_got,
GOT_WORKTREE_PATH_PREFIX);
goto done;
done:
- free(gotpath);
+ free(path_got);
free(path_lock);
if (err) {
if (fd != -1)