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 use hard-coded mount prefix #2317
Comments
Please look in https://cygwin.com/cygwin-ug-net.html for a command which can more reliably return the prefix. |
Sorry I don't understand what you expect. |
Something like Show me the output of |
I guess yes
and
so
obviously the tail and cut can be achieved in elisp with something like (forward-line -1)
(buffer-substring-no-properties (+ 1 (point)) (line-end-position)) |
Or just |
Same as with -p (short switch vs long switch)
|
Ups sorry, though that would just print "the prefix". But actually there might be no "one and only prefix", and that's what I was getting at all along. |
As I said in #2319, I think we should try to use cygwin-mount.el instead of reimplementing it. |
If we do that, then we should also try to locate the latest version and get someone to maintain it in a git repository. |
I'm not convinced it's possible to have multiple prefix at the same time. here is the doc of the function (line 209) :
I think it"s possible to just get the prefix without using the full machinery of cygwin-mount. I agree the constant must be created more carefully by adding a check on system-type and maybe on the presence of cygwin / msys etc. |
I would prefer that too. |
I reviewed my patch and I should really add checks for building magit-cygwin-prefix. |
I think I got confused between mount points ( |
What do you think of this version ? (defconst magit-cygwin-prefix
(let ((magit-cygwin-prefix "/cygdrive"))
;; then try to retrive the real one.
(when (eq system-type 'windows-nt)
(with-temp-buffer
(call-process-shell-command "mount --show-cygdrive-prefixe | tail -1 | cut -d ' ' -f1" nil '(t nil))
(forward-line -1)
(setq magit-cygwin-prefix
(buffer-substring-no-properties (point) (line-end-position)))
(if (string= magit-cygwin-prefix "")
(setq magit-cygwin-prefix nil)
magit-cygwin-prefix)))
magit-cygwin-prefix)
"Store prefix used for the \"/cygdrive/X/\" style of cygwin.
This is done by calling \"mount --show-cygdrive-prefixes\".
The result is either \"/\", \"/<string>\" or nil if not in `windows-nt' system.") |
Here's a slightly cleaned up version (IMHO). Most importantly, it should be It does correctly detect the prefix of (defconst magit-cygwin-prefix
(when (eq system-type 'windows-nt)
(with-temp-buffer
(call-process-shell-command
"mount --show-cygdrive-prefix | tail -1 | cut -d ' ' -f1"
nil '(t nil))
(forward-line -1)
(let ((str (buffer-substring-no-properties (point) (line-end-position))))
(unless (string= str "")
str))))
"Prefix used for \"/cygdrive/X/\" style Cygwin paths.
The result is either \"/\", \"/<string>\" or nil if not on a
`windows-nt' system.") |
I think this should be an option and use |
Indeed, it comes out better with Edit: I like this version better (defcustom magit-cygwin-prefix
(when (eq system-type 'windows-nt)
(ignore-errors
(-> (process-lines "mount" "--show-cygdrive-prefix")
cadr
split-string
car)))
"Prefix used for \"/cygdrive/X/\" style Cygwin paths.
The result is either \"/\", \"/<string>\" or nil if not on a
`windows-nt' system."
:package-version '(magit . "2.3.0")
:group 'magit-process
:type '(choice (const :tag "None" nil)
string)) Original: (defcustom magit-cygwin-prefix
(when (eq system-type 'windows-nt)
(ignore-errors
(--when-let (process-lines "mount" "--show-cygdrive-prefix")
(car (split-string (cadr it))))))
"Prefix used for \"/cygdrive/X/\" style Cygwin paths.
The result is either \"/\", \"/<string>\" or nil if not on a
`windows-nt' system."
:package-version '(magit . "2.3.0")
:group 'magit-process
:type '(choice (const :tag "None" nil)
string)) |
No, I'm at home now and haven't access to an Windows machine. |
@johnmastro: I prefer the second. It has less dashims. I don't mind. |
I also prefer "the original". Yes, please open a pr. But I'll leave it to @npostavs to decide whether it should be merged. |
Or rather just update the pr you already opened. |
To clarify, I am inclined to merge this; after looking at cygwin-mount.el some more I'm less eager to recommend using it (it's rather invasive) and the code to calculate the cygdrive prefix looks simple enough. Only snag is, I think we need the cygdrive prefix in |
@npostavs Not tested yet. But if both git-commit and magit need to be changed, where should I put the definition of magit-cygdrive-prefix ? |
@npostavs I've used commit from from magit to correct my repo with the use of the defcustom and everything has worked without any modifications to |
Huh. I don't quite understand, but good news I guess.
Essentially |
Sorry, I'm not really fluent in English. |
Okay, please update #2319 (or open new pull request if you can't, I see it is saying Also, please post the output when running
|
I think I'll have to open another pull request. I've destroyed the previous repository. |
Okay, just open a new one then. |
Here is the output of
And it's work because my I've created PR #2324 |
Hmm, then it won't work if someone chooses a trickier mapping. Well, I guess we can wait until someone complains about it. |
Please address the issue proactively. |
Hmm problem is the cygdrive prefix is actually not sufficient, it's only a fallback. https://cygwin.com/cygwin-ug-net/using.html#mount-table
http://www.cygwin.com/cygwin-ug-net/mount.html
Example: I map
To translate paths like
|
Did you think we could use
|
Unfortunately no:
I think matching against (let ((line "C:/Documents and Settings on /docs type ntfs (binary)"))
(if (string-match "^\\(.*\\) on \\(.*\\) type" line)
(cons (match-string 1 line) (match-string 2 line))
(display-warning '(magit) (format "Failed to parse Cygwin mount: %S" line))))
;; => ("C:/Documents and Settings" . "/docs") |
Isn't the output of
my
Another bonus of (let ((mount-points (ignore-errors (process-lines "mount" "-m"))))
(mapcar #'(lambda (l)
(let ((entry (split-string l)))
(cons (replace-regexp-in-string "\\\\040" " " (cadr entry))
(replace-regexp-in-string "none" ""
(replace-regexp-in-string "\\\\040" " " (car entry))))))
mount-points))
;;=>
(("/home" . "D:/home") ("/travail" . "D:/Travail")
("/documents/documents bidons" . "C:/Users/myUser/Documents/Bluetooth Folder")
("/documents" . "C:/Users/myUser/Documents/Bluetooth Folder")
("/mnt" . "")) What did you think ? |
Ah, didn't notice that option. The drawback of the |
if an user customised the mount prefix in his cygwin / MINGW install, he is unable to use last magit version.
In function magit-expand-git-file-name (lisp/magit-git.el) the moun prefix is hard coded with cygdrive.
here is an attempt to fix this (this work for me with /mnt prefix) :
Sorry I was unable to attach it with a file.
The text was updated successfully, but these errors were encountered: