From 3b1f8ffc8cc2260d5b7ac54ff7cab98ca4f8a2f2 Mon Sep 17 00:00:00 2001 From: Giovanni De Toni Date: Mon, 17 Jul 2017 10:13:39 +0200 Subject: [PATCH] Fix clang-format script when dealing with deleted files. --- scripts/check_format.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 9a4c64db773..92520bd8ef1 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -31,7 +31,17 @@ function check_shogun_style { echo "Running clang-format-3.8 against branch ${2:-}, with hash $BASE_COMMIT" COMMIT_FILES=$(git diff --name-only $BASE_COMMIT) - RESULT_OUTPUT="$(git clang-format-3.8 --commit $BASE_COMMIT --diff --binary `which clang-format-3.8` $COMMIT_FILES)" + + # Use clang-format only on existent files + LIST="" + for file in $COMMIT_FILES + do + if [ -f $file ]; then + LIST+="$file\n" + fi + done + + RESULT_OUTPUT="$(git clang-format-3.8 --commit $BASE_COMMIT --diff --binary `which clang-format-3.8` $LIST)" if [ "$RESULT_OUTPUT" == "no modified files to format" ] \ || [ "$RESULT_OUTPUT" == "clang-format-3.8 did not modify any files" ] \