@@ -30,6 +30,7 @@ class RepositoryWatcher : IRepositoryWatcher
3030 private readonly NPath [ ] ignoredPaths ;
3131 private readonly ManualResetEventSlim pauseEvent ;
3232 private NativeInterface nativeInterface ;
33+ private NativeInterface worktreeNativeInterface ;
3334 private bool running ;
3435 private int lastCountOfProcessedEvents = 0 ;
3536 private bool processingEvents ;
@@ -64,6 +65,11 @@ public void Initialize()
6465 try
6566 {
6667 nativeInterface = new NativeInterface ( pathsRepositoryPath ) ;
68+
69+ if ( paths . IsWorktree )
70+ {
71+ worktreeNativeInterface = new NativeInterface ( paths . WorktreeDotGitPath ) ;
72+ }
6773 }
6874 catch ( Exception ex )
6975 {
@@ -80,6 +86,18 @@ public void Start()
8086 }
8187
8288 Logger . Trace ( "Watching Path: \" {0}\" " , paths . RepositoryPath . ToString ( ) ) ;
89+
90+ if ( paths . IsWorktree )
91+ {
92+ if ( worktreeNativeInterface == null )
93+ {
94+ Logger . Warning ( "Worktree NativeInterface is null" ) ;
95+ throw new InvalidOperationException ( "Worktree NativeInterface is null" ) ;
96+ }
97+
98+ Logger . Trace ( "Watching Additional Path for Worktree: \" {0}\" " , paths . WorktreeDotGitPath ) ;
99+ }
100+
83101 running = true ;
84102 pauseEvent . Reset ( ) ;
85103 Task . Factory . StartNew ( WatcherLoop , cancellationToken , TaskCreationOptions . None , TaskScheduler . Default ) ;
@@ -131,6 +149,15 @@ public int CheckAndProcessEvents()
131149 processedEventCount = ProcessEvents ( fileEvents ) ;
132150 }
133151
152+ if ( worktreeNativeInterface != null )
153+ {
154+ fileEvents = worktreeNativeInterface . GetEvents ( ) ;
155+ if ( fileEvents . Length > 0 )
156+ {
157+ processedEventCount = processedEventCount + ProcessEvents ( fileEvents ) ;
158+ }
159+ }
160+
134161 lastCountOfProcessedEvents = processedEventCount ;
135162 processingEvents = false ;
136163 signalProcessingEventsDone . Set ( ) ;
@@ -158,7 +185,7 @@ private int ProcessEvents(Event[] fileEvents)
158185 var fileA = eventDirectory . Combine ( fileEvent . FileA ) ;
159186
160187 // handling events in .git/*
161- if ( fileA . IsChildOf ( paths . DotGitPath ) )
188+ if ( fileA . IsChildOf ( paths . DotGitPath ) || ( paths . WorktreeDotGitPath . IsInitialized && fileA . IsChildOf ( paths . WorktreeDotGitPath ) ) )
162189 {
163190 if ( ! events . Contains ( EventType . ConfigChanged ) && fileA . Equals ( paths . DotGitConfig ) )
164191 {
0 commit comments