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
Fix "fatal: destination path … already exists" on checkout #861
Fix "fatal: destination path … already exists" on checkout #861
Conversation
`git rev-parse --git-dir` returns not only relative path but also absolute path. When absolute path was returned, it caused "fatal: destination path" error.
Good catch! Using a relative path makes me a little uneasy. Could we use |
Oh, this PR still have a bug. |
Thanks for reviewing. |
if (relativeOrAbsoluteGitDirectory as NSString).absolutePath { | ||
absoluteGitDirectory = relativeOrAbsoluteGitDirectory | ||
} else { | ||
absoluteGitDirectory = (directoryURL.path! as NSString).stringByAppendingPathComponent(relativeOrAbsoluteGitDirectory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directoryURL.URLByAppendingPathComponent
would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be as follows?:
absoluteGitDirectory = directoryURL.URLByAppendingPathComponent(relativeOrAbsoluteGitDirectory).path!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better as follows:
var absoluteGitDirectory: String?
if (relativeOrAbsoluteGitDirectory as NSString).absolutePath {
absoluteGitDirectory = relativeOrAbsoluteGitDirectory
} else {
absoluteGitDirectory = directoryURL.URLByAppendingPathComponent(relativeOrAbsoluteGitDirectory).path
}
var isDirectory: ObjCBool = false
let directoryExists = absoluteGitDirectory.map { NSFileManager.defaultManager().fileExistsAtPath($0, isDirectory: &isDirectory) } ?? false
That looks great! Thanks! |
…y-exists-on-checkout Fix "fatal: destination path … already exists" on checkout
git rev-parse --git-dir
returns not only relative path but also absolute path. When absolute path was returned, it caused "fatal: destination path" error.% git rev-parse --git-dir .git % cd Carthage/Checkouts/Argo % git rev-parse --git-dir /Users/norio/Documents/workspace/github/Carthage/.git/modules/Carthage/Checkouts/Argo %