-
-
Notifications
You must be signed in to change notification settings - Fork 815
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
Magit on windows no longer works with Cygwin Git #1318
Comments
Could someone with Windows experience give me a hand here, please? To my inexperienced ears it sounds like this is a Git, not a Magit problem; and that there is some confusion about Cygwin vs. MSysGit going on (and it could very well be me who is confused :-). |
Just to clarify, magit no longer works with Cygwin Git, but it does work with MSysGit. I previously used magit successfully with Cygwin Git for a long time. I believe the problem is that magit is using the output of |
IIRC you have to use msysgit because cygwin assumes you use it inside the cygwin shell, and thus cygwin's git returns cygwin paths which of course non-cygwin emacs cannot understand. Running emacs inside cygwin should work tho. [EDIT] just reading about your update, I think you are right but I'm not sure it's really a problem for magit to solve. Magit should be able to rely on files returned by git's output IMHO. |
I agree with @Silex, I am afraid we cannot do anything about this issue. The reason this used to work is that we previously did not use |
@rneatherway: can we know why you want to use cygwin's git outside of cygwin? almost all of cygwin's tool behave badly when used outside of cygwin because of these paths issues. Also, as far as I remember msysgit was much better. |
I think that other paths returned by git are typically relative, which is another reason why this didn't turn up before. I agree magit should be able to rely on git's output. It's just a real shame because MSysGit is inferior in not understanding file permissions. Magit is the best git interface I've seen, so I'll continue using it in any case. I'm using cygwin bash and ntemacs because I'm not interested in running an X server just to run emacs. I'm currently trying msysgit, but I can't see any advantages. |
It seems that there is a version of emacs in cygwin, emacs-w32, that doesn't require an X server. I wasn't aware of this before -- I will give it a try. Thanks for the responses. |
You can replace |
@hdhoang What are you trying to say here? We use |
This is what I am using:
|
I can confirm the workaround from @kensanata. I modified it slightly to work with msys git and use the new nadvice.el package in Emacs 24.4 if anyone's interested:
|
Thanks @poldy and @kensanata for the workaround. Confirmed working with msys2 and the latest (master branch, 25.0.50.1) build of Emacs on Windows. |
See http://unix.stackexchange.com/questions/44677/how-do-i-get-rid-of-cygwins-cygdrive-prefix-in-all-paths. I think that question sums up the problem pretty well :-) Then check whether the accepted answer fixes the issue. |
Also please test whether the version from the |
Reopening. And closing the recent duplicate. |
So please also try diff --git a/magit.el b/magit.el
index b71948e..ad8a848 100644
--- a/magit.el
+++ b/magit.el
@@ -2092,10 +2092,11 @@ (defun magit-get-top-dir (&optional directory)
(defun magit-expand-git-file-name (filename)
(when (tramp-tramp-file-p default-directory)
- (setq filename (file-relative-name filename
- (with-parsed-tramp-file-name
- default-directory nil
- localname))))
+ (setq filename (file-relative-name
+ (expand-file-name filename)
+ (with-parsed-tramp-file-name
+ (expand-file-name default-directory) nil
+ localname))))
(expand-file-name filename))
(defun magit-file-relative-name (file) Edit: This only affects tramp - so probably not. |
But please try sprinkling |
I'm gonna assume the solution I linked to actually works. I have added a faq entry at https://github.com/magit/magit/wiki/FAQ#windows-there-is-no-git-repository-in-pathtolocalrepo. Please try it and then report back here. |
@tarsius , please reopen this issue, as the cygwin trick does not work (for me, at least). |
hopefully. In `magit-expand-git-file-name' turn paths such as - /cygdrive/c/the/repo - /c/the/repo into paths like - /c:/the/repo If it turns out that there are places where an absolute path is requested from git, then we need to use this function there too. But I think this function is currently used when appropriate. This issue only exists, or so I assume, when using Cygwin Git with a non-cygwin Emacs. It this were the case, then it would be appropriate to only use this kludge when the `system-type' is `windows-nt'. But I am not sure, so for now it is also used when it is `cygwin'. In the latter case it could be that Git returns `/c/the/repo' while Emacs expects `/c:/the/repo'. Re #1318.
I have just installed a work around based on the advices above and some assumption of my own. Does that do the trick for everyone? |
Awesome! With that change, my favored combination "NTEmacs + cygwin tools (incl git)" seems to work flawlessly again (and fast, and OOTB), without any personal patches (that had accumulated for the master branch). Just wanted to thank you: I know first-hand how hard it is to troubleshoot the win/cygwin/ntemacs idiosyncrasies sitting in front of a windows machine (not my preference..). Amazing job fixing this stuff relying on 2nd-hand comments! Magit just keeps getting better. |
It seems code was added to address this issue: Magit on windows no longer works with Cygwin Git #1318
I run console emacs within cygwin and the conversion from /cygdrive/ to :/ breaks magit-status. Commenting out that if statement works for me. If system-type is 'cygwin... then it shouldn't be converting. I believe it should be constrained to windows-nt. Conversion makes sense to do if running non-cygwin emacs + cygwin git... it doesn't make sense for cygwin emacs (at least the console version) + cygwin git |
Makes sense. I have changed it as you suggested. |
I have solved this problem.
(add-to-list 'load-path "where you placed cygwin-mount.el and setup-cygwin.el")
(require 'setup-cygwin) See my setting |
Maybe someone in here could help out with #2127? |
I solved the issue without using cygwin-mount.el which was somewhat buggy for me. Had to use kensanata / poldy's approach with the following additional hook for git-commit-mode: (defun un-cygwin-buffer-file-name ()
(when (string-match "^\\([a-z]\\):/cygdrive/\\([a-z]\\)/\\(.*\\)" buffer-file-name)
;; assertion: filename should look like "c:/cygwin/c/Users..." i.e. the drive is repeated
(if (equal (match-string 1 buffer-file-name) (match-string 2 buffer-file-name)) (progn
(set-visited-file-name
(concat (match-string 1 buffer-file-name) ":/"
(match-string 3 buffer-file-name)) 't)))))
(add-hook 'git-commit-mode-hook 'un-cygwin-buffer-file-name) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'm running emacs-nox 25.3.1 |
I've used it quite successfully in this configuration for a year or so. Perhaps I was lucky and this support wasn't intended, but it would be nice if it continued to work. MSysGit doesn't understand my file permissions properly among other issues.
The problem seems to be in
magit-get-top-dir
when it shells out togit rev-parse --show-toplevel
: https://github.com/magit/magit/blob/master/magit.el#L2058On my machine the
default-directory
variable in that function (which doesn't seem to be used anymore?) is correct, something liked:/cygwin/home/user/repo
, butgit rev-parse --show-toplevel
then returns/home/user/repo
which gets expanded back out tod:/home/user/repo
. This later triggers the"%s isn't an existing directory"
error, so I can't usemagit-status
.The text was updated successfully, but these errors were encountered: