@@ -3695,12 +3695,16 @@ static int parse_ws_error_highlight(struct diff_options *opt, const char *arg)
36953695 return 1 ;
36963696}
36973697
3698- int diff_opt_parse (struct diff_options * options , const char * * av , int ac )
3698+ int diff_opt_parse (struct diff_options * options ,
3699+ const char * * av , int ac , const char * prefix )
36993700{
37003701 const char * arg = av [0 ];
37013702 const char * optarg ;
37023703 int argcount ;
37033704
3705+ if (!prefix )
3706+ prefix = "" ;
3707+
37043708 /* Output format options */
37053709 if (!strcmp (arg , "-p" ) || !strcmp (arg , "-u" ) || !strcmp (arg , "--patch" )
37063710 || opt_arg (arg , 'U' , "unified" , & options -> context ))
@@ -3917,7 +3921,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
39173921 else if (!strcmp (arg , "--pickaxe-regex" ))
39183922 options -> pickaxe_opts |= DIFF_PICKAXE_REGEX ;
39193923 else if ((argcount = short_opt ('O' , av , & optarg ))) {
3920- options -> orderfile = optarg ;
3924+ const char * path = prefix_filename (prefix , strlen (prefix ), optarg );
3925+ options -> orderfile = xstrdup (path );
39213926 return argcount ;
39223927 }
39233928 else if ((argcount = parse_long_opt ("diff-filter" , av , & optarg ))) {
@@ -3956,9 +3961,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
39563961 else if (!strcmp (arg , "--no-function-context" ))
39573962 DIFF_OPT_CLR (options , FUNCCONTEXT );
39583963 else if ((argcount = parse_long_opt ("output" , av , & optarg ))) {
3959- options -> file = fopen (optarg , "w" );
3964+ const char * path = prefix_filename (prefix , strlen (prefix ), optarg );
3965+ options -> file = fopen (path , "w" );
39603966 if (!options -> file )
3961- die_errno ("Could not open '%s'" , optarg );
3967+ die_errno ("Could not open '%s'" , path );
39623968 options -> close_file = 1 ;
39633969 return argcount ;
39643970 } else
0 commit comments