@@ -779,6 +779,19 @@ static int git_blame_config(const char *var, const char *value,
779779 }
780780 }
781781
782+ if (!strcmp (var , "diff.algorithm" )) {
783+ long diff_algorithm ;
784+ if (!value )
785+ return config_error_nonbool (var );
786+ diff_algorithm = parse_algorithm_value (value );
787+ if (diff_algorithm < 0 )
788+ return error (_ ("unknown value for config '%s': %s" ),
789+ var , value );
790+ xdl_opts &= ~XDF_DIFF_ALGORITHM_MASK ;
791+ xdl_opts |= diff_algorithm ;
792+ return 0 ;
793+ }
794+
782795 if (git_diff_heuristic_config (var , value , cb ) < 0 )
783796 return -1 ;
784797 if (userdiff_config (var , value ) < 0 )
@@ -824,6 +837,38 @@ static int blame_move_callback(const struct option *option, const char *arg, int
824837 return 0 ;
825838}
826839
840+ static int blame_diff_algorithm_minimal (const struct option * option ,
841+ const char * arg , int unset )
842+ {
843+ int * opt = option -> value ;
844+
845+ BUG_ON_OPT_NEG (unset );
846+ BUG_ON_OPT_ARG (arg );
847+
848+ * opt &= ~XDF_DIFF_ALGORITHM_MASK ;
849+ * opt |= XDF_NEED_MINIMAL ;
850+
851+ return 0 ;
852+ }
853+
854+ static int blame_diff_algorithm_callback (const struct option * option ,
855+ const char * arg , int unset )
856+ {
857+ int * opt = option -> value ;
858+ long value = parse_algorithm_value (arg );
859+
860+ BUG_ON_OPT_NEG (unset );
861+
862+ if (value < 0 )
863+ return error (_ ("option diff-algorithm accepts \"myers\", "
864+ "\"minimal\", \"patience\" and \"histogram\"" ));
865+
866+ * opt &= ~(XDF_NEED_MINIMAL | XDF_DIFF_ALGORITHM_MASK );
867+ * opt |= value ;
868+
869+ return 0 ;
870+ }
871+
827872static int is_a_rev (const char * name )
828873{
829874 struct object_id oid ;
@@ -915,11 +960,17 @@ int cmd_blame(int argc,
915960 OPT_BIT ('s' , NULL , & output_option , N_ ("suppress author name and timestamp (Default: off)" ), OUTPUT_NO_AUTHOR ),
916961 OPT_BIT ('e' , "show-email" , & output_option , N_ ("show author email instead of name (Default: off)" ), OUTPUT_SHOW_EMAIL ),
917962 OPT_BIT ('w' , NULL , & xdl_opts , N_ ("ignore whitespace differences" ), XDF_IGNORE_WHITESPACE ),
963+ OPT_CALLBACK_F (0 , "diff-algorithm" , & xdl_opts , N_ ("<algorithm>" ),
964+ N_ ("choose a diff algorithm" ),
965+ PARSE_OPT_NONEG , blame_diff_algorithm_callback ),
918966 OPT_STRING_LIST (0 , "ignore-rev" , & ignore_rev_list , N_ ("rev" ), N_ ("ignore <rev> when blaming" )),
919967 OPT_STRING_LIST (0 , "ignore-revs-file" , & ignore_revs_file_list , N_ ("file" ), N_ ("ignore revisions from <file>" )),
920968 OPT_BIT (0 , "color-lines" , & output_option , N_ ("color redundant metadata from previous line differently" ), OUTPUT_COLOR_LINE ),
921969 OPT_BIT (0 , "color-by-age" , & output_option , N_ ("color lines by age" ), OUTPUT_SHOW_AGE_WITH_COLOR ),
922- OPT_BIT (0 , "minimal" , & xdl_opts , N_ ("spend extra cycles to find better match" ), XDF_NEED_MINIMAL ),
970+ OPT_CALLBACK_F (0 , "minimal" , & xdl_opts , NULL ,
971+ N_ ("spend extra cycles to find better match" ),
972+ PARSE_OPT_NONEG | PARSE_OPT_NOARG ,
973+ blame_diff_algorithm_minimal ),
923974 OPT_STRING ('S' , NULL , & revs_file , N_ ("file" ), N_ ("use revisions from <file> instead of calling git-rev-list" )),
924975 OPT_STRING (0 , "contents" , & contents_from , N_ ("file" ), N_ ("use <file>'s contents as the final image" )),
925976 OPT_CALLBACK_F ('C' , NULL , & opt , N_ ("score" ), N_ ("find line copies within and across files" ), PARSE_OPT_OPTARG , blame_copy_callback ),
0 commit comments