@@ -280,18 +280,32 @@ private ITask<NPath[]> CalculateFileDiff(ChangesTreeNode node)
280280 var tmpDir = Manager . Environment . UnityProjectPath . Combine ( "Temp" , "ghu-diffs" ) . EnsureDirectoryExists ( ) ;
281281 var leftFile = tmpDir . Combine ( rightFile . FileName + "_" + Repository . CurrentHead + rightFile . ExtensionWithDot ) ;
282282 return new SimpleProcessTask ( TaskManager . Token , "show HEAD:\" " + rightFile . ToString ( SlashMode . Forward ) + "\" " )
283- . Configure ( Manager . ProcessManager , false )
284- . Catch ( _ => true )
285- . Then ( ( success , txt ) =>
286- {
287- if ( success )
288- leftFile . WriteAllText ( txt ) ;
289- else
290- leftFile = NPath . Default ;
291- if ( ! rightFile . FileExists ( ) )
292- rightFile = NPath . Default ;
293- return new NPath [ ] { leftFile , rightFile } ;
294- } ) ;
283+ . Configure ( Manager . ProcessManager , false )
284+ . Catch ( _ => true )
285+ . Then ( ( success , txt ) =>
286+ {
287+ // both files exist, just compare them
288+ if ( success && rightFile . FileExists ( ) )
289+ {
290+ leftFile . WriteAllText ( txt ) ;
291+ return new NPath [ ] { leftFile , rightFile } ;
292+ }
293+
294+ var leftFolder = tmpDir . Combine ( "left" , leftFile . FileName ) . EnsureDirectoryExists ( ) ;
295+ var rightFolder = tmpDir . Combine ( "right" , leftFile . FileName ) . EnsureDirectoryExists ( ) ;
296+ // file was deleted
297+ if ( ! rightFile . FileExists ( ) )
298+ {
299+ leftFolder . Combine ( rightFile ) . WriteAllText ( txt ) ;
300+ }
301+
302+ // file was created
303+ if ( ! success )
304+ {
305+ rightFolder . Combine ( rightFile ) . WriteAllText ( rightFile . ReadAllText ( ) ) ;
306+ }
307+ return new NPath [ ] { leftFolder , rightFolder } ;
308+ } ) ;
295309 }
296310
297311 private void RepositoryOnStatusEntriesChanged ( CacheUpdateEvent cacheUpdateEvent )
0 commit comments