Skip to content

fix(config): enable file include in scoped queries - #2345

Open
becm wants to merge 2 commits into
git-ecosystem:mainfrom
becm:scope-includes
Open

fix(config): enable file include in scoped queries#2345
becm wants to merge 2 commits into
git-ecosystem:mainfrom
becm:scope-includes

Conversation

@becm

@becm becm commented May 14, 2026

Copy link
Copy Markdown
Contributor

Avoid duplication of entries already present in included files:

  • consistent include of files in Git config queries with scope limit
  • check for sufficient detection of present values, assignments always create values in main files
  • add test for file includes

Improves consistency regarding include behavior with cached Git config and

Fixes #2342
Fixes #1696
Fixes #1337

@becm
becm requested a review from a team as a code owner May 14, 2026 16:51
@derrickstolee

Copy link
Copy Markdown
Contributor

@becm Thanks for identifying this key piece that connects to several issues. Could you add a test to demonstrate the behavior change to prevent regressions in the future?

@becm
becm marked this pull request as draft May 14, 2026 18:11
@becm

becm commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

@derrickstolee sadly only the 1st step, since:

  • the assignment seems to be unconditional
  • I did not even manage to get all instances where the --list request is issued.

add parameter to make file include behavior in config read consistent
retain existing parameters on write, always uses "primary" scope file
@becm
becm force-pushed the scope-includes branch from 4949cdf to 7e80d8b Compare May 14, 2026 22:17
@becm becm changed the title fix(config): enable file include in scoped query fix(config): avoid config duplications May 14, 2026
@becm
becm force-pushed the scope-includes branch from 7e80d8b to 5070c2b Compare May 14, 2026 22:40
@becm

becm commented May 16, 2026

Copy link
Copy Markdown
Contributor Author

@derrickstolee since the --include stuff is dependent on partnered Git version and file setup, I'd have no idea how to attempt a proper test (existing examples just operate on unrelated mock data).

Will try to implement a test for (abstract) config data with the (hopefully) resolved corner case of configure.

@becm
becm force-pushed the scope-includes branch from 5070c2b to 4c486f0 Compare May 22, 2026 09:53
@becm becm changed the title fix(config): avoid config duplications fix(config): enable file include in scoped queries May 22, 2026
@becm

becm commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Reverted PR to primary goal, will tackle git-credential-manager configure issue in separate task.

@derrickstolee I'll try to add a test for file inclusion (global scope).

@xz2m9kg2cw-oss

This comment was marked as spam.

configuration queries should process include statements consistently
@becm
becm marked this pull request as ready for review May 22, 2026 16:20
@becm

becm commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@mjcheetham any further actions to be taken to accept this?

This change will essentially harmonizes behavior before and after Git 2.54 .
#318 changed the default includes behavior by splitting global and local.
#2268 basically introduced holistic config parsing with --show-scope again.

@becm

becm commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@derrickstolee it seems git-credential-manager only ever uses GitConfigurationType.Raw (in non-test code).

Would it be possible to introduce a further code path for Git 2.26+ without the --no-type argument that only uses/generates raw cache and only depends on --show-scope?

This would be an extension or (for non-ancient Git versions) a replacement for the current PR.

@dscho

dscho commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

The way I read this change, it constitutes a change of behavior. A good one, granted, but one that has a high potential of affecting existing users' setups (especially complex setups). As such, I'd be much more comfortable to make this behavioral change part of a major version bump. Seeing as v3.x is starting to take concrete shape, I would consider that version to be the natural inflection point to integrate this here PR.

@becm

becm commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@dscho behavior change already happened for 2.8.0 with #2268 and #2296 for certain newer Git versions.

This combination effectively uses --show-scope and full config parsing again (which has further impacts).
So this would be an attempt to harmonize behavior in a 2.8.1 for older Git versions.

@dscho

dscho commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

behavior change already happened for 2.8.0 with #2268 and #2296 for certain newer Git versions.

@becm sure, but the way I see it was that this was an inadvertent behavioral change. Here, we are aware of the change. That makes a huge difference.

@becm

becm commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@dscho the problem is inconsistent behavior when different Git versions are involved.

So a "bugfix" is to intentionally lean into the (unintended) change.
The less desirable option would be to revert the introduction of the config cache.

If adding config cache did not enforce --type support (only GitConfigurationType.Raw is used at present)
the new approach would already be applicable down to Git v2.26 (introduction of --show-scope).

@dscho

dscho commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Now that main targets v3.x, I think this change should go in.

@becm

becm commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

If there is serious intent to merge, I'd invest work to submit a better (more extensive) approach.
The code paths requiring --type are only used in test code so there are 2 viable options:

  • drop the support for typed config cache (less complex code) or
  • add separate version checks for useRawCache and useTypedCache
    (and loose the --no-type option) for the Raw config type.

Only using --includes still has a issues when using includeif.hasconfig
→ local config can effect behavior in global scope (#2328)

The approach using --includes would still be applicable for ancient Git versions.

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

Labels

None yet

Projects

None yet

4 participants