./mach clang-format with git doesn't use .clang-format-ignore to ignore some files & dirs

RESOLVED FIXED in Firefox 57

Status

RESOLVED FIXED
2 years ago
a year ago

People

(Reporter: sylvestre, Assigned: dex, Mentored)

Tracking

(Blocks: 1 bug, {good-first-bug})

Trunk
mozilla57
good-first-bug

Firefox Tracking Flags

(firefox57 fixed)

Details

(Whiteboard: [good first bug][lang=python])

Attachments

(1 attachment)

Comment 1

2 years ago
Hello, I'm new around here. From what I understood, the format that clang-format uses to ignore files is different for mercurial and git. 
I was referring to https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
and found that git has a different option called 'ignored' that does the same function as .clang-format-ignored.
Usage would be: 
git clang-format ignored dir

So I think we should change line 272 from:
diff_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD","--","*.c","*.cpp","*.h"], stdout=PIPE)
to:
diff_process = Popen(["git", "diff", "--no-color", "-U0", "HEAD","--","*.c","*.cpp","*.h", "clang-format", "ignored", "dir"], stdout=PIPE)
I don't know how I should mention the directory/file to be ignored. Help would be appreciated.
Please assign this bug to me if I have understood the problem correctly.
Flags: needinfo?(sledru)
(Reporter)

Comment 2

2 years ago
did you test your change in the code?
Thanks
Flags: needinfo?(sledru)

Comment 3

2 years ago
Not yet. I am going to proceed with running "./mach clang-format" on this git repo https://github.com/mozilla/gecko-dev.git and then going to try to fix any errors that may occur. Do you know which command I should use to specifically trigger the bug?
Thanks!
Flags: needinfo?(sledru)
(Reporter)

Comment 4

2 years ago
You should look for this yourself. This is part of the learning phase!
Flags: needinfo?(sledru)
Comment hidden (mozreview-request)
(Reporter)

Updated

2 years ago
Assignee: nobody → dex
(Reporter)

Comment 6

2 years ago
mozreview-review
Comment on attachment 8900921 [details]
Bug 1392012 - ./clang-format with git should exclude files from .clang-format-ignore

https://reviewboard.mozilla.org/r/172358/#review178456

once more, great work, thanks
Attachment #8900921 - Flags: review?(sledru) → review+

Comment 7

2 years ago
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/371686fcf5e0
/clang-format with git should exclude files from .clang-format-ignore r=sylvestre
https://hg.mozilla.org/mozilla-central/rev/371686fcf5e0
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox57: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla57

Updated

a year ago
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.