[clang] [git-clang-format] Fix: make the tool backward compatible (PR #108721)

2024-09-14 Thread Eden Reich via cfe-commits

https://github.com/edenreich created 
https://github.com/llvm/llvm-project/pull/108721

## Summary

Currently it's not backward compatible, because the flag -list-ignored doesn't 
exists on older version of clang-format.

To make this tool still backward compatible, we can first check if the 
.clang-format-ignore file exists before we run clang-format with the 
-list-ignored flag.

>From 04bf30e5d21460d8ceef1e2ef514b3c4653530f4 Mon Sep 17 00:00:00 2001
From: Eden Reich 
Date: Sun, 15 Sep 2024 00:25:50 +0200
Subject: [PATCH] Fix git-clang-format

Currently it's not backward compatible, because the flag -list-ignored doesn't 
exists on older version of clang-format.

To make this tool still backward compatible, we can first check if the 
.clang-format-ignore file exists before we run clang-format with the 
-list-ignored flag.
---
 clang/tools/clang-format/git-clang-format | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index bacbd8de245666..997644045c1f25 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -402,6 +402,8 @@ def filter_symlinks(dictionary):
 
 def filter_ignored_files(dictionary, binary):
   """Delete every key in `dictionary` that is ignored by clang-format."""
+  if not os.path.exists('.clang-format-ignore'):
+return
   ignored_files = run(binary, '-list-ignored', *dictionary.keys())
   if not ignored_files:
 return

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [git-clang-format] Fix: make the tool backward compatible (PR #108721)

2024-09-14 Thread Eden Reich via cfe-commits

https://github.com/edenreich edited 
https://github.com/llvm/llvm-project/pull/108721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [git-clang-format] Fix: make the tool backward compatible (PR #108721)

2024-09-14 Thread Eden Reich via cfe-commits

https://github.com/edenreich edited 
https://github.com/llvm/llvm-project/pull/108721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [git-clang-format] Fix: make the tool backward compatible (PR #108721)

2024-09-14 Thread Eden Reich via cfe-commits

https://github.com/edenreich edited 
https://github.com/llvm/llvm-project/pull/108721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [git-clang-format] Fix: make the tool backward compatible (PR #108721)

2024-09-15 Thread Eden Reich via cfe-commits

edenreich wrote:

Because I was trying to use this tool with the current stable release of 
clang-format, and it's currently broken?

IDK, or I just wait for the next release of clang-format before I can consider 
using git-clang-format 🤷‍♂️

https://github.com/llvm/llvm-project/pull/108721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [git-clang-format] Fix: make the tool backward compatible (PR #108721)

2024-09-15 Thread Eden Reich via cfe-commits

https://github.com/edenreich closed 
https://github.com/llvm/llvm-project/pull/108721
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits