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
+14 -5
+14 -5
View File
@@ -17,22 +17,22 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# #
# The interactive user interfaces in modified source and object code versions # The interactive user interfaces in modified source and object code versions
# of this program must display Appropriate Legal Notices, as required under # of this program must display Appropriate Legal Notices, as required under
# Section 5 of the GNU Affero General Public License version 3. In accordance # Section 5 of the GNU Affero General Public License version 3. In accordance
# with Section 7(b) of the GNU Affero General Public License, you must retain # with Section 7(b) of the GNU Affero General Public License, you must retain
# the Info line in every timestamp that is created or manipulated using a # the Info line in every timestamp that is created or manipulated using a
# covered work. # covered work.
# #
# You can be released from the requirements of the license by purchasing # You can be released from the requirements of the license by purchasing
# a commercial license. Buying such a license is mandatory as soon as you # a commercial license. Buying such a license is mandatory as soon as you
# develop commercial activities involving this software without # develop commercial activities involving this software without
# disclosing the source code of your own applications. # disclosing the source code of your own applications.
# These activities include: offering paid services to customers as an ASP, # These activities include: offering paid services to customers as an ASP,
# providing data storage and archival services, shipping this software with a # providing data storage and archival services, shipping this software with a
# closed source product. # closed source product.
# #
# For more information, please contact Mabulous GmbH at this # For more information, please contact Mabulous GmbH at this
# address: info@mabulous.com # address: info@mabulous.com
# #
@@ -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
@@ -61,7 +62,7 @@ while [[ $# -gt 0 ]]; do
if [ $MINVERSION -gt $TIMESTAMPING_VERSION ]; then if [ $MINVERSION -gt $TIMESTAMPING_VERSION ]; then
echo_error "$KEY: this script only supports validating up to version $TIMESTAMPING_VERSION, but got $MINVERSION" echo_error "$KEY: this script only supports validating up to version $TIMESTAMPING_VERSION, but got $MINVERSION"
exit 1 exit 1
fi fi
shift # past argument shift # past argument
shift # past value shift # past value
;; ;;
@@ -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