@@ -64,15 +64,18 @@ static void stuff_change(struct diff_options *opt,
64
64
65
65
static int builtin_diff_b_f (struct rev_info * revs ,
66
66
int argc , const char * * argv ,
67
- struct blobinfo * blob ,
68
- const char * path )
67
+ struct blobinfo * blob )
69
68
{
70
69
/* Blob vs file in the working tree*/
71
70
struct stat st ;
71
+ const char * path ;
72
72
73
73
if (argc > 1 )
74
74
usage (builtin_diff_usage );
75
75
76
+ GUARD_PATHSPEC (& revs -> prune_data , PATHSPEC_FROMTOP | PATHSPEC_LITERAL );
77
+ path = revs -> prune_data .items [0 ].match ;
78
+
76
79
if (lstat (path , & st ))
77
80
die_errno (_ ("failed to stat '%s'" ), path );
78
81
if (!(S_ISREG (st .st_mode ) || S_ISLNK (st .st_mode )))
@@ -255,7 +258,6 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
255
258
struct rev_info rev ;
256
259
struct object_array ent = OBJECT_ARRAY_INIT ;
257
260
int blobs = 0 , paths = 0 ;
258
- const char * path = NULL ;
259
261
struct blobinfo blob [2 ];
260
262
int nongit ;
261
263
int result = 0 ;
@@ -366,13 +368,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
366
368
die (_ ("unhandled object '%s' given." ), name );
367
369
}
368
370
}
369
- if (rev .prune_data .nr ) {
370
- /* builtin_diff_b_f() */
371
- GUARD_PATHSPEC (& rev .prune_data , PATHSPEC_FROMTOP | PATHSPEC_LITERAL );
372
- if (!path )
373
- path = rev .prune_data .items [0 ].match ;
371
+ if (rev .prune_data .nr )
374
372
paths += rev .prune_data .nr ;
375
- }
376
373
377
374
/*
378
375
* Now, do the arguments look reasonable?
@@ -385,7 +382,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
385
382
case 1 :
386
383
if (paths != 1 )
387
384
usage (builtin_diff_usage );
388
- result = builtin_diff_b_f (& rev , argc , argv , blob , path );
385
+ result = builtin_diff_b_f (& rev , argc , argv , blob );
389
386
break ;
390
387
case 2 :
391
388
if (paths )
0 commit comments