validate parents only once #17
+14
-5
@@ -17,22 +17,22 @@
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
#
|
||||
# The interactive user interfaces in modified source and object code versions
|
||||
# of this program must display Appropriate Legal Notices, as required under
|
||||
# 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
|
||||
# the Info line in every timestamp that is created or manipulated using a
|
||||
# covered work.
|
||||
#
|
||||
#
|
||||
# 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
|
||||
# develop commercial activities involving this software without
|
||||
# disclosing the source code of your own applications.
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
# For more information, please contact Mabulous GmbH at this
|
||||
# address: info@mabulous.com
|
||||
#
|
||||
@@ -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
|
||||
|
||||
@@ -61,7 +62,7 @@ while [[ $# -gt 0 ]]; do
|
||||
if [ $MINVERSION -gt $TIMESTAMPING_VERSION ]; then
|
||||
echo_error "$KEY: this script only supports validating up to version $TIMESTAMPING_VERSION, but got $MINVERSION"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user