From: Philippe Antoine Date: Tue, 20 May 2025 13:12:15 +0000 (+0200) Subject: scripts: clang-format can use a different base than master X-Git-Tag: suricata-7.0.11~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a348f36cd8097463cf332f736c1492c158939d23;p=thirdparty%2Fsuricata.git scripts: clang-format can use a different base than master 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) --- diff --git a/scripts/clang-format.sh b/scripts/clang-format.sh index fc69e49dbf..e5fd187214 100755 --- a/scripts/clang-format.sh +++ b/scripts/clang-format.sh @@ -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 }