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

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 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

This comment has been minimized.

@asottile

asottile Dec 7, 2020
Member

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

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 force-pushed the mrogaski:1610_git_toplevel_relpath branch from c2b3a9c to 29d15de Dec 7, 2020
@asottile asottile merged commit eacf4c8 into pre-commit:master Dec 7, 2020
2 checks passed
2 checks passed
pre-commit.ci - pr checks completed successfully
Details
pre-commit.pre-commit #20201207.5 succeeded
Details
@mrogaski mrogaski deleted the mrogaski:1610_git_toplevel_relpath branch Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants