Subject: Re: [PATCH v2 1/5] refs: make branchname helpers repository aware

From: Tian Yuchen <[email-masked]>
Date: Sun, 29 Mar 2026 00:54:20 +0800

Hi Shreyansh,

On 3/28/26 22:09, Shreyansh Paliwal wrote:

> @@ -5,6 +5,7 @@
>   #include "refs.h"
>   #include "setup.h"
>   #include "strbuf.h"
> +#include "repository.c"

I'm surprised that it doesn't cause any errors. Or maybe you haven't 
build it yet?

---

> -int check_branch_ref(struct strbuf *sb, const char *name)
> +int check_branch_ref(struct repository *repo, struct strbuf *sb, const char *name)
>   {
>   	if (startup_info->have_repository)
> -		copy_branchname(sb, name, INTERPRET_BRANCH_LOCAL);
> +		copy_branchname(repo, sb, name, INTERPRET_BRANCH_LOCAL);
>   	else
>   		strbuf_addstr(sb, name);
>   

startup_info itself is a global variable, isn't it?

I think a more appropriate approach is something like:

	if (repo && repo->gitdir)
		copy_branchname(repo, sb, name, INTERPRET_BRANCH_LOCAL);

I dunno, just a thought.

---

Regards, Yuchen