Skip to content

safe.directory interpretation is case-sensitive on Windows for the drive letter, when it is not for Git for Windows. #7037

Open

Description

@tyrielv
  1. On Windows 11, create a repository and assign ownership to something other than the current user. (I use the BUILTIN\Users group to repro, since the ownership check does not resolve group memberships other than BUILTIN\Administrators).

  2. Running "git status" (git for windows 2.47.1) in the repository results in
    fatal: detected dubious ownership in repository at 'C:/path/to/repo' 'C:/path/to/repo' is owned by: BUILTIN/Users (S-1-5-32-545) but the current user is: <redacted>

  3. Using libgit2sharp (0.31.0) to open the repository (Repository r = new Repository(@"C:\path\to\repo");) results in LibGit2Sharp.LibGit2SharpException: 'repository path 'C:/path/to/repo' is not owned by current user'

  4. Add the path with a case mismatch to safe.directory
    git config --global --add safe.directory c:/PATH/to/REPO

  5. git status now works

  6. Opening the repo with Libgit2sharp still results in LibGit2Sharp.LibGit2SharpException: 'repository path 'C:/path/to/repo' is not owned by current user'

  7. Opening the repo with matching case on the drive letter (Repository r = new Repository(@"c:\path\to\repo"); works as expected - the path is case-insensitive, but the drive letter is case-sensitive.

Activity

  1. changed the title [-]safe.directory interpretation is case-sensitive on Windows, when it is not for Git for Windows.[/-] [+]safe.directory interpretation is case-sensitive on Windows for the drive letter, when it is not for Git for Windows.[/+] on Feb 7, 2025
  2. ethomson commented on Mar 3, 2025

    @ethomson
    Member

    What's amazing about this is that safe.directory is case sensitive on macOS, so this is not actually honoring core.ignorecase.

    safe.directory is an unmitigated disaster.

  3. csware commented on May 24, 2026

    @csware
    Contributor

    Even if safe.directory is a desaster, libgit2 should not ignore issues...

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions