From 1fb378dbafbaefaa5cba6c71f9004be0673d42ab Mon Sep 17 00:00:00 2001 From: Matt Rubin Date: Sat, 17 Dec 2016 01:35:05 -0500 Subject: [PATCH] Use the Swift API for getting a URL's file system representation --- SwiftGit2/Repository.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SwiftGit2/Repository.swift b/SwiftGit2/Repository.swift index 332bd5d..d67107b 100644 --- a/SwiftGit2/Repository.swift +++ b/SwiftGit2/Repository.swift @@ -105,7 +105,9 @@ final public class Repository { /// Returns a `Result` with a `Repository` or an error. class public func atURL(_ url: URL) -> Result { var pointer: OpaquePointer? = nil - let result = git_repository_open(&pointer, (url as NSURL).fileSystemRepresentation) + let result = url.withUnsafeFileSystemRepresentation { + git_repository_open(&pointer, $0) + } if result != GIT_OK.rawValue { return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_repository_open")) @@ -135,7 +137,9 @@ final public class Repository { var pointer: OpaquePointer? = nil let remoteURLString = (remoteURL as NSURL).isFileReferenceURL() ? remoteURL.path : remoteURL.absoluteString - let result = git_clone(&pointer, remoteURLString, (toURL as NSURL).fileSystemRepresentation, &options) + let result = toURL.withUnsafeFileSystemRepresentation { + git_clone(&pointer, remoteURLString, $0, &options) + } if result != GIT_OK.rawValue { return Result.failure(libGit2Error(result, libGit2PointOfFailure: "git_clone"))