diff --git a/diff-sha.sh b/diff-sha.sh index 599ef9da160..3bda566e41c 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -220,7 +220,7 @@ else depth=$INPUT_FETCH_DEPTH max_depth=$INPUT_MAX_FETCH_DEPTH - while ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; do + for ((i=0; i&1) && exit_status=$? || exit_status=$? - if [[ $depth -gt $max_depth ]]; then - echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" - exit 1 + if git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then + break fi - - depth=$((depth + 300)) done + + if ((i >= max_depth)); then + echo "::error::Unable to locate a common ancestor between $TARGET_BRANCH and $CURRENT_SHA" + exit 1 + fi else echo "::debug::Not a shallow clone, skipping merge-base check." fi