make 'got cat' not search for a work tree if the -r option is used Fixes failures in our test suite if 'got tag -l | less' is used in the work tree while cmdline tests are running.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/got/got.c b/got/got.c
index c317c15..337e093 100644
--- a/got/got.c
+++ b/got/got.c
@@ -11879,28 +11879,29 @@ cmd_cat(int argc, char *argv[])
error = got_error_from_errno("getcwd");
goto done;
}
- error = got_worktree_open(&worktree, cwd);
- if (error && error->code != GOT_ERR_NOT_WORKTREE)
- goto done;
- if (worktree) {
- if (repo_path == NULL) {
+
+ if (repo_path == NULL) {
+ error = got_worktree_open(&worktree, cwd);
+ if (error && error->code != GOT_ERR_NOT_WORKTREE)
+ goto done;
+ if (worktree) {
repo_path = strdup(
got_worktree_get_repo_path(worktree));
if (repo_path == NULL) {
error = got_error_from_errno("strdup");
goto done;
}
- }
- /* Release work tree lock. */
- got_worktree_close(worktree);
- worktree = NULL;
+ /* Release work tree lock. */
+ got_worktree_close(worktree);
+ worktree = NULL;
+ }
}
if (repo_path == NULL) {
- repo_path = getcwd(NULL, 0);
+ repo_path = strdup(cwd);
if (repo_path == NULL)
- return got_error_from_errno("getcwd");
+ return got_error_from_errno("strdup");
}
error = got_repo_open(&repo, repo_path, NULL);