🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
2 messages
2 total messages Started by Justin Tobler Mon, 02 Nov 2026 23:20
Re: [GSoC Patch v7 8/8] repo: add path.cdup
#2195
Author: Justin Tobler
Date: Mon, 02 Nov 2026 23:20
52 lines
11846 bytes
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
Re: [GSoC Patch v7 8/8] repo: add path.cdup
#2211
Author: K Jayatheerth
Date: Tue, 03 Nov 2026 02:54
69 lines
13719 bytes
On Tue, Nov 3, 2026 at 4:50 AM Justin Tobler <jltobler@gmail.com> 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads