commit 442a3ddc59a2c8a06621dd008f5449481939cbc4 from: Stefan Sperling date: Mon Apr 23 07:38:37 2018 UTC try to infer repository path from work tree commit - e3306bd98bc7e2ca355c082a7db8660aaf3fb699 commit + 442a3ddc59a2c8a06621dd008f5449481939cbc4 blob - 3666d5bce24758194183e573ddf33cc2dd733953 blob + c71005801f910cd48a3a315d6e91126c82dde3f4 --- got/got.c +++ got/got.c @@ -449,7 +449,7 @@ cmd_log(int argc, char *argv[]) const char *errstr; #ifndef PROFILE - if (pledge("stdio rpath wpath cpath proc", NULL) == -1) + if (pledge("stdio rpath wpath cpath flock proc", NULL) == -1) err(1, "pledge"); #endif @@ -623,7 +623,7 @@ cmd_diff(int argc, char *argv[]) int ch; #ifndef PROFILE - if (pledge("stdio rpath wpath cpath proc", NULL) == -1) + if (pledge("stdio rpath wpath cpath flock proc", NULL) == -1) err(1, "pledge"); #endif blob - 611e9526b1ab2357953b99cd6ef6703388720a13 blob + fa438dbb0d40c4058f0a9906b50419ccf3d738b8 --- lib/repository.c +++ lib/repository.c @@ -27,6 +27,7 @@ #include "got_error.h" #include "got_reference.h" #include "got_repository.h" +#include "got_worktree.h" #include "got_lib_path.h" #include "got_lib_delta.h" @@ -34,6 +35,7 @@ #include "got_lib_object.h" #include "got_lib_pack.h" #include "got_lib_repository.h" +#include "got_lib_worktree.h" #ifndef nitems #define nitems(_a) (sizeof(_a) / sizeof((_a)[0])) @@ -184,6 +186,28 @@ got_repo_open(struct got_repository **ret, const char goto done; } if (!is_git_repo(repo)) { + struct got_worktree *worktree; + if (got_worktree_open(&worktree, repo->path) == NULL) { + free(repo->path_git_dir); + repo->path_git_dir = + strdup(worktree->repo_path); + if (repo->path_git_dir == NULL) { + err = got_error_from_errno(); + goto done; + } + if (!is_git_repo(repo)) { + free(repo->path_git_dir); + if (asprintf(&repo->path_git_dir, + "%s/%s", worktree->repo_path, + GOT_GIT_DIR) == -1) { + err = got_error_from_errno(); + goto done; + } + } + got_worktree_close(worktree); + } + } + if (!is_git_repo(repo)) { err = got_error(GOT_ERR_NOT_GIT_REPO); goto done; } blob - 0058276d9ffc15cf54575813b1acc5eb96b1a99c blob + 605897bc12d293b738391522d9efbee802cb54c8 --- regress/repository/Makefile +++ regress/repository/Makefile @@ -2,7 +2,8 @@ PROG = repository_test SRCS = path.c repository.c error.c reference.c object.c sha1.c diff.c \ - diffreg.c pack.c privsep.c delta.c zbuf.c repository_test.c + diffreg.c pack.c privsep.c delta.c fileindex.c worktree.c \ + zbuf.c repository_test.c CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib LDADD = -lutil -lz