Skip to content

Commit b88903d

Browse files
committed
Convert local file: URLs to paths before handing over to git_clone.
Fixes a bug where a locally-cloned remote would get a `file:` URL as it's origin URL, making the push machinery shrivel in fear.
1 parent 9bc13e2 commit b88903d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Classes/GTRepository.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,14 @@ + (id)cloneFromURL:(NSURL *)originURL toWorkingDirectory:(NSURL *)workdirURL opt
218218
cloneOptions.remote_callbacks.transfer_progress = transferProgressCallback;
219219
cloneOptions.remote_callbacks.payload = &payload;
220220

221-
const char *remoteURL = originURL.absoluteString.UTF8String;
222-
const char *workingDirectoryPath = workdirURL.path.UTF8String;
221+
// If our originURL is local, convert to a path before handing down.
222+
const char *remoteURL = NULL;
223+
if (originURL.isFileURL || originURL.isFileReferenceURL) {
224+
remoteURL = originURL.filePathURL.path.fileSystemRepresentation;
225+
} else {
226+
remoteURL = originURL.absoluteString.UTF8String;
227+
}
228+
const char *workingDirectoryPath = workdirURL.path.fileSystemRepresentation;
223229
git_repository *repository;
224230
int gitError = git_clone(&repository, remoteURL, workingDirectoryPath, &cloneOptions);
225231
if (gitError < GIT_OK) {

0 commit comments

Comments
 (0)