JetBrains / idea-gitignore

.ignore support plugin for IntelliJ IDEA
Apache License 2.0
1.29k stars 176 forks source link

Exception in .gitignore plugin with git worktrees #842

Closed StefanHuebnerV closed 1 year ago

StefanHuebnerV commented 1 year ago

Prerequisites

Description

The plugin doesn't handle git worktrees. In a worktree, there is no ".git" subdirectory, but a ".git" file (that refers to the 'basic' checkout of the repository)

2023-06-27 16:45:24,952 [  32193] SEVERE - #c.i.u.EditorNotificationsImpl - Expected directory instead of file: /home/me/myprojects/branch-r7.1/.git [Plugin: mobi.hsz.idea.gitignore]
com.intellij.diagnostic.PluginException: Expected directory instead of file: /home/me/myprojects/branch-r7.1/.git [Plugin: mobi.hsz.idea.gitignore]
    at com.intellij.ui.EditorNotificationsImpl$updateEditors$job$1.invokeSuspend(EditorNotificationsImpl.kt:229)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: java.io.IOException: Expected directory instead of file: /home/me/myprojects/branch-r7.1/.git
    at com.intellij.openapi.vfs.VirtualFileUtil.findDirectory(VirtualFileUtil.kt:79)
    at mobi.hsz.idea.gitignore.daemon.MissingGitignoreNotificationProvider.collectNotificationData(MissingGitignoreNotificationProvider.kt:77)
    at com.intellij.ui.EditorNotificationsImpl$updateEditors$job$1$result$1.invoke(EditorNotificationsImpl.kt:207)
    at com.intellij.ui.EditorNotificationsImpl$updateEditors$job$1$result$1.invoke(EditorNotificationsImpl.kt:204)
    at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:108)
    at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:92)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:91)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
    at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
    at com.intellij.openapi.progress.CancellationKt.executeWithJobAndCompleteIt(cancellation.kt:126)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$1$lambda$0(cancellableReadAction.kt:49)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1102)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$1(cancellableReadAction.kt:47)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:129)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:45)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:91)
    at com.intellij.openapi.application.rw.InternalReadAction.access$tryReadCancellable(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:77)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:72)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
    at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:193)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:72)
    at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:64)
    at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invokeSuspend(InternalReadAction.kt:43)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invoke(InternalReadAction.kt)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invoke(InternalReadAction.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
    at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
    at com.intellij.openapi.application.rw.InternalReadAction.runReadAction(InternalReadAction.kt:39)
    at com.intellij.openapi.application.rw.PlatformReadActionSupport.executeReadAction(PlatformReadActionSupport.kt:29)
    at com.intellij.openapi.application.ReadActionSupport.executeReadAction$default(ReadActionSupport.kt:15)
    at com.intellij.openapi.application.CoroutinesKt.constrainedReadAction(coroutines.kt:55)
    at com.intellij.openapi.application.CoroutinesKt.readAction(coroutines.kt:22)
    at com.intellij.ui.EditorNotificationsImpl$updateEditors$job$1.invokeSuspend(EditorNotificationsImpl.kt:204)
    ... 6 more

Steps to Reproduce

  1. Have a local git repository
  2. git worktree add -b "branch-r7.1" /home/me/myprojects/branch-r7.1
  3. cd /home/me/myprojects/branch-r7.1
  4. Open project with clion

Expected behavior:

The plugin shall handle 'git worktree' repositories.

Actual behavior:

Pluging core dumps on clion/project start

Reproduces how often:

100%

Versions

Plugin:

4.5.1

IDE:

CLion 2023.1.4
Build #CL-231.9161.40, built on June 20, 2023
Licensed to *******

Runtime version: 17.0.7+10-b829.16 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.19.0-41-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 7000M
Cores: 16
Registry:
    directory.access.checker.enabled=false
    run.processes.with.pty=TRUE
    debugger.attach.dialog.enabled=true

Non-Bundled Plugins:
    String Manipulation (9.9.0)
    org.jetbrains.plugins.rest (231.8770.3)
    org.rust.lang (0.4.197.5401-231)
    GrepConsole (12.18.211.6693.0)
    PlantUML integration (6.3.0-IJ2022.2)
    nl.rubensten.texifyidea (0.7.30)
    com.github.itechbear.clion.cpplint (1.0.7)
    zielu.gittoolbox (500.0.10+213)
    mobi.hsz.idea.gitignore (4.5.1)
    io.probst.idea.clangformat (1.1.0)

Current Desktop: XFCE

OS:

$ uname -a
Linux myMachine 5.19.0-41-generic #42~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 18 17:40:00 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Additional Information

hsz commented 1 year ago

Thanks for reporting, fixed!