@@ -64,15 +64,18 @@ static void stuff_change(struct diff_options *opt,
6464
6565static int builtin_diff_b_f (struct rev_info * revs ,
6666 int argc , const char * * argv ,
67- struct blobinfo * blob ,
68- const char * path )
67+ struct blobinfo * blob )
6968{
7069 /* Blob vs file in the working tree*/
7170 struct stat st ;
71+ const char * path ;
7272
7373 if (argc > 1 )
7474 usage (builtin_diff_usage );
7575
76+ GUARD_PATHSPEC (& revs -> prune_data , PATHSPEC_FROMTOP | PATHSPEC_LITERAL );
77+ path = revs -> prune_data .items [0 ].match ;
78+
7679 if (lstat (path , & st ))
7780 die_errno (_ ("failed to stat '%s'" ), path );
7881 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)
255258 struct rev_info rev ;
256259 struct object_array ent = OBJECT_ARRAY_INIT ;
257260 int blobs = 0 , paths = 0 ;
258- const char * path = NULL ;
259261 struct blobinfo blob [2 ];
260262 int nongit ;
261263 int result = 0 ;
@@ -366,13 +368,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
366368 die (_ ("unhandled object '%s' given." ), name );
367369 }
368370 }
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 )
374372 paths += rev .prune_data .nr ;
375- }
376373
377374 /*
378375 * Now, do the arguments look reasonable?
@@ -385,7 +382,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
385382 case 1 :
386383 if (paths != 1 )
387384 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 );
389386 break ;
390387 case 2 :
391388 if (paths )
0 commit comments