Author: Aiden Grossman
Date: 2025-08-26T16:55:28Z
New Revision: f09986aab575b41e2e210d937a46dfce82eceebc

URL: 
https://github.com/llvm/llvm-project/commit/f09986aab575b41e2e210d937a46dfce82eceebc
DIFF: 
https://github.com/llvm/llvm-project/commit/f09986aab575b41e2e210d937a46dfce82eceebc.diff

LOG: [clang-format] Use proper flags for git diff-tree (#155247)

>From local testing, git diff-tree does not support three dot diffs
correctly, instead expecting the --merge-base flag to be passed along
with two commits. From my reading, the documentation
(https://git-scm.com/docs/git-diff-tree) also confirms this. This patch
updates the git-clang-format script to be correct.

I don't think we ever ran into this issue before because we never ended
up using it. For the PR code format job I believe we would just
explicitly pass the merge base, completely bypassing the problem.

Added: 
    

Modified: 
    clang/tools/clang-format/git-clang-format

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index e709803d9a3f1..fe2dd283d403e 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -419,7 +419,7 @@ def compute_
diff (commits, files, staged, 
diff _common_commit):
     if len(commits) == 2:
         git_tool = "
diff -tree"
         if 
diff _common_commit:
-            commits = [f"{commits[0]}...{commits[1]}"]
+            extra_args += ["--merge-base"]
     elif staged:
         extra_args += ["--cached"]
 


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

Reply via email to