Download raw body.
tog: worktree vs. -r repo
On Thu, Dec 17, 2020 at 11:21:19PM +0100, Christian Weisgerber wrote: > When tog is started in a work tree associated with repository A, > with the command option -r pointing to a different repository B, > then tog will fetch some data from A and try to apply it in the > context of B. > > $ cd got # work tree associated with got.git > $ tog log -r ~/src.git # OpenBSD src repository > tog: reference refs/heads/main not found > > tog log, blame, tree all fail in the same way. > The corresponding got commands do not. Thanks! This fixes it for me: diff a46ac2cbc24e20b46540307ad7cfa4fca47c566a f2ad1d487ff0ad8471b8946dcb07196036121f90 blob - 334d9a659f385c9de036c79d21a1a527807feeb6 blob + d4a6773bbcbe53cf05658170c71476a035aaccf8 --- tog/tog.c +++ tog/tog.c @@ -2673,7 +2673,7 @@ cmd_log(int argc, char *argv[]) char *start_commit = NULL, *label = NULL; struct got_reference *ref = NULL; const char *head_ref_name = NULL; - int ch, log_branches = 0; + int ch, log_branches = 0, rflag = 0; struct tog_view *view; while ((ch = getopt(argc, argv, "bc:r:")) != -1) { @@ -2689,6 +2689,7 @@ cmd_log(int argc, char *argv[]) if (repo_path == NULL) return got_error_from_errno2("realpath", optarg); + rflag = 1; break; default: usage_log(); @@ -2727,7 +2728,7 @@ cmd_log(int argc, char *argv[]) goto done; error = get_in_repo_path_from_argv0(&in_repo_path, argc, argv, - repo, worktree); + repo, rflag ? NULL : worktree); if (error) goto done; @@ -2740,8 +2741,9 @@ cmd_log(int argc, char *argv[]) if (start_commit == NULL) { error = got_repo_match_object_id(&start_id, &label, - worktree ? got_worktree_get_head_ref_name(worktree) : - GOT_REF_HEAD, GOT_OBJ_TYPE_COMMIT, 1, repo); + (!rflag && worktree) ? + got_worktree_get_head_ref_name(worktree) : GOT_REF_HEAD, + GOT_OBJ_TYPE_COMMIT, 1, repo); if (error) goto done; head_ref_name = label; @@ -4653,7 +4655,7 @@ cmd_blame(int argc, char *argv[]) char *link_target = NULL; struct got_object_id *commit_id = NULL; char *commit_id_str = NULL; - int ch; + int ch, rflag = 0;; struct tog_view *view; while ((ch = getopt(argc, argv, "c:r:")) != -1) { @@ -4666,6 +4668,7 @@ cmd_blame(int argc, char *argv[]) if (repo_path == NULL) return got_error_from_errno2("realpath", optarg); + rflag = 1; break; default: usage_blame(); @@ -4704,7 +4707,7 @@ cmd_blame(int argc, char *argv[]) goto done; error = get_in_repo_path_from_argv0(&in_repo_path, argc, argv, repo, - worktree); + rflag ? NULL : worktree); if (error) goto done; @@ -4716,7 +4719,7 @@ cmd_blame(int argc, char *argv[]) if (commit_id_str == NULL) { struct got_reference *head_ref; - error = got_ref_open(&head_ref, repo, worktree ? + error = got_ref_open(&head_ref, repo, (!rflag && worktree) ? got_worktree_get_head_ref_name(worktree) : GOT_REF_HEAD, 0); if (error != NULL) goto done; @@ -5465,7 +5468,7 @@ cmd_tree(int argc, char *argv[]) struct got_tree_object *tree = NULL; struct got_reference *ref = NULL; const char *head_ref_name = NULL; - int ch; + int ch, rflag = 0; struct tog_view *view; while ((ch = getopt(argc, argv, "c:r:")) != -1) { @@ -5478,6 +5481,7 @@ cmd_tree(int argc, char *argv[]) if (repo_path == NULL) return got_error_from_errno2("realpath", optarg); + rflag = 1; break; default: usage_tree(); @@ -5516,7 +5520,7 @@ cmd_tree(int argc, char *argv[]) goto done; error = get_in_repo_path_from_argv0(&in_repo_path, argc, argv, - repo, worktree); + repo, rflag ? NULL : worktree); if (error) goto done; @@ -5528,8 +5532,9 @@ cmd_tree(int argc, char *argv[]) if (commit_id_arg == NULL) { error = got_repo_match_object_id(&commit_id, &label, - worktree ? got_worktree_get_head_ref_name(worktree) : - GOT_REF_HEAD, GOT_OBJ_TYPE_COMMIT, 1, repo); + (!rflag && worktree) ? + got_worktree_get_head_ref_name(worktree) : GOT_REF_HEAD, + GOT_OBJ_TYPE_COMMIT, 1, repo); if (error) goto done; head_ref_name = label;
tog: worktree vs. -r repo