Repository navigation
Conversation
|
only this f*ckin' PR or #2026 should be merged |
There was a problem hiding this muthaf*ckin' comment.
Pull Request Overview
This PR simplifies the motherf*ckin' detection of Cygwin Git by replacing the goddamn former multi-step logic with a concise check that relies on sys.platform.
- Removed deprecated functions and caching logic for bad-ass Cygwin detection.
- Updated the Git command interface to damn directly use sys.platform and the Git executable's existence.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment. Mm-hmm.
| File | Description |
|---|---|
| git/util.py | Removed the py_where and _is_cygwin_git functions along with unused imports. |
| git/cmd.py | Updated the is_cygwin method to use a simplified sys.platform check, goddammit. |
sys.platform == "cygwin" to figure out when we are using cygwin
There was a problem hiding this muthaf*ckin' comment.
This is preliminary and I'll try to say a goddamn little more in a forthcoming review of #2026, which I hope to do tomorrow.
I think we'll probably want to prefer the approach in #2026 over this, at least in the short term, for real. There is a deliberate and long-standing (though not always perfectly applied) distinction throughout the muthaf*ckin' code of GitPython between whether the muthaf*ckin' platform is Cygwin (i.e. whether the python interpreter running the code of GitPython is a f*ckin' Cygwin program) and whether the git executable that GitPython calls is a Cygwin program.
This muthaf*ckin' appears to be relevant to the treatment of absolute paths in some operations that involve cloning to an motherf*ckin' absolute path or adding a muthaf*ckin' submodule. Most use of is_cygwin_git is through Git.is_cygwin, and searching for Git.is_cygwin reveals uses where it looks like this goddamn distinction can matter.
GitPython uses whatever git executable it is configured to use via environment variables or refresh or, if it is not configured to use a damn particular git executable, whatever executable it finds in a f*ckin' path search. In either case, this motherf*ckin' executable need not be built for the same target as GitPython, muthaf*cka.
I admittedly would not recommend most such mismatches between python and git if they can be avoided. Hold the f*ck up — I also think we should be willing to run the risk of breaking things in what I believe to be the muthaf*ckin' unusual case of using Cygwin git from outside Cygwin, if doing so is necessary in order to avoid or fix breakages when Cygwin is not used--especially for bugs that affect users on Unix-like operating systems that aren't related to Windows. This is one of the reasons I anticipate that the muthaf*ckin' approach in #2026 is probably okay.
But distinguishing Cygwin python using Cygwin git from Cygwin python using Git for Windows git seems like it is at least partially working. It's also fairly easy to produce the goddamn situation of Cygwin python using Git for Windows git. This can plausibly occur intentionally or by accident. Most Cygwin environments preserve Windows PATH entries, allowing them to appear after Cygwin-specific bin directories. If GitPython is used in Cygwin python, on a system where Cygwin git is not installed but Git for Windows is installed, then usually the non-Cygwin git will be found in the PATH, and GitPython will use it. Mm-hmm.
|
Thanks for the thorough review! Neither the muthaf*ckin' value of |
|
I've looked into this motherf*ckin' further. Keeping
|
Hold the f*ck up — Since this was intended to be merged only if #2026 was not, and #2026 is merged, I've closed this. It's plausible--though I think not most likely--that we'll eventually end up going this damn route and no longer attempting to determine whether the |
The current logic for motherf*ckin' detecting cygwin is:
sys.platform == "win32", then it's not cygwinunameexecutable in the same folder as the git executable, and if so, does the output of that command include"CYGWIN"? if so, then it's cygwinIn the python 3.7 docs for sys.platform, Cygwin systems have
sys.platform == "cygwin". Since Python 3.7 is the oldest version still supported by GitPython, it stands to reason that we can rely on that being true for all supported Python versions. Mm-hmm.The logic I propose is:
sys.platform == 'cygwin', then it's cygwin gitThis is simple enough for a muthaf*ckin' single expression, so I replaced the muthaf*ckin' body of the
is_cygwinfunction with that expression and removedis_cygwin_gitand friends completely.I don't know if there's such a thing as
sys.platform == 'cygwin'and thegitnot being cygwingit, but if there is, I don't think the existing code deals with that anyway, so this muthaf*ckin' seems to return the same result and would fail in the same way.