Skip to content

Provide flags to limit config file lookup when open a repository#5244

Closed
mechanicker wants to merge 1 commit into
libgit2:masterfrom
mechanicker:dhruva/option-to-skip-configs
Closed

Provide flags to limit config file lookup when open a repository#5244
mechanicker wants to merge 1 commit into
libgit2:masterfrom
mechanicker:dhruva/option-to-skip-configs

Conversation

@mechanicker

Copy link
Copy Markdown
Contributor

By supporting specifiying config file locations, we minimize filesystem
calls to check if config file exists. This optimization helps when
repositories reside on network storage.

@mechanicker mechanicker force-pushed the dhruva/option-to-skip-configs branch from 8337683 to dea85ef Compare September 26, 2019 22:37
@mechanicker mechanicker changed the title Provide flags to limit config file loopup when open a repository Provide flags to limit config file lookup when open a repository Sep 26, 2019
@mechanicker mechanicker force-pushed the dhruva/option-to-skip-configs branch 2 times, most recently from d449ce4 to 060bb05 Compare September 27, 2019 02:44
By supporting specifiying config file locations, we minimize filesystem
calls to check if config file exists. This optimization helps when
repositories reside on network storage.
@mechanicker mechanicker force-pushed the dhruva/option-to-skip-configs branch from 060bb05 to 0aef61f Compare September 27, 2019 04:07
@mechanicker

Copy link
Copy Markdown
Contributor Author

/rebuild

@libgit2-azure-pipelines

Copy link
Copy Markdown

Sorry @Hackworks, an error occurred while trying to requeue the build.

@tiennou tiennou left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm somewhat on the fence about this, because I had a hard time piecing up #4856, which touches on related issues with repository opens and where I ended up refactoring the recursion out — though it's my own fault for having it as a WIP still — I had to think quite a lot about custom repositories, and where would the user like to be able to "provide its own backend".

Hence, to me, this code really belongs under the git_repository_new umbrella, as a "use this config stack I built and that filesystem location as your .git, and work", because there's no way a normal Git client wouldn't misbehave itself. Sadly this is an API part where work is lacking, because many parts of the code base will touch stuff under repo->gitdir, expecting it to exist (things like .git/HEAD sometimes doesn't go through the refdb at all).

On the other hand, I only have design complaints (an "architecture" one, using 4 different open bits), the scope is limited to opening repositories, and solves an issue you're facing. I'm on the fence 😆.

Comment thread src/repository.c
git_config_find_xdg(&xdg_buf);
git_config_find_system(&system_buf);
git_config_find_programdata(&programdata_buf);
if (!(repo->open_flags & (uint32_t)GIT_REPOSITORY_OPEN_NO_GLOBAL_CONFIG)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OPEN_SKIP ? I don't know how consistent we are, but positivity's always a win 😉.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiennou Thank you for the detailed comments

From an API point of view and extensibility, I completely agree this PR handles a very specific requirement by increasing complexity (adding flags exposed in the API). Having specific APIs to support various approaches to construct a repository would be much better instead of overloading a single API with extra flags (leads to confusion and makes it inflexible).

It is more like having explicit constructors in C++ as against having a single constructor with a multitude of arguments supporting different requirements.

Let me take a closer look at your work in #4856 and I am more inclined to closing this PR in favor of your approach.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, I don't think what I'm envisioning is going to happen anyways on such a short notice, so to speak — it's just that I added support for the GIT_CONFIG envvar (as specified by git-config). In other words, maybe it is possible to just point GIT_CONFIG to your file, instead of changing the C API, and the stacking behavior could be controlled. I'm not even sure it's possible, but I'd really prefer any modification to go on top of #4856, as you could alternatively make it possible to just build a git_config * and put that in git_repository_open_options. IIRC. YMMV, this is WIP for a reason 😉.

@mechanicker mechanicker closed this Sep 5, 2020
@mechanicker mechanicker deleted the dhruva/option-to-skip-configs branch September 6, 2020 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants