GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Add support for hasconfig git rule. by bvanelli · Pull Request #2075 · gitpython-developers/GitPython

Conversation

@bvanelli

@bvanelli bvanelli commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

Support adding custom paths for the following git config:

# Anonymous user override
[includeIf "hasconfig:remote.*.url:**/**github.com*/**"]
	path = ~/.personal.gitconfig

According to the documentation:

As for the naming of this keyword, it is for forwards compatibility with a naming scheme that supports more variable-based include conditions, but currently Git only supports the exact keyword described above.

So I have matched the condition exactly word to word with hasconfig:remote.*.url. I then go over the list of remotes and find using fnmatchcase the correct remote (not sure if fnmatch.

Maybe a list of open points here:

  • I'm not sure if the wildcard format and the fnmatch function are equivalent. Is it necessary to match these two 100%? Maybe a maintainer would have more experience with
  • Should I write more test cases?
  • Write a couple of cases which are handled by both git binary and gitpython and compare the two.

Closes #2017

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bvanelli added 2 commits October 7, 2025 20:50
@bvanelli
feat: Add support for hasconfig git rule.
bcdcccd
@bvanelli
fix: Use fnmatch instead.
6cf8633
Byron
Byron approved these changes Oct 8, 2025
View reviewed changes

@Byron Byron left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks so much for contributing this capability!

I really like the implementation, and love that there are tests as well.
To my mind these tests cover the most important cases.

Good to merge!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread git/config.py

elif keyword == "hasconfig:remote.*.url":
for remote in self._repo.remotes:
if fnmatch.fnmatchcase(remote.url, value):

@Byron Byron Oct 8, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Using a case-sensitive search is correct here, Git does the same.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread test/test_config.py

# Ensure that config with hasconfig and incorrect url is incorrect.
with open(path1, "w") as stream:
stream.write(template.format("incorrect", path2))

@Byron Byron Oct 8, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think that "incorrect" fails to communicate that this is a URL that simply doesn't match.
Maybe something for a follow-up.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Byron
Byron merged commit 0c2bfac into gitpython-developers:main Oct 8, 2025
@bvanelli
bvanelli deleted the 2017-support-hasconfig-remote-url branch October 8, 2025 05:35
@bvanelli

bvanelli commented Oct 8, 2025

Copy link
Copy Markdown
Contributor Author

Oh, such speed, thanks for the quick response!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Byron Byron Byron approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

hasconfig:remote.*.url not supported by includeIf

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bvanelli @Byron
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.