66#include "parse-options.h"
77#include "range-diff.h"
88#include "config.h"
9+ #include "parse.h"
910
1011
1112static const char * const builtin_range_diff_usage [] = {
@@ -15,6 +16,21 @@ N_("git range-diff [<options>] <base> <old-tip> <new-tip>"),
1516NULL
1617};
1718
19+ static int parse_max_memory (const struct option * opt , const char * arg , int unset )
20+ {
21+ size_t * max_memory = opt -> value ;
22+ uintmax_t val ;
23+
24+ if (unset )
25+ return 0 ;
26+
27+ if (!git_parse_unsigned (arg , & val , SIZE_MAX ))
28+ return error (_ ("invalid max-memory value: %s" ), arg );
29+
30+ * max_memory = (size_t )val ;
31+ return 0 ;
32+ }
33+
1834int cmd_range_diff (int argc ,
1935 const char * * argv ,
2036 const char * prefix ,
@@ -25,6 +41,7 @@ int cmd_range_diff(int argc,
2541 struct strvec diff_merges_arg = STRVEC_INIT ;
2642 struct range_diff_options range_diff_opts = {
2743 .creation_factor = RANGE_DIFF_CREATION_FACTOR_DEFAULT ,
44+ .max_memory = RANGE_DIFF_MAX_MEMORY_DEFAULT ,
2845 .diffopt = & diffopt ,
2946 .other_arg = & other_arg
3047 };
@@ -33,17 +50,21 @@ int cmd_range_diff(int argc,
3350 OPT_INTEGER (0 , "creation-factor" ,
3451 & range_diff_opts .creation_factor ,
3552 N_ ("percentage by which creation is weighted" )),
53+ OPT_PASSTHRU_ARGV (0 , "diff-merges" , & diff_merges_arg ,
54+ N_ ("style" ), N_ ("passed to 'git log'" ), 0 ),
55+ OPT_BOOL (0 , "left-only" , & left_only ,
56+ N_ ("only emit output related to the first range" )),
57+ OPT_CALLBACK (0 , "max-memory" , & range_diff_opts .max_memory ,
58+ N_ ("size" ),
59+ N_ ("maximum memory for cost matrix (default 4G)" ),
60+ parse_max_memory ),
3661 OPT_BOOL (0 , "no-dual-color" , & simple_color ,
3762 N_ ("use simple diff colors" )),
3863 OPT_PASSTHRU_ARGV (0 , "notes" , & other_arg ,
3964 N_ ("notes" ), N_ ("passed to 'git log'" ),
4065 PARSE_OPT_OPTARG ),
41- OPT_PASSTHRU_ARGV (0 , "diff-merges" , & diff_merges_arg ,
42- N_ ("style" ), N_ ("passed to 'git log'" ), 0 ),
4366 OPT_PASSTHRU_ARGV (0 , "remerge-diff" , & diff_merges_arg , NULL ,
4467 N_ ("passed to 'git log'" ), PARSE_OPT_NOARG ),
45- OPT_BOOL (0 , "left-only" , & left_only ,
46- N_ ("only emit output related to the first range" )),
4768 OPT_BOOL (0 , "right-only" , & right_only ,
4869 N_ ("only emit output related to the second range" )),
4970 OPT_END ()
0 commit comments