diff --git a/01-Setup.sh b/01-Setup.sh index 326eed0..6ec8a11 100755 --- a/01-Setup.sh +++ b/01-Setup.sh @@ -28,13 +28,28 @@ else if [ "$LOCAL" = "$REMOTE" ]; then echo "The repository is up to date." else - echo "Downloading update..." - git reset --hard && git pull --force > /dev/null 2>&1 - echo - echo "The script has been updated to the latest version." - read -n 1 -s -r -p "Press any key to exit, then run the script again." - echo - exit 0 + echo "Downloading updates..." + # Get a list of files that have changed remotely + UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE") + + if [ -n "$UPDATED_FILES" ]; then + echo "Files updated in the remote repository:" + echo "$UPDATED_FILES" + + # Reset only the files that were updated remotely (discard local changes to them) + echo "$UPDATED_FILES" | xargs git checkout -- + + # Pull the latest changes + git pull --ff-only + + echo + echo "The script has been updated to the latest version." + read -n 1 -s -r -p "Press any key to exit, then run the script again." + echo + exit 0 + else + echo "The repository is up to date." + fi fi fi diff --git a/02-PSBBN-Installer.sh b/02-PSBBN-Installer.sh index 18f4a36..077e5cc 100755 --- a/02-PSBBN-Installer.sh +++ b/02-PSBBN-Installer.sh @@ -39,13 +39,27 @@ else if [ "$LOCAL" = "$REMOTE" ]; then echo "The repository is up to date." | tee -a "${INSTALL_LOG}" else - echo "Downloading update..." - git reset --hard && git pull --force >> "${INSTALL_LOG}" 2>&1 - echo - echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}" - read -n 1 -s -r -p "Press any key to exit, then run the script again." - echo - exit 0 + echo "Downloading updates..." + # Get a list of files that have changed remotely + UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE") + + if [ -n "$UPDATED_FILES" ]; then + echo "Files updated in the remote repository:" | tee -a "${INSTALL_LOG}" + echo "$UPDATED_FILES" | tee -a "${INSTALL_LOG}" + + # Reset only the files that were updated remotely (discard local changes to them) + echo "$UPDATED_FILES" | xargs git checkout -- >> "${INSTALL_LOG}" 2>&1 + + # Pull the latest changes + git pull --ff-only >> "${INSTALL_LOG}" 2>&1 + + echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}" + read -n 1 -s -r -p "Press any key to exit, then run the script again." + echo + exit 0 + else + echo "The repository is up to date." | tee -a "${INSTALL_LOG}" + fi fi fi diff --git a/03-Game-Installer.sh b/03-Game-Installer.sh index bc706bf..4256187 100755 --- a/03-Game-Installer.sh +++ b/03-Game-Installer.sh @@ -64,13 +64,27 @@ else if [ "$LOCAL" = "$REMOTE" ]; then echo "The repository is up to date." | tee -a "${LOG_FILE}" else - echo "Downloading update..." - git reset --hard && git pull --force >> "${LOG_FILE}" 2>&1 - echo - echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}" - read -n 1 -s -r -p "Press any key to exit, set your custom game path if needed, and then run the script again." - echo - exit 0 + echo "Downloading updates..." + # Get a list of files that have changed remotely + UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE") + + if [ -n "$UPDATED_FILES" ]; then + echo "Files updated in the remote repository:" | tee -a "${LOG_FILE}" + echo "$UPDATED_FILES" | tee -a "${LOG_FILE}" + + # Reset only the files that were updated remotely (discard local changes to them) + echo "$UPDATED_FILES" | xargs git checkout -- >> "${LOG_FILE}" 2>&1 + + # Pull the latest changes + git pull --ff-only >> "${LOG_FILE}" 2>&1 + + echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}" + read -n 1 -s -r -p "Press any key to exit, set your custom game path if needed, and then run the script again." + echo + exit 0 + else + echo "The repository is up to date." | tee -a "${LOG_FILE}" + fi fi fi