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
IDEA-157915: Fix symbolic-ref in HEAD #424
IDEA-157915: Fix symbolic-ref in HEAD #424
Conversation
Have you submitted a contributor license agreement? If not, please check your mail box: I've just sent a sign request there via DocuSign. |
Yes, I've just signed it. |
Received, thanks. I see that you've at first closed this pull request right after creation, and then reopened it a week later. But Github doesn't show any new/rewritten commits here. You just wanted to test it more, or you closed it by accident? |
Yes, I just wanted PR to be first reviewed by my colleagues, but accidentally created it in JetBrains repo instead of my fork |
|
||
@NotNull | ||
File getBranchFile(String path) { | ||
return new File(FileUtil.toSystemDependentName(myMainDir.getCanonicalPath() + File.separatorChar + 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.
Looks like this should be changed to
@NotNull
File getBranchFile(@NotNull String fullBranchName) {
return file(myMainDir.getPath() + slash(fullBranchName));
}
(see other get*File
methods and isBranchFile()
)
Merged the patch with a few mentioned corrections. Thanks a lot! |
Ah. Together we missed the fact that the linked reference can reside in |
And how can this happen? symbolic-ref in origin? |
It seems that to solve the issue we'll have first to read all references to a map, both from |
Thank you, I'll try to do something with this. |
Cool, thanks. I've written a test which reveals the issue. package git4idea.repo
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.LocalFileSystem
import git4idea.branch.GitBranchUtil.stripRefsPrefix
import git4idea.test.GitExecutor.cd
import git4idea.test.GitExecutor.git
import git4idea.test.GitPlatformTest
import git4idea.test.GitTestUtil.makeCommit
import java.io.File
class GitRepositoryReaderNew2Test : GitPlatformTest() {
fun `test packed symbolic ref`() {
cd(myProjectPath)
git("init")
makeCommit("file.txt")
git("pack-refs --all")
// verify master is packed
val gitDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(File(myProjectPath, ".git"))!!
val repoFiles = GitRepositoryFiles.getInstance(gitDir)
assertFalse("setup failed: master is not packed", File(repoFiles.refsHeadsFile, "master").exists())
assertTrue("setup failed: master is not packed",
FileUtil.loadFile(repoFiles.packedRefsPath).lines().any { it.endsWith("refs/heads/master") })
val repo = GitRepositoryImpl.getInstance(myProjectRoot, myProject, false)
assertEquals("HEAD should be on master", "master", stripRefsPrefix(repo.currentBranchName!!))
assertEquals("HEAD revision is incorrect", git("rev-parse HEAD"), repo.currentRevision)
assertEquals("master revision is incorrect",
git("rev-parse master"),
repo.branches.getHash(repo.branches.findLocalBranch("master")!!)!!.asString())
}
} |
No description provided.