Skip to content

Conversation

@mrogaski
Copy link
Contributor

@mrogaski mrogaski commented Dec 7, 2020

Resolves #1610

Git 2.25 introduced a change to "rev-parse --show-toplevel" that exposed underlying volumes for Windows drives mapped with SUBST. We use "rev-parse --show-cdup" to get the appropriate path, but must perform an extra check to see if we are in the .git directory.

@mrogaski
Copy link
Contributor Author

mrogaski commented Dec 7, 2020

This is for #1610. I used pathlib for the path comparisons in the get_root function to ensure the same failure modes.

import logging
import os.path
import sys
from pathlib import Path
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer not to use pathlib

you can do the same without it via os.path.commonpath:

root = os.path.realpath(root)
git_dir = os.path.realpath(git_dir)
if os.path.commonpath(root, git_dir) == git_dir:
    ...

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

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

Git 2.25 introduced a change to "rev-parse --show-toplevel" that exposed underlying volumes for Windows drives mapped with SUBST.  We use "rev-parse --show-cdup" to get the appropriate path, but must perform an extra check to see if we are in the .git directory.
@asottile asottile merged commit eacf4c8 into pre-commit:master Dec 7, 2020
@mrogaski mrogaski deleted the 1610_git_toplevel_relpath branch December 8, 2020 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Pre-commit fails for git >=2.25 if repo is on a Windows subst drive

2 participants