From 80710c666f48c78f65588c967b69ce008d7b799a Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 24 Jun 2021 17:23:01 +0200 Subject: [PATCH] [mod] utils/manage_static.sh: simplify git restore actions Signed-off-by: Markus Heiser --- utils/manage_static.sh | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/utils/manage_static.sh b/utils/manage_static.sh index f6eb1cae3..8f58b5dbf 100755 --- a/utils/manage_static.sh +++ b/utils/manage_static.sh @@ -105,31 +105,6 @@ static.build.commit() { ) } -static.git.restore.staged() { - local STAGED_FILES - STAGED_FILES=$(git diff --name-only --cached) - - for i in ${BUILT_PATHS[*]}; do - STAGED_FILES_FOR_I=$(echo "${STAGED_FILES}" | grep "^${i}") - if [ -n "${STAGED_FILES_FOR_I}" ]; then - # shellcheck disable=SC2086 - git restore --staged ${STAGED_FILES_FOR_I} - fi - done -} - -static.git.restore() { - static.git.restore.staged - - NOT_COMMITED_FILES="$(git diff --name-only)" - for i in ${BUILT_PATHS[*]}; do - NOT_COMMITED_FILES_FOR_I=$(echo "${NOT_COMMITED_FILES}" | grep "^${i}") - if [ -n "${NOT_COMMITED_FILES_FOR_I}" ]; then - # shellcheck disable=SC2086 - git restore ${NOT_COMMITED_FILES_FOR_I} - fi - done -} main() { case $1 in @@ -147,11 +122,11 @@ main() { # after "git add ." # remove the built files # so only the source are commited - static.git.restore.staged + git restore --staged "${BUILT_PATHS[@]}" ;; static.git.restore) # "git restore" of the built files. - static.git.restore + git restore --worktree --staged "${BUILT_PATHS[@]}" ;; esac }