commit:     d887c8af4c90e7237167fd09459b373fa0791fbd
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Fri Jul 18 19:06:02 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jul 22 22:29:35 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=d887c8af

phase-helpers.sh: don't repeatedly declare the _eapply_patch() function

Presently, the _eapply_patch() function is declared upon each occasion
that the eapply() function is called. Hoist it upwards so that it is
declared exactly once, once the targeted EAPI has been confirmed to
support eapply (meaning that it must be greater than 5).

See-also: 51ad398621e668920c46916c9a90768e27c2df62
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/phase-helpers.sh | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index a350d073a3..f01ef09467 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -981,34 +981,34 @@ if ___eapi_has_eapply; then
                patch() { gpatch "$@"; }
        fi
 
+       _eapply_patch() {
+               local prefix=$1 patch=$2 output IFS
+               shift 2
+
+               ebegin "${prefix:-Applying }${patch##*/}"
+               # -p1 as a sane default
+               # -f to avoid interactivity
+               # -g0 to guarantee no VCS interaction
+               # --no-backup-if-mismatch not to pollute the sources
+               set -- -p1 -f -g0 --no-backup-if-mismatch "$@"
+               if output=$(LC_ALL= LC_MESSAGES=C patch "$@" < "${patch}" 
2>&1); then
+                       # The patch was successfully applied. Maintain silence
+                       # unless applied with fuzz.
+                       if [[ ${output} == *[0-9]' with fuzz '[0-9]* ]]; then
+                               printf '%s\n' "${output}"
+                       fi
+                       eend 0
+               else
+                       printf '%s\n' "${output}" >&2
+                       eend 1
+                       __helpers_die "patch ${*@Q} failed with ${patch@Q}"
+               fi
+       }
+
        eapply() {
                local LC_ALL LC_COLLATE=C f i path
                local -a operands options
 
-               _eapply_patch() {
-                       local prefix=$1 patch=$2 output IFS
-                       shift 2
-
-                       ebegin "${prefix:-Applying }${patch##*/}"
-                       # -p1 as a sane default
-                       # -f to avoid interactivity
-                       # -g0 to guarantee no VCS interaction
-                       # --no-backup-if-mismatch not to pollute the sources
-                       set -- -p1 -f -g0 --no-backup-if-mismatch "$@"
-                       if output=$(LC_ALL= LC_MESSAGES=C patch "$@" < 
"${patch}" 2>&1); then
-                               # The patch was successfully applied. Maintain
-                               # silence unless applied with fuzz.
-                               if [[ ${output} == *[0-9]' with fuzz '[0-9]* 
]]; then
-                                       printf '%s\n' "${output}"
-                               fi
-                               eend 0
-                       else
-                               printf '%s\n' "${output}" >&2
-                               eend 1
-                               __helpers_die "patch ${*@Q} failed with 
${patch@Q}"
-                       fi
-               }
-
                while (( $# )); do
                        case $1 in
                                --)

Reply via email to