Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: changed rev-parse option for Git 2.25 changes to --show-toplevel #1727

Merged
merged 1 commit into from Dec 7, 2020
Merged

git: changed rev-parse option for Git 2.25 changes to --show-toplevel #1727

merged 1 commit into from Dec 7, 2020

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.

@@ -1,6 +1,7 @@
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