Skip to content

Commit

Permalink
script: cleanup. disable debug
Browse files Browse the repository at this point in the history
  • Loading branch information
roligugus committed Jul 10, 2020
1 parent a3b4ff3 commit 5f810a1
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions scripts/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#set -e
#set -x

PRINT_DEBUG=1
PRINT_DEBUG=0
# Debug output if PRINT_DEBUG is 1
function Debug {
if [ $PRINT_DEBUG -ne 0 ]; then
Expand Down Expand Up @@ -311,10 +311,9 @@ function CheckBranch {
esac
done

# Find first commit off master. 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.
local first_commit=$(FirstCommitOfBranch)
echo "First commit off master: $first_commit"

# git-clang-format is a python script that does not like SIGPIPE shut down
# by "| head" prematurely. Use work-around with writing to tmpfile first.
Expand All @@ -333,9 +332,8 @@ function CheckBranch {
fi
rm $tmpfile

if [ $quiet -eq 1 ]; then
return 1
else
if [ $quiet -ne 1 ]; then
echo "First commit on branch: $first_commit"
Error "Branch requires formatting"
Debug "View required changes with: ${italic}$format_changes${normal}"
if [ $from_make -eq 1 ]; then
Expand All @@ -345,11 +343,14 @@ function CheckBranch {
Error "View required changes with: ${italic}$EXEC $command --diff${normal}"
Die "Use ${italic}$EXEC rewrite-branch${normal} or ${italic}$EXEC branch${normal} to fix formatting"
fi
else
return 1
fi
else
rm $tmpfile

if [ $quiet -ne 1 ]; then
echo "First commit on branch: $first_commit"
echo "no modified files to format"
fi
return 0
Expand All @@ -374,10 +375,10 @@ function ReformatBranch {
fi
fi

# Find first commit off master. 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.
local first_commit=$(FirstCommitOfBranch)
echo "First commit off master: $first_commit"
echo "First commit on branch: $first_commit"

$GIT_CLANG_FORMAT --style file --extensions c,h $with_unstaged $first_commit^
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -434,10 +435,10 @@ function ReformatCommits {
# Should investigate using git-filter-repo in the future instead.
export FILTER_BRANCH_SQUELCH_WARNING=1

# Find first commit off master. 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.
local first_commit=$(FirstCommitOfBranch)
echo "First commit off master: $first_commit"
echo "First commit on branch: $first_commit"
# Use --force in case it's run a second time on the same branch
git filter-branch --force --tree-filter "$GIT_CLANG_FORMAT $first_commit^" -- $first_commit..HEAD
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit 5f810a1

Please sign in to comment.