Commit a49dfe13 authored by Jonas Bernoulli's avatar Jonas Bernoulli

replace magit-convert-git-filename with magit-convert-filename-for-git

The new function also deals with Tramp filenames and comes
with a doc-string, and its name actually matches what it does.

Closes #2807.
parent 8ab81f06
......@@ -613,11 +613,18 @@ Sorted from longest to shortest CYGWIN name."
(concat win (substring filename (length cyg)))
(defun magit-convert-git-filename (filename)
(defun magit-convert-filename-for-git (filename)
"Convert FILENAME so that it can be passed to git.
1. If it's a remote filename, then remove the remote part.
2. Expand \"~/\", git isn't a shell and does not understand it.
3. Deal with an `windows-nt' Emacs vs. Cygwin Git incompatibility."
(if (file-name-absolute-p filename)
(-if-let ((cyg . win)
(cl-rassoc filename magit-cygwin-mount-points
:test (lambda (f win) (string-prefix-p win f))))
(concat cyg (substring filename (length win)))
(or (file-remote-p filename 'localname)
(defun magit-decode-git-path (path)
......@@ -1193,9 +1200,8 @@ Return a list of two integers: (A>B B>A)."
(defmacro magit-with-temp-index (tree arg &rest body)
(declare (indent 2) (debug (form form body)))
(let ((file (cl-gensym "file")))
`(let ((,file (magit-convert-git-filename
`(let ((,file (magit-convert-filename-for-git
(make-temp-name (magit-git-dir "index.magit.")))))
(setq ,file (or (file-remote-p ,file 'localname) ,file))
(progn (--when-let ,tree
(or (magit-git-success "read-tree" ,arg it
......@@ -62,8 +62,7 @@ Then show the status buffer for the new repository."
(match-string 1 url))))))
(setq directory (file-name-as-directory (expand-file-name directory)))
(magit-run-git-async "clone" repository
;; Stop cygwin git making a "c:" directory.
(magit-convert-git-filename directory))
(magit-convert-filename-for-git directory))
;; Don't refresh the buffer we're calling from.
(process-put magit-this-process 'inhibit-refresh t)
......@@ -1402,7 +1402,7 @@ Non-interactively DIRECTORY is (re-)initialized unconditionally."
(user-error "Abort")))
(list directory)))
;; `git init' does not understand the meaning of "~"!
(magit-call-git "init" (magit-convert-git-filename
(magit-call-git "init" (magit-convert-filename-for-git
(expand-file-name directory)))
(magit-status-internal directory))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment