-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preparations to remove context from repo struct #33893
base: main
Are you sure you want to change the base?
Conversation
modernize test
CommitsCountBetween is dead code
add context to commitsBetweenNotBase
Is it clear that the change is safe? If the For example: in |
There are already some deadlock problems like this So there could be 3 results of the "ctx" refactoring:
So ideally I think we should figure out and fix the deadlock problems before introducing unclear changes, and only introduce clear changes with necessary tests. The first clear and necessary change in my mind is to clarify the |
As far as I know this brings no functional change, it just changes/how when the context gets passed from: request -> open gitRepo with context -> function, to request -> open gitRepo -> function with context. For whatever reason it took me a far bit to understand what exactly you meant but I see what you're talking about now. // Note those are very basic and don't represent real operations
func SomeEndpoint(ctx *context.Context){
gitRepo,err:=git.openRepository(ctx.repo)
...:=gitRepo.SomeGitFunction(ctx)
func (repo ...) SomeGitFunction(ctx,...){
// It uses CatFileBatch underneath
...:=repo.CatFileBatch(ctx) // request scoped so might be stuck of a lot of data gets requested
} If it's meant to more usecase specific one I'd opt for local one but that's more wasteful probably: func SomeEndpoint(ctx *context.Context){
gitRepo,err:=git.openRepository(ctx.repo)
...:=gitRepo.SomeGitFunction(ctx)
func (repo ...) SomeGitFunction(ctx,...){
ctx,cancel:=context.WithCancel(ctx)
defer cancel()
// It uses CatFileBatch underneath
...:=repo.CatFileBatch(ctx) // as soon as it's useless it's removed
} I'll look into it more though input is welcome. |
Can you clarify what I can do to help with it? |
Maybe it needs a complete refactoring to make these functions overall right. TBH I don't quite understand the old design either. By reading the commit history briefly, I can see that at the beginning there was no "ctx", so the "cached batch checker" was right. Then, "ctx" support was added, then more and more places started using "ctx", then the "cached batch checker with ctx" might go wrong. There are still many technical debts to pay. 🤷♂️ IIRC (just FYI) there were other "ctx" patches
No idea, either some people did too much "defensive programming" and added unnecessary design, or there is a real case that it would happen in real world. 🤷♂️ |
I created #33934 to try to rework CatFile implementation. |
first round of adding contexts to functions requiring it
trying keep it small'ish