From: K Jayatheerth Date: Tue, 03 Nov 2026 02:54:21 GMT Subject: Re: [GSoC Patch v7 8/8] repo: add path.cdup Message-ID: In-Reply-To: On Tue, Nov 3, 2026 at 4:50 AM Justin Tobler wrote: > > 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? > We should just return early. You are right. I will do that. > > + } > > + > > + 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. > Oh whoops, that wasn't intended. Yeah this clearly just cds into non test env altering common files. Will fix it. > > + 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 Thank you for the review! - K Jayatheerth