sanitize all git remote names
This commit is contained in:
parent
cc90c2be50
commit
3f70dafcd4
2 changed files with 11 additions and 5 deletions
|
@ -25,6 +25,7 @@ import Logs.Remote
|
||||||
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import Data.Char
|
||||||
|
|
||||||
{- Sets up and begins syncing with a new ssh or rsync remote. -}
|
{- Sets up and begins syncing with a new ssh or rsync remote. -}
|
||||||
makeSshRemote :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Bool -> SshData -> IO ()
|
makeSshRemote :: ThreadState -> DaemonStatusHandle -> ScanRemoteMap -> Bool -> SshData -> IO ()
|
||||||
|
@ -99,14 +100,19 @@ makeRemote basename location a = do
|
||||||
samelocation x = Git.repoLocation x == location
|
samelocation x = Git.repoLocation x == location
|
||||||
|
|
||||||
{- Generate an unused name for a remote, adding a number if
|
{- Generate an unused name for a remote, adding a number if
|
||||||
- necessary. -}
|
- necessary.
|
||||||
|
-
|
||||||
|
- Ensures that the returned name is a legal git remote name. -}
|
||||||
uniqueRemoteName :: String -> Int -> Git.Repo -> String
|
uniqueRemoteName :: String -> Int -> Git.Repo -> String
|
||||||
uniqueRemoteName basename n r
|
uniqueRemoteName basename n r
|
||||||
| null namecollision = name
|
| null namecollision = name
|
||||||
| otherwise = uniqueRemoteName basename (succ n) r
|
| otherwise = uniqueRemoteName legalbasename (succ n) r
|
||||||
where
|
where
|
||||||
namecollision = filter samename (Git.remotes r)
|
namecollision = filter samename (Git.remotes r)
|
||||||
samename x = Git.remoteName x == Just name
|
samename x = Git.remoteName x == Just name
|
||||||
name
|
name
|
||||||
| n == 0 = basename
|
| n == 0 = legalbasename
|
||||||
| otherwise = basename ++ show n
|
| otherwise = legalbasename ++ show n
|
||||||
|
legalbasename = filter legal basename
|
||||||
|
legal '_' = True
|
||||||
|
legal c = isAlphaNum c
|
||||||
|
|
|
@ -15,4 +15,4 @@ The assistant produces an internal server error and subsequently crashes complet
|
||||||
|
|
||||||
git-annex 3.20120924 from the Debian package in sid on Debian wheezy, amd64.
|
git-annex 3.20120924 from the Debian package in sid on Debian wheezy, amd64.
|
||||||
|
|
||||||
|
> Thanks for reporting this, I've fixed it in git. [[done]] --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue