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 MINVERSION=$TIMESTAMPING_VERSION
declare -i MAX_COMMITS_TO_CHECK=0 declare -i MAX_COMMITS_TO_CHECK=0
declare -A PROCESSED_COMMIT declare -A PROCESSED_COMMIT
declare -A PROCESSED_PARENT
declare -A COMMITS declare -A COMMITS
declare -A COMMIT_TIMES declare -A COMMIT_TIMES
@@ -323,12 +324,19 @@ validate_commit_and_parents() {
local COMMIT_HASH="$1" local COMMIT_HASH="$1"
log "validate_commit_and_parents for $COMMIT_HASH" 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 local ALL_PASSED=true
if ! validate_commit "$COMMIT_HASH"; then if ! validate_commit "$COMMIT_HASH"; then
ALL_PASSED=false ALL_PASSED=false
fi fi
NUM_COMMITS_CHECKED=${#PROCESSED_COMMIT[@]} NUM_COMMITS_CHECKED=${#PROCESSED_COMMIT[@]}
local PARENTS=$(git cat-file -p "$COMMIT_HASH" | awk '/^$/{exit} /parent/ {print}' | sed 's/parent //') local PARENTS=$(git cat-file -p "$COMMIT_HASH" | awk '/^$/{exit} /parent/ {print}' | sed 's/parent //')
#iterate over all parents of commit #iterate over all parents of commit
if [ ! -z "$PARENTS" ]; then if [ ! -z "$PARENTS" ]; then
while read PARENT_HASH; do while read PARENT_HASH; do
@@ -337,6 +345,7 @@ validate_commit_and_parents() {
fi fi
done <<< $(printf "%s" "$PARENTS") done <<< $(printf "%s" "$PARENTS")
fi fi
if [ "$ALL_PASSED" = true ]; then if [ "$ALL_PASSED" = true ]; then
return 0 return 0
fi fi