From: Stefan Sperling Subject: tog: avoid got_repo_map_path() in worktree To: gameoftrees@openbsd.org Date: Fri, 13 Nov 2020 19:50:02 +0100 If tog can resolve an in-repository path via a work tree, do not use got_repo_map_path(). This matches what got now does as well. ok? diff 41605754d020cd4be569b2dffdfac47451ea8925 /home/stsp/src/got blob - 3895e44e1cc2bd3dcc96dbcbd7369ecad839c9b0 file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -2595,21 +2595,18 @@ get_in_repo_path_from_argv0(char **in_repo_path, int a if (worktree) { const char *prefix = got_worktree_get_path_prefix(worktree); - char *wt_path, *p; + char *p; - err = got_worktree_resolve_path(&wt_path, worktree, argv[0]); + err = got_worktree_resolve_path(&p, worktree, argv[0]); if (err) return err; - - if (asprintf(&p, "%s%s%s", prefix, - (strcmp(prefix, "/") != 0) ? "/" : "", wt_path) == -1) { + if (asprintf(in_repo_path, "%s%s%s", prefix, + (p[0] != '\0' && !got_path_is_root_dir(prefix)) ? "/" : "", + p) == -1) { err = got_error_from_errno("asprintf"); - free(wt_path); - return err; + *in_repo_path = NULL; } - err = got_repo_map_path(in_repo_path, repo, p, 0); free(p); - free(wt_path); } else err = got_repo_map_path(in_repo_path, repo, argv[0], 1);