apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.72k stars 865 forks source link

Projects that are GIT submodules trigger exception when NetBeans is looking for ./.git/nbconfig #7107

Open aeckstein opened 11 months ago

aeckstein commented 11 months ago

Apache NetBeans version

Apache NetBeans 21

What happened

Assume two projects that are GIT repos, 'A' and 'B'. 'B' lives as a GIT submodule inside 'A'. On NetBeans startup, the IDE checks if there is a .git/nbconfig file (as per RepositoryInfo.java). However, for the submodule 'B', .git is not a directory, but a text file containing the path to the actual GIT directory location, in this case '../.git/modules/B'. Presumably, one couldn't activate the 'autoSync' NetBeans feature either. Has been present at least in NetBeans-20 too, probably for longer.

Not sure what the correct solution here is, creating nbconfig in ../.git/modules/B/, or perhaps using a different config file location altogether, e.g. ./nbproject/private/nbgitconfig; happy to create a pull request if I can get some guidance on the proper nbconfig location.

The exception thrown is

java.nio.file.FileSystemException: /home/javadevel/NetBeansProjects/A/B/.git/nbconfig: Not a directory
    at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
    at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
    at java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
    at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:171)
    at java.base/sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99)
    at java.base/java.nio.file.Files.readAttributes(Files.java:1853)
    at org.eclipse.jgit.util.FileUtils.fileAttributes(FileUtils.java:827)
    at org.eclipse.jgit.util.FS.fileAttributes(FS.java:1294)
[catch] at org.eclipse.jgit.internal.storage.file.FileSnapshot.<init>(FileSnapshot.java:234)
    at org.eclipse.jgit.internal.storage.file.FileSnapshot.saveNoConfig(FileSnapshot.java:120)
    at org.eclipse.jgit.storage.file.FileBasedConfig.load(FileBasedConfig.java:147)
    at org.eclipse.jgit.util.FileUtils.readWithRetries(FileUtils.java:733)
    at org.eclipse.jgit.storage.file.FileBasedConfig.load(FileBasedConfig.java:128)
    at org.netbeans.modules.git.ui.repository.RepositoryInfo$NBGitConfig.refresh(RepositoryInfo.java:687)
    at org.netbeans.modules.git.ui.repository.RepositoryInfo$NBGitConfig.access$300(RepositoryInfo.java:655)
    at org.netbeans.modules.git.ui.repository.RepositoryInfo.getNetbeansConfig(RepositoryInfo.java:283)
    at org.netbeans.modules.git.ui.repository.RepositoryInfo.refresh(RepositoryInfo.java:183)
    at org.netbeans.modules.git.ui.repository.RepositoryInfo.getInstance(RepositoryInfo.java:159)
    at org.netbeans.modules.git.Annotator.annotateFolderIcon(Annotator.java:361)
    at org.netbeans.modules.git.Annotator.annotateIcon(Annotator.java:244)
    at org.netbeans.modules.versioning.DelegatingVCS$2.annotateIcon(DelegatingVCS.java:224)
    at org.netbeans.modules.versioning.core.VersioningAnnotationProvider$Cache.annotate(VersioningAnnotationProvider.java:633)
    at org.netbeans.modules.versioning.core.VersioningAnnotationProvider$Cache.annotate(VersioningAnnotationProvider.java:663)
    at org.netbeans.modules.versioning.core.VersioningAnnotationProvider$Cache.access$1500(VersioningAnnotationProvider.java:486)
    at org.netbeans.modules.versioning.core.VersioningAnnotationProvider$Cache$AnnotationRefreshTask.run(VersioningAnnotationProvider.java:769)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1420)
    at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
    at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2035)

Language / Project Type / NetBeans Component

Project and GIT repository

How to reproduce

Create two projects 'A' and 'B' (in the same base folder in this instance), initialize a GIT repo in each project. Add one of the projects as a submodule to the other:

cd ./A/ git submodule add ../B/

Make sure project B is opened, close NetBeans, start NetBeans.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Linux

JDK

Temurin JDK 21.0.2_p13

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

No response

Are you willing to submit a pull request?

Yes