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

clang-format breaks symlinks #46336

Open
stephenhines opened this issue Aug 4, 2020 · 4 comments
Open

clang-format breaks symlinks #46336

stephenhines opened this issue Aug 4, 2020 · 4 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla clang-format confirmed Verified by a second party

Comments

@stephenhines
Copy link
Collaborator

Bugzilla Link 46992
Resolution FIXED
Resolved on May 11, 2021 20:50
Version unspecified
OS Linux
CC @pirama-arumuga-nainar

Extended Description

This comes from an Android bug about running clang-format on a symlinked file (in this case, one named DisplayId.h that is pointing to a different DisplayId.h).

diff --git a/libs/ui/include_vndk/ui/DisplayId.h b/libs/ui/include_vndk/ui/DisplayId.h
index 73c9fe8d689..ec31ce4a306 120000
--- a/libs/ui/include_vndk/ui/DisplayId.h
+++ b/libs/ui/include_vndk/ui/DisplayId.h
@@ -1 +1 @@
-../../include/ui/DisplayId.h
\ No newline at end of file
+../../ include / ui / DisplayId.h
\ No newline at end of file

Ideally, clang-format would detect that it is running on a symlink and not adjust the file at all.

@stephenhines
Copy link
Collaborator Author

assigned to @pirama-arumuga-nainar

@pirama-arumuga-nainar
Copy link
Collaborator

To reproduce:

  1. create a symlink foo.h and commit it to a git project
  2. git-clang-format --diff --style file --extensions c,h,cc,cpp 85e55396aaa5ad5661232154f2ce778f4752b79f^ 85e55396aaa5ad5661232154f2ce778f4752b79f

This'd suggest a formatting change to the foo.h.

https://reviews.llvm.org/D101878 has a proposed fix.

@pirama-arumuga-nainar
Copy link
Collaborator

Fixed by 0fd0a01 (https://reviews.llvm.org/D101878).

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@NikolausDemmel
Copy link

It seems this was fixed only for git-clang-format. If you run clang-format -i on a symlink, it still seems replace the symlink with a regular file. I would expect it to either replace the file the symlink points to, or to skip the symlink.

Can this issue be reopened?

@rymiel rymiel reopened this Dec 22, 2023
@Endilll Endilll added the confirmed Verified by a second party label Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-format confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

5 participants