Skip to content

Commit 3e40695

Browse files
committed
Follow first parents when looking for the protocol bump
A date-ordered walk could stop on a PR branch commit and pick a later commit than the merge that introduced the protocol.
1 parent 402e141 commit 3e40695

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎scripts/check-overlay-min-version.sh‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# Usage: check-overlay-min-version.sh [--apply] <network-protocol>
1313
#
14-
# Finds the commit in HEAD's history that raised the ledger protocol version
14+
# Finds the commit in HEAD's first-parent history that raised the ledger protocol version
1515
# (MAX_SUPPORTED_PROTOCOL_VERSION in src/util/ProtocolVersion.h, or
1616
# Config::CURRENT_LEDGER_PROTOCOL_VERSION in src/main/Config.cpp in older
1717
# revisions) to <network-protocol>, and compares OVERLAY_PROTOCOL_MIN_VERSION in the
@@ -105,12 +105,14 @@ LEDGER_LOG_REGEX='(CURRENT_LEDGER|MAX_SUPPORTED)_PROTOCOL_VERSION[[:space:]]*=[[
105105
OVERLAY_EXPR='s/^[[:space:]]*OVERLAY_PROTOCOL_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p'
106106
MIN_EXPR='s/^[[:space:]]*OVERLAY_PROTOCOL_MIN_VERSION[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p'
107107

108-
# Print the oldest commit in HEAD's history from which the ledger protocol
109-
# version has been at least $NETWORK_LEDGER.
108+
# Print the oldest commit in HEAD's first-parent history from which the ledger
109+
# protocol version has been at least $NETWORK_LEDGER. Following first parents
110+
# finds the commit (usually a PR merge) where HEAD's branch got the protocol,
111+
# not one on a PR branch whose date may be out of order with the branch's.
110112
ledger_bump_commit()
111113
{
112114
FOUND=
113-
for C in $(git log --format=%H -G "$LEDGER_LOG_REGEX" HEAD -- "$CONFIG_CPP" "$PROTOCOL_H")
115+
for C in $(git log --first-parent --format=%H -G "$LEDGER_LOG_REGEX" HEAD -- "$CONFIG_CPP" "$PROTOCOL_H")
114116
do
115117
LEDGER=$(ledger_at "$C")
116118
if [ "$LEDGER" -lt "$NETWORK_LEDGER" ]

0 commit comments

Comments
 (0)