Commands used in various situations:
-Formatting branch changes (compared to master or SURICATA_BRANCH env variable):
+Formatting branch changes (compared to main or SURICATA_BRANCH env variable):
branch Format all changes in branch as additional commit
rewrite-branch Format every commit in branch and rewrite history
Check if all branch changes are correctly formatted.
Note, it does not check every commit's formatting, but rather the
- overall diff between HEAD and master.
+ overall diff between HEAD and main.
Returns 1 if formatting is off, 0 if it is correct.
$EXEC rewrite-branch
${bold}DESCRIPTION${normal}
- Reformat all commits in branch off master one-by-one. This will ${bold}rewrite
+ Reformat all commits in branch off main one-by-one. This will ${bold}rewrite
the branch history${normal} using the existing commit metadata!
It automatically detects all commits on your branch.
esac
}
-# Return first commit of branch (off master or SURICATA_BRANCH env variable).
+# Return first commit of branch (off main 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!
+# Use $first_commit^ if you need the commit on main we branched off.
+# Do not compare with main directly as it will diff with the latest commit
+# on main. If our branch has not been rebased on the latest main, this
+# would result in including all new commits on main!
function FirstCommitOfBranch {
- start="${SURICATA_BRANCH:-origin/master}"
+ start="${SURICATA_BRANCH:-origin/main}"
local first_commit=$(git rev-list $start..HEAD | tail -n 1)
echo $first_commit
}
# Check if branch formatting is correct.
-# Compares with master branch as baseline which means it's limited to branches
-# other than master.
+# Compares with main branch as baseline which means it's limited to branches
+# other than main.
# Exits with 1 if not, 0 if ok.
function CheckBranch {
# check parameters
fi
# Find first commit on branch. Use $first_commit^ if you need the
- # commit on master we branched off.
+ # commit on main we branched off.
local first_commit=$(FirstCommitOfBranch)
# git-clang-format is a python script that does not like SIGPIPE shut down
fi
# Find first commit on branch. Use $first_commit^ if you need the
- # commit on master we branched off.
+ # commit on main we branched off.
local first_commit=$(FirstCommitOfBranch)
echo "First commit on branch: $first_commit"
fi
}
-# Reformat all commits of a branch (compared with master) and rewrites
+# Reformat all commits of a branch (compared with main) and rewrites
# the history with the formatted commits one-by-one.
# This is helpful for quickly reformatting branches with multiple commits,
-# or where the master version of a file has been reformatted.
+# or where the main version of a file has been reformatted.
#
# You can achieve the same manually by git checkout -n <commit>, git clang-format
# for each commit in your branch.
function ReformatCommitsOnBranch {
- # Do not allow rewriting of master.
+ # Do not allow rewriting of main.
# CheckBranch below will also tell us there are no changes compared with
- # master, but let's make this foolproof and explicit here.
+ # main, but let's make this foolproof and explicit here.
local current_branch=$(git rev-parse --abbrev-ref HEAD)
- if [ "$current_branch" == "master" ]; then
- Die "Must not rewrite master branch history."
+ if [ "$current_branch" == "main" ]; then
+ Die "Must not rewrite main branch history."
fi
CheckBranch "--quiet"
export FILTER_BRANCH_SQUELCH_WARNING=1
# Find first commit on branch. Use $first_commit^ if you need the
- # commit on master we branched off.
+ # commit on main we branched off.
local first_commit=$(FirstCommitOfBranch)
echo "First commit on branch: $first_commit"
# Use --force in case it's run a second time on the same branch