From: Justin Tobler Date: Mon, 02 Nov 2026 23:20:48 GMT Subject: Re: [GSoC Patch v7 8/8] repo: add path.cdup Message-ID: In-Reply-To: <20260927114420.59724-9-jayatheerthkulkarni2005@gmail.com> On 26/09/27 05:14PM, K Jayatheerth wrote: [snip] > +static int get_path_cdup(struct repository *repo, struct strbuf *buf) > +{ > + const char *pfx = repo->prefix; > + > + if (!is_inside_work_tree(repo)) { > + const char *worktree = repo_get_work_tree(repo); > + > + if (worktree) { > + strbuf_addstr(buf, worktree); > + } nit: The curly braces on a single line if statement are not needed. Also, should we just return early if we are not inside a worktree? > + } > + > + while (pfx) { > + pfx = strchr(pfx, '/'); > + if (pfx) { > + pfx++; > + strbuf_addstr(buf, "../"); > + } > + } > + return 0; > +} > + [snip] > +test_expect_success 'path.cdup cwd outside the working tree' ' > + test_when_finished "rm -rf repo" && > + mkdir -p repo/tmp/x && > + cd repo && This cd isn't in a subshell, so it changes the working directory for every following test, which I don't think was intended. > + git init test && > + ( > + echo path.cdup=$(pwd)/tmp/x >./test/expect && > + cd test && > + GIT_WORK_TREE=../tmp/x && > + export GIT_WORK_TREE && > + GIT_DIR=$(pwd)/.git && > + export GIT_DIR && > + git repo info path.cdup >actual && > + test_cmp expect actual > + ) -Justin