]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
scripts: clang-format can use a different base than master 13296/head
authorPhilippe Antoine <pantoine@oisf.net>
Tue, 20 May 2025 13:12:15 +0000 (15:12 +0200)
committerPhilippe Antoine <pantoine@oisf.net>
Thu, 22 May 2025 08:41:20 +0000 (10:41 +0200)
useful for git hook running on main-7.0.x branches so that
not every commit gets its format checked again.

Ticket: 7292
(cherry picked from commit cca169f307126cb2b85ac27b0c9b0e3b17daa418)

scripts/clang-format.sh

index fc69e49dbf31874bebe561a8ed7dd463e7dd2122..e5fd187214d368e6c0fc14bd21a1c3bca4d34d8e 100755 (executable)
@@ -61,7 +61,7 @@ proper it provides additional functionality such as reformatting of all commits
 
 Commands used in various situations:
 
-Formatting branch changes (compared to master):
+Formatting branch changes (compared to master or SURICATA_BRANCH env variable):
     branch          Format all changes in branch as additional commit
     rewrite-branch  Format every commit in branch and rewrite history
 
@@ -335,14 +335,15 @@ function HelpCommand {
     esac
 }
 
-# Return first commit of branch (off master).
+# Return first commit of branch (off master or SURICATA_BRANCH env variable).
 #
 # Use $first_commit^ if you need the commit on master we branched off.
 # Do not compare with master directly as it will diff with the latest commit
 # on master. If our branch has not been rebased on the latest master, this
 # would result in including all new commits on master!
 function FirstCommitOfBranch {
-    local first_commit=$(git rev-list origin/master..HEAD | tail -n 1)
+    start="${SURICATA_BRANCH:-origin/master}"
+    local first_commit=$(git rev-list $start..HEAD | tail -n 1)
     echo $first_commit
 }