@@ -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,26 @@ static int blame_move_callback(const struct option *option, const char *arg, int
824837 return 0 ;
825838}
826839
840+ static int blame_diff_algorithm_callback (const struct option * option ,
841+ const char * arg , int unset )
842+ {
843+ int * opt = option -> value ;
844+ long value = parse_algorithm_value (arg );
845+
846+ BUG_ON_OPT_NEG (unset );
847+
848+ if (value < 0 )
849+ return error (_ ("option diff-algorithm accepts \"myers\", "
850+ "\"minimal\", \"patience\" and \"histogram\"" ));
851+
852+ // ignore any previous --minimal setting, following git-diff's behavior
853+ * opt &= ~XDF_NEED_MINIMAL ;
854+ * opt &= ~XDF_DIFF_ALGORITHM_MASK ;
855+ * opt |= value ;
856+
857+ return 0 ;
858+ }
859+
827860static int is_a_rev (const char * name )
828861{
829862 struct object_id oid ;
@@ -908,13 +941,16 @@ int cmd_blame(int argc,
908941 OPT_BIT ('f' , "show-name" , & output_option , N_ ("show original filename (Default: auto)" ), OUTPUT_SHOW_NAME ),
909942 OPT_BIT ('n' , "show-number" , & output_option , N_ ("show original linenumber (Default: off)" ), OUTPUT_SHOW_NUMBER ),
910943 OPT_BIT ('p' , "porcelain" , & output_option , N_ ("show in a format designed for machine consumption" ), OUTPUT_PORCELAIN ),
911- OPT_BIT (0 , "line-porcelain" , & output_option , N_ ("show porcelain format with per-line commit information" ), OUTPUT_PORCELAIN | OUTPUT_LINE_PORCELAIN ),
944+ OPT_BIT (0 , "line-porcelain" , & output_option , N_ ("show porcelain format with per-line commit information" ), OUTPUT_PORCELAIN | OUTPUT_LINE_PORCELAIN ),
912945 OPT_BIT ('c' , NULL , & output_option , N_ ("use the same output mode as git-annotate (Default: off)" ), OUTPUT_ANNOTATE_COMPAT ),
913946 OPT_BIT ('t' , NULL , & output_option , N_ ("show raw timestamp (Default: off)" ), OUTPUT_RAW_TIMESTAMP ),
914947 OPT_BIT ('l' , NULL , & output_option , N_ ("show long commit SHA1 (Default: off)" ), OUTPUT_LONG_OBJECT_NAME ),
915948 OPT_BIT ('s' , NULL , & output_option , N_ ("suppress author name and timestamp (Default: off)" ), OUTPUT_NO_AUTHOR ),
916949 OPT_BIT ('e' , "show-email" , & output_option , N_ ("show author email instead of name (Default: off)" ), OUTPUT_SHOW_EMAIL ),
917950 OPT_BIT ('w' , NULL , & xdl_opts , N_ ("ignore whitespace differences" ), XDF_IGNORE_WHITESPACE ),
951+ OPT_CALLBACK_F (0 , "diff-algorithm" , & xdl_opts , N_ ("<algorithm>" ),
952+ N_ ("choose a diff algorithm" ),
953+ PARSE_OPT_NONEG , blame_diff_algorithm_callback ),
918954 OPT_STRING_LIST (0 , "ignore-rev" , & ignore_rev_list , N_ ("rev" ), N_ ("ignore <rev> when blaming" )),
919955 OPT_STRING_LIST (0 , "ignore-revs-file" , & ignore_revs_file_list , N_ ("file" ), N_ ("ignore revisions from <file>" )),
920956 OPT_BIT (0 , "color-lines" , & output_option , N_ ("color redundant metadata from previous line differently" ), OUTPUT_COLOR_LINE ),
0 commit comments