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

Add format options for path and changed files based on git diff #3

Open
ElectricRCAircraftGuy opened this issue Mar 16, 2021 · 0 comments

Comments

@ElectricRCAircraftGuy
Copy link
Owner

ElectricRCAircraftGuy commented Mar 16, 2021

Options should include a list of files or dirs, or a commit range of changed files.

See also my answer here: https://stackoverflow.com/questions/30905086/git-list-of-all-changed-but-not-deleted-files-in-a-commit/66649684#66649684.

The below func works only on filenames which have no spaces or special bash chars. So, make it work with spaces too!

To make it handle these chars, it will require using git diff --name-only -z or something. See my answer here: https://stackoverflow.com/questions/28109520/how-to-cope-with-spaces-in-file-names-when-iterating-results-from-git-diff-nam/62853776#62853776

Example:

gs_format_code() {
    files="$(git diff --name-only --diff-filter=d $1 $2)"
    echo "Manually formatting just these files:"
    echo "$files"
    clang-format --verbose -i --style=file $files
}
@ElectricRCAircraftGuy ElectricRCAircraftGuy changed the title Add format options for path and changed files Add format options for path and changed files based on git diff Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant