From d0fac4ebfb13bbcced3b3c75cdea45f08a8a8215 Mon Sep 17 00:00:00 2001 From: raccoon Date: Sat, 25 Jul 2026 02:21:16 +0500 Subject: [PATCH] Updated shell scripts again --- repo-discard.cmd | 5 +++-- repo-discard.sh | 5 +++-- repo-reset.cmd | 13 +++++++++++-- repo-reset.sh | 10 +++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/repo-discard.cmd b/repo-discard.cmd index fd68ddf..162bf12 100644 --- a/repo-discard.cmd +++ b/repo-discard.cmd @@ -5,13 +5,14 @@ SETLOCAL CD "%~dp0" git rev-parse --is-inside-work-tree >NUL || GOTO die -ECHO The following files were changed and will be reverted: +ECHO. +ECHO *** WARNING: The following files were changed and will be reverted: git diff --name-only HEAD ECHO. CHOICE /M "Execute" IF %ERRORLEVEL% NEQ 1 ( - ECHO Aborting restore... + ECHO Aborting discard... ) ELSE ( git restore "%~dp0." || GOTO die ECHO Done. diff --git a/repo-discard.sh b/repo-discard.sh index a2b8cdb..cf32509 100755 --- a/repo-discard.sh +++ b/repo-discard.sh @@ -5,12 +5,13 @@ repository="$(dirname "$(readlink -f "$0")")/." cd "${repository}" git rev-parse --is-inside-work-tree >/dev/null -echo "The following files were changed and will be reverted:" +echo "" +echo "*** WARNING: The following files were changed and will be reverted:" git diff --name-only HEAD printf "\nExecute [Y,N]?"; read -r yn if [ "$yn" = "${yn#[Yy]}" ]; then - echo "Aborting restore..." + echo "Aborting discard..." else git restore "${repository}" echo "Done." diff --git a/repo-reset.cmd b/repo-reset.cmd index f072c84..a5b3b15 100644 --- a/repo-reset.cmd +++ b/repo-reset.cmd @@ -11,15 +11,24 @@ IF NOT DEFINED upstream ( GOTO die ) +git fetch --all || GOTO die + +ECHO. ECHO Going to reset current branch to: %upstream% -ECHO *** WARNING: All local changes and commits will be lost! + +ECHO. +ECHO *** WARNING: These local commits will be lost: +git log "%upstream%..HEAD" --oneline + +ECHO. +ECHO *** WARNING: These local files will be reset: +git diff "HEAD..%upstream%" --name-only ECHO. CHOICE /M "Execute" IF %ERRORLEVEL% NEQ 1 ( ECHO Aborting reset... ) ELSE ( - git fetch --all || GOTO die git reset --hard "%upstream%" || GOTO die ECHO Done. ) diff --git a/repo-reset.sh b/repo-reset.sh index 4339561..23beff4 100755 --- a/repo-reset.sh +++ b/repo-reset.sh @@ -9,8 +9,16 @@ if [ -z "$upstream" ]; then exit 1 fi +echo "" echo "Going to reset current branch to: ${upstream}" -echo "*** WARNING: All local changes and commits will be lost!" + +echo "" +echo "*** WARNING: These local commits will be lost:" +git log "${upstream}..HEAD" --oneline + +echo "" +echo "*** WARNING: These local files will be reset:" +git diff "HEAD..${upstream}" --name-only printf "\nExecute [Y,N]?"; read -r yn if [ "$yn" = "${yn#[Yy]}" ]; then