validate parent chain only once

This commit is contained in:
Artur Neumann committed 2026-10-05 16:54:27 +05:45
1 parent 2dd8923dc4
commit 445aa5635e
1 file changed
+9
+9
View File
@@ -44,6 +44,7 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
declare -i MINVERSION=$TIMESTAMPING_VERSION
declare -i MAX_COMMITS_TO_CHECK=0
declare -A PROCESSED_COMMIT
declare -A PROCESSED_PARENT
declare -A COMMITS
declare -A COMMIT_TIMES
@@ -323,12 +324,19 @@ validate_commit_and_parents() {
local COMMIT_HASH="$1"
log "validate_commit_and_parents for $COMMIT_HASH"
if [[ ${PROCESSED_PARENT[$COMMIT_HASH]} ]]; then
log "parents for $COMMIT_HASH have already been validated"
return 0;
else
PROCESSED_PARENT[$COMMIT_HASH]=1
fi
local ALL_PASSED=true
if ! validate_commit "$COMMIT_HASH"; then
ALL_PASSED=false
fi
NUM_COMMITS_CHECKED=${#PROCESSED_COMMIT[@]}
local PARENTS=$(git cat-file -p "$COMMIT_HASH" | awk '/^$/{exit} /parent/ {print}' | sed 's/parent //')
#iterate over all parents of commit
if [ ! -z "$PARENTS" ]; then
while read PARENT_HASH; do
@@ -337,6 +345,7 @@ validate_commit_and_parents() {
fi
done <<< $(printf "%s" "$PARENTS")
fi
if [ "$ALL_PASSED" = true ]; then
return 0
fi