commit 963f97a1f258c5d517ee748dfeb9855262cfad11 from: Stefan Sperling date: Mon Mar 18 16:16:32 2019 UTC make 'tog log' resolve paths just like 'got log' does it commit - b70703ad8ae920fd55bd7976d1632e05975e5c63 commit + 963f97a1f258c5d517ee748dfeb9855262cfad11 blob - 64b0fb3e07eb9692849032563e898ee916cf2d00 blob + 1a7431f898376074dd8afb26bfad4c19dc2abbe8 --- tog/tog.c +++ tog/tog.c @@ -1853,34 +1853,44 @@ cmd_log(int argc, char *argv[]) argc -= optind; argv += optind; - - if (argc == 0) - path = strdup(""); - else if (argc == 1) - path = strdup(argv[0]); - else - usage_log(); - if (path == NULL) - return got_error_from_errno(); cwd = getcwd(NULL, 0); if (cwd == NULL) { error = got_error_from_errno(); goto done; } - 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)); - } else - repo_path = strdup(cwd); - if (repo_path == NULL) { + error = got_worktree_open(&worktree, cwd); + if (error && error->code != GOT_ERR_NOT_WORKTREE) + goto done; + error = NULL; + + if (argc == 0) { + path = strdup(""); + if (path == NULL) { error = got_error_from_errno(); goto done; } + } else if (argc == 1) { + if (worktree) { + error = got_worktree_resolve_path(&path, worktree, + argv[0]); + if (error) + goto done; + } else { + path = strdup(argv[0]); + if (path == NULL) { + error = got_error_from_errno(); + goto done; + } + } + } else + usage_log(); + + repo_path = worktree ? + strdup(got_worktree_get_repo_path(worktree)) : strdup(cwd); + if (repo_path == NULL) { + error = got_error_from_errno(); + goto done; } init_curses();