Skip to content

git-clang-format removes unstaged files #65643

Closed
llvm/llvm-project-release-prs
#736
@adorostkar

Description

@adorostkar

Hi all,
While running git clang-format I have come to a scenario where the script doesn't work as expected.

How to reproduce

  1. Have staged changes in file A which require reformatting
  2. Have staged changes in file B which don’t require reformatting
  3. Have unstaged changes in file B which are actual changes (let’s say new function)
  4. Run git clang-format --staged

The effect:

  • Unstaged changes in A which is the format change.
  • New changes in file B are deleted. <- this is the wrong behavior

Additional info

  1. The version of the clang-format and the script is 16.0.6
  2. I am running this on MacOs

If the changes that need formatting are staged in B and anything else is not staged in B then the git-clang-format refuses to format and prints a message saying that there are unstaged changes.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions