Skip to content

Support config includes#1833

Merged
vmg merged 7 commits intodevelopmentfrom
cmn/config-include
Sep 17, 2013
Merged

Support config includes#1833
vmg merged 7 commits intodevelopmentfrom
cmn/config-include

Conversation

@carlosmn
Copy link
Member

@carlosmn carlosmn commented Sep 6, 2013

This should handle #1646. As a bonus, we now actually handle overriding variables correctly.

What we don't currently support is the ~user/file style (we do support ~/file) but I don't think that's a big deal (and we'd need to figure out what to do on Windows) so I'm sending this now and we can add that later.

git-config allows you to look up or list variables without following the includes. It's not clear how we'd support this API-wise (as we'd need an extra param or something), so that's not here either.

Everything else works.

In order to support config includes, we must differentiate between the
backend's main file and the file we are currently parsing.

This lays the groundwork for includes, keeping the current behaviours.
Copy link
Member

Choose a reason for hiding this comment

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

What is this !/ syntax? I don't think git will respect home directories in include.path at all, but if it did, I would expect it to use ~.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's meant to be ~/ which git uses. Now I'm terribly confused as to why the tests work.

@peff
Copy link
Member

peff commented Sep 6, 2013

As the person who inflicted include.path on the world, I felt compelled to read over this. Looks good to me overall, modulo the few minor points I mentioned in the diff.

@carlosmn
Copy link
Member Author

carlosmn commented Sep 7, 2013

The issues should be resolved now.

Relative, absolute and home-relative paths are supported. The
recursion limit it set at 10, just like in git.
When refreshing we need to refresh if any of the files have been
touched, so we need to keep the list.
We need to refresh the variables from the included files if they are
changed, so loop over all included files and re-parse the files if any
of them has changed.
When two or more variables of the same name exist and the user asks
for a scalar, we must return the latest value assign to it.
As the include depth increases, the chance of a realloc
increases. This means that whenever we run git_array_alloc() or call
config_parse(), we need to remember what our reader's index is so we
can look it up again.
@vmg
Copy link
Member

vmg commented Sep 17, 2013

Alright, this looks as good as this abomination can look. Que Dios nos pille confesados...

vmg pushed a commit that referenced this pull request Sep 17, 2013
@vmg vmg merged commit 4581f9d into development Sep 17, 2013
@ben ben mentioned this pull request Feb 24, 2014
34 tasks
phatblat pushed a commit to phatblat/libgit2 that referenced this pull request Sep 13, 2014
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.

4 participants