fix(gix-config-value)!: expand ~ and ~user like git does - #2984
Merged
Sebastian Thiel (Byron) merged 4 commits intoSep 9, 2026
Merged
Conversation
Git expands `~` and `~user` paths via `interpolate_path()` in `path.c`. In `gix-config-value`, `Path::interpolate()` previously required a trailing slash for the current user (`~/`) and required a slash for named users (`self.starts_with(b"~") && self.contains(&b'/')`). Consequently: - A standalone `~` was left unexpanded as a literal `"~"`. - A standalone `~user` without a trailing slash was left unexpanded as a literal `"~user"`. - A nonexistent user without a slash (`~nonexistent`) silently returned the literal instead of producing a user lookup error. Recorded from `git -c t.k=<input> config --type=path t.k` on git 2.50.1: | input | git | before | after | |---|---|---|---| | `~` | `/home/user` | `"~"` | `/home/user` | | `~/` | `/home/user/` | `/home/user` | `/home/user` | | `~/foo` | `/home/user/foo` | `/home/user/foo` | `/home/user/foo` | | `~user` | `/home/user` | `"~user"` | `/home/user` | | `~user/` | `/home/user/` | `/home/user` | `/home/user` | | `~user/foo` | `/home/user/foo` | `/home/user/foo` | `/home/user/foo` | | `~nonexistent` | error | `"~nonexistent"` | error | Changes: - Expand `~` to `home_dir` when standalone, matching `~/`. - In `interpolate_user`, allow paths without `/` (e.g. `~user`) to expand directly to the user's home directory. - Update `tests/value/path.rs` with tests for `~`, `~user`, and missing user error cases. Marked breaking (`!`): `~` and `~user` without trailing slashes now interpolate instead of returning literal strings.
Member
|
Thanks for the hint! |
- remove OS specific home resolution which hardcoded 'unsupported', even though the closure can decide. - simplified expansion logic Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <[email protected]>
Sebastian Thiel (Byron)
force-pushed
the
fix/config-path-tilde-parity
branch
from
September 9, 2026 14:37
a8ec67f to
1330200
Compare
<!-- agent --> Fixture commands already ignore external Git configuration, but inherited `GIT_TEMPLATE_DIR` could still inject personal template files into repositories created by `git init`, making fixtures depend on the caller's environment. Clear that variable in the shared command setup used by fixture scripts and isolated Git helpers. Keep Git's installed templates available because existing fixtures rely on their standard files and directory layout. Document the isolation behavior and add a regression that supplies an external template containing a marker file, then verifies that `git init` does not copy it into the fixture repository. Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <[email protected]>
<!-- agent --> - [P2] Preserve literal worktree paths when expanding bare tildes — gix-config-value/src/path.rs:196-200 With `core.worktree = "~"`, the caller in `gix/src/open/repository.rs` now selects `$HOME`, or fails under `Options::isolated()`. Git and the previous code instead use the literal `<git-dir>/~`: Git does not interpolate this setting. Adapt the worktree caller alongside this change so existing repositories continue opening correctly . - [P2] Preserve failed-user fallback for conditional include patterns — gix-config-value/src/path.rs:191-194 For a bare repository named `~repo` where `repo` is not a system user, `[includeIf "gitdir:~repo"]` matches in Git and before this patch. It now produces a lookup error, which `gix-config`'s `gitdir_matches()` converts into `false`, silently omitting the included settings. Git's `prepare_include_condition_pattern()` preserves the original pattern when expansion fails; retain that fallback in the caller. Assisted-by: GPT 6.0 Co-authored-by: GPT 6.0 <[email protected]>
Sebastian Thiel (Byron)
force-pushed
the
fix/config-path-tilde-parity
branch
from
September 9, 2026 15:01
1330200 to
2742f05
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Written with assistance from the Zed coding agent through Just One More Night (@justonemorenight)'s account, per the identification rule in
CONTRIBUTING.md.Git expands
~and~userpaths viainterpolate_path()inpath.c. Ingix-config-value,Path::interpolate()previously required a trailing slash for the current user (~/) and required a slash for named users (self.starts_with(b"~") && self.contains(&b'/')). Consequently:~was left unexpanded as a literal"~".~userwithout a trailing slash was left unexpanded as a literal"~user".~nonexistent) silently returned the literal instead of producing a user lookup error.Parity with Git
Recorded from
git -c t.k=<input> config --type=path t.kon git 2.50.1:~/home/user"~"/home/user~//home/user//home/user/home/user~/foo/home/user/foo/home/user/foo/home/user/foo~user/home/user"~user"/home/user~user//home/user//home/user/home/user~user/foo/home/user/foo/home/user/foo/home/user/foo~nonexistent"~nonexistent"Changes
~tohome_dirwhen standalone, matching~/.interpolate_user, allow paths without/(e.g.~user) to expand directly to the user's home directory.tests/value/path.rs: replacetilde_alone_does_not_interpolatewithtilde_alone_substitutes_current_user, and add tests for~userand missing user error cases.Marked breaking (
!):~and~userwithout trailing slashes now interpolate instead of returning literal strings.Verification
cargo test -p gix-config-value(56 tests + 2 doctests pass)cargo test -p gix-config(366 tests pass)cargo clippy -p gix-config-value(clean)cargo fmt --check(clean)