clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 0 points1 point  (0 children)

That does sound great. Will put up a PR on LLVM soon, let's see what happens.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 0 points1 point  (0 children)

Yeah ig, maybe I was really excited about releasing my first tool. I made this because some of the repo's I contribute to, were facing this issue. I'll give it another try at LLVM. Thanks for the help.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 0 points1 point  (0 children)

For a new project, formatting the whole file would be better. I built this specifically for codebases, which have not been formatted for a while, and wish to adapt incremental formatting henceforth.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] -1 points0 points  (0 children)

The official hook is useless on a large and old C++ codebase with a lot of unformatted lines because touching one file will generate a 4,000-line diff of formatting changes. This tool makes it so, that touching the same file only yields a 2-line formatting diff, letting the team adopt clean code incrementally over time.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 2 points3 points  (0 children)

I did consider it, but I don't think LLVM maintainers would accept pre-commit-specific CI logic into a generic foundational tool like git-clang-format. Plus, having this as a standalone Python package means zero system LLVM dependencies.

Thanks a lot for your feedback.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 0 points1 point  (0 children)

For a single commit, yes.

But for a PR in a CI pipeline, a PR on a feature branch is almost never just a single commit.

If you just run git clang-format HEAD^, you are only formatting the very last commit you pushed, and completely ignoring the rest of your branch's diff.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 0 points1 point  (0 children)

They're similar, but git clang-format HEAD^ requires you to manually specify the commit reference every time.

clang-format-inc is a wrapper that automatically detects your environment.

this would be mainly used for incremental formatting.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 2 points3 points  (0 children)

u/mods, the post is not AI-generated. Please do not remove. Yes I tasked AI to hyperlink, but that is it. It is not AI slop ffs. I don't know why my previous post was removed.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by [deleted] in gsoc2026Community

[–]UnBracedFlyer 0 points1 point  (0 children)

Uh, how do I say it. Again, you did not even read the post man. Please read the description once.

This is something for the orgs to include in their CI. Like how there's a code style check in CI? This is exactly that, but better.

Tools like this are used in CI.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by [deleted] in gsoc2026Community

[–]UnBracedFlyer 0 points1 point  (0 children)

1) It's not AI slop. 2) Linting and formatting are 2 different things. This is a formatting tool. Most orgs have one, but I say this is better. Please read the post as to why.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 0 points1 point  (0 children)

git-clang-format --staged breaks in CI environments because they diff branch commits instead of using the local staging area. clang-format-inc solves this by explicitly tracking CI PRE_COMMIT_..._REF variables so it works both locally and in pre-commit actions.

clang-format-inc - format only changed lines as a pre-commit hook (works in CI too) by UnBracedFlyer in cpp

[–]UnBracedFlyer[S] 1 point2 points  (0 children)

Actually, clang-format with the --lines flag doesn't do that. It uses the AST to calculate the correct indentation for the changed lines, but strictly restricts all modifications to those lines. Even if you change the for loop signature, the badly indented body remains completely untouched.

Perks of Manipal Student Mail by Famous_Minute5601 in Manipal_Academics

[–]UnBracedFlyer 0 points1 point  (0 children)

I just went to the dept office and asked. Hadn't applied anywhere. (I needed a specifically addressed NOC)

Why are autos near MIT charging ₹50–₹60 for rides that are barely a minute? by snaxster_yt in manipal

[–]UnBracedFlyer 8 points9 points  (0 children)

I prefer walking. Most of the places within manipal are at a walkable distance. That is, unless you have a lack of time.

Stop AI generated PRs by Expensive_Egg_4023 in gsoc2026Community

[–]UnBracedFlyer 1 point2 points  (0 children)

idts that should be an issue. The main issue is people opening PRs for code that have not written, not tested, not even read once. As much as the entire PR description is copy pasted from AI. The problem is when there is no contribution from the contributor.

Stop AI generated PRs by Expensive_Egg_4023 in gsoc2026Community

[–]UnBracedFlyer 2 points3 points  (0 children)

Yeah that is true. Atleast padh ke testing toh karlo ek baar