@@ -285,21 +285,57 @@ await processManager.ExecuteGit(repo1, [
285
285
includeAdditionalMappings : false ,
286
286
CancellationToken . None ) ;
287
287
288
- // If tmpDirectory is not null, it means the output path was not provided, so we just want to
289
- // print out the whole diff
290
- if ( ! string . IsNullOrEmpty ( tmpDirectory ) )
288
+ try
291
289
{
292
- foreach ( var patch in patches )
290
+ if ( options . NameOnly )
291
+ {
292
+ var files = new List < UnixPath > ( ) ;
293
+
294
+ // For name-only mode, we'll print the filenames directly from the git patch summary lines
295
+ foreach ( var patch in patches )
296
+ {
297
+ files . AddRange ( await patchHandler . GetPatchedFiles ( patch . Path , CancellationToken . None ) ) ;
298
+ }
299
+
300
+ var list = files
301
+ . Select ( f => f . Path )
302
+ . OrderBy ( f => f ) ;
303
+
304
+ // If the output path was provided, the list will be stored there
305
+ // Otherwise we want to print it
306
+ if ( string . IsNullOrEmpty ( options . OutputPath ) )
307
+ {
308
+ foreach ( var file in list )
309
+ {
310
+ Console . WriteLine ( file ) ;
311
+ }
312
+ }
313
+ else
314
+ {
315
+ await File . WriteAllLinesAsync ( outputPath , list ) ;
316
+ }
317
+ }
318
+ else
293
319
{
294
- using FileStream fs = new ( patch . Path , FileMode . Open , FileAccess . Read ) ;
295
- using StreamReader sr = new ( fs ) ;
296
- string ? line ;
297
- while ( ( line = await sr . ReadLineAsync ( ) ) != null )
320
+ // For regular diff mode, we print the full diff content
321
+ foreach ( var patch in patches )
298
322
{
299
- Console . WriteLine ( line ) ;
323
+ using FileStream fs = new ( patch . Path , FileMode . Open , FileAccess . Read ) ;
324
+ using StreamReader sr = new ( fs ) ;
325
+ string ? line ;
326
+ while ( ( line = await sr . ReadLineAsync ( ) ) != null )
327
+ {
328
+ Console . WriteLine ( line ) ;
329
+ }
300
330
}
301
331
}
302
- fileSystem . DeleteDirectory ( tmpDirectory , true ) ;
332
+ }
333
+ finally
334
+ {
335
+ if ( ! string . IsNullOrEmpty ( tmpDirectory ) )
336
+ {
337
+ fileSystem . DeleteDirectory ( tmpDirectory , true ) ;
338
+ }
303
339
}
304
340
}
305
341
0 commit comments