Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teach diff to honor diff algorithms set through git attributes #1452

Closed
wants to merge 2 commits into from

Commits on Feb 17, 2023

  1. diff: consolidate diff algorithm option parsing

    A subsequent commit will need the ability to tell if the diff algorithm
    was set through the command line through setting a new member of
    diff_options. While this logic can be added to the
    diff_opt_diff_algorithm() callback, the `--minimal` and `--histogram`
    options are handled via OPT_BIT without a callback.
    
    Remedy this by consolidating the options parsing logic for --minimal and
    --histogram into one callback. This way we can modify `diff_options` in
    that function.
    
    As an additional refactor, the logic that sets the diff algorithm in
    diff_opt_diff_algorithm() can be refactored into a helper that will
    allow multiple callsites to set the diff algorithm.
    
    Signed-off-by: John Cai <johncai86@gmail.com>
    john-cai authored and John Cai committed Feb 17, 2023
    Configuration menu
    Copy the full SHA
    816c47a View commit details
    Browse the repository at this point in the history

Commits on Feb 20, 2023

  1. diff: teach diff to read algorithm from diff driver

    It can be useful to specify diff algorithms per file type. For example,
    one may want to use the minimal diff algorithm for .json files, another
    for .c files, etc.
    
    The diff machinery already checks attributes for a diff driver. Teach
    the diff driver parser a new type "algorithm" to look for in the
    config, which will be used if a driver has been specified through the
    attributes.
    
    Enforce precedence of the diff algorithm by favoring the command line
    option, then looking at the driver attributes & config combination, then
    finally the diff.algorithm config.
    
    To enforce precedence order, use a new `ignore_driver_algorithm` member
    during options parsing to indicate the diff algorithm was set via command
    line args.
    
    Signed-off-by: John Cai <johncai86@gmail.com>
    john-cai authored and John Cai committed Feb 20, 2023
    Configuration menu
    Copy the full SHA
    77e66ab View commit details
    Browse the repository at this point in the history