|
|
|
@ -61,7 +61,7 @@ proper it provides additional functionality such as reformatting of all commits
|
|
|
|
|
|
|
|
|
|
|
|
Commands used in various situations:
|
|
|
|
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
|
|
|
|
branch Format all changes in branch as additional commit
|
|
|
|
rewrite-branch Format every commit in branch and rewrite history
|
|
|
|
rewrite-branch Format every commit in branch and rewrite history
|
|
|
|
|
|
|
|
|
|
|
|
@ -155,7 +155,7 @@ ${bold}DESCRIPTION${normal}
|
|
|
|
Check if all branch changes are correctly formatted.
|
|
|
|
Check if all branch changes are correctly formatted.
|
|
|
|
|
|
|
|
|
|
|
|
Note, it does not check every commit's formatting, but rather the
|
|
|
|
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.
|
|
|
|
Returns 1 if formatting is off, 0 if it is correct.
|
|
|
|
|
|
|
|
|
|
|
|
@ -215,7 +215,7 @@ ${bold}SYNOPSIS${normal}
|
|
|
|
$EXEC rewrite-branch
|
|
|
|
$EXEC rewrite-branch
|
|
|
|
|
|
|
|
|
|
|
|
${bold}DESCRIPTION${normal}
|
|
|
|
${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!
|
|
|
|
the branch history${normal} using the existing commit metadata!
|
|
|
|
It automatically detects all commits on your branch.
|
|
|
|
It automatically detects all commits on your branch.
|
|
|
|
|
|
|
|
|
|
|
|
@ -334,21 +334,21 @@ function HelpCommand {
|
|
|
|
esac
|
|
|
|
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.
|
|
|
|
# Use $first_commit^ if you need the commit on main we branched off.
|
|
|
|
# Do not compare with master directly as it will diff with the latest commit
|
|
|
|
# Do not compare with main directly as it will diff with the latest commit
|
|
|
|
# on master. If our branch has not been rebased on the latest master, this
|
|
|
|
# on main. If our branch has not been rebased on the latest main, this
|
|
|
|
# would result in including all new commits on master!
|
|
|
|
# would result in including all new commits on main!
|
|
|
|
function FirstCommitOfBranch {
|
|
|
|
function FirstCommitOfBranch {
|
|
|
|
start="${SURICATA_BRANCH:-origin/master}"
|
|
|
|
start="${SURICATA_BRANCH:-origin/main}"
|
|
|
|
local first_commit=$(git rev-list $start..HEAD | tail -n 1)
|
|
|
|
local first_commit=$(git rev-list $start..HEAD | tail -n 1)
|
|
|
|
echo $first_commit
|
|
|
|
echo $first_commit
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# Check if branch formatting is correct.
|
|
|
|
# Check if branch formatting is correct.
|
|
|
|
# Compares with master branch as baseline which means it's limited to branches
|
|
|
|
# Compares with main branch as baseline which means it's limited to branches
|
|
|
|
# other than master.
|
|
|
|
# other than main.
|
|
|
|
# Exits with 1 if not, 0 if ok.
|
|
|
|
# Exits with 1 if not, 0 if ok.
|
|
|
|
function CheckBranch {
|
|
|
|
function CheckBranch {
|
|
|
|
# check parameters
|
|
|
|
# check parameters
|
|
|
|
@ -396,7 +396,7 @@ function CheckBranch {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Find first commit on branch. Use $first_commit^ if you need the
|
|
|
|
# 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)
|
|
|
|
local first_commit=$(FirstCommitOfBranch)
|
|
|
|
|
|
|
|
|
|
|
|
# git-clang-format is a python script that does not like SIGPIPE shut down
|
|
|
|
# git-clang-format is a python script that does not like SIGPIPE shut down
|
|
|
|
@ -464,7 +464,7 @@ function ReformatBranch {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Find first commit on branch. Use $first_commit^ if you need the
|
|
|
|
# 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)
|
|
|
|
local first_commit=$(FirstCommitOfBranch)
|
|
|
|
echo "First commit on branch: $first_commit"
|
|
|
|
echo "First commit on branch: $first_commit"
|
|
|
|
|
|
|
|
|
|
|
|
@ -514,20 +514,20 @@ function ReformatCached {
|
|
|
|
fi
|
|
|
|
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.
|
|
|
|
# the history with the formatted commits one-by-one.
|
|
|
|
# This is helpful for quickly reformatting branches with multiple commits,
|
|
|
|
# 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
|
|
|
|
# You can achieve the same manually by git checkout -n <commit>, git clang-format
|
|
|
|
# for each commit in your branch.
|
|
|
|
# for each commit in your branch.
|
|
|
|
function ReformatCommitsOnBranch {
|
|
|
|
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
|
|
|
|
# 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)
|
|
|
|
local current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
if [ "$current_branch" == "master" ]; then
|
|
|
|
if [ "$current_branch" == "main" ]; then
|
|
|
|
Die "Must not rewrite master branch history."
|
|
|
|
Die "Must not rewrite main branch history."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
CheckBranch "--quiet"
|
|
|
|
CheckBranch "--quiet"
|
|
|
|
@ -540,7 +540,7 @@ function ReformatCommitsOnBranch {
|
|
|
|
export FILTER_BRANCH_SQUELCH_WARNING=1
|
|
|
|
export FILTER_BRANCH_SQUELCH_WARNING=1
|
|
|
|
|
|
|
|
|
|
|
|
# Find first commit on branch. Use $first_commit^ if you need the
|
|
|
|
# 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)
|
|
|
|
local first_commit=$(FirstCommitOfBranch)
|
|
|
|
echo "First commit on branch: $first_commit"
|
|
|
|
echo "First commit on branch: $first_commit"
|
|
|
|
# Use --force in case it's run a second time on the same branch
|
|
|
|
# Use --force in case it's run a second time on the same branch
|
|
|
|
|