record only commit from earlier cherry pick without -x
* applied patch from Alexey for closes #39704
* reviewed checks at start of function to match Delphi in rangecheck errors and other exits
* test for the above.
(cherry picked from commit 533cd8292234c3ee350b3e9fe147b579b38fedd9)