Skip to content

file-lines do not reformat parts of a multi-line statement #4053

Open
@athei

Description

@athei

Imagine the following statement in which one line is wrongly indented:

let diff = repo
.diff_tree_to_workdir(Some(&head), Some(&mut diff_options))
    .unwrap();

I now specify only the second line in my --file-lines.

What I expect to happen
The second line becomes correctly indented to match the same column as the .unwrap().

What actually happens
Nothing. The line is ignored because it is part of a larger statement.

Why this is a problem
I have a use case where a script uses git and --file-lines to only format lines which where changed in a specific commit. This script fails when someone just edits parts of a larger statement because the line is not formatted then. Adding more context to the range is also not viable because then lines are formatted that weren't touched in the commit.

#3397

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-chainsonly-with-optionrequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions