diff --git a/bin/git-undo b/bin/git-undo index f71ab31..d0d5d2d 100755 --- a/bin/git-undo +++ b/bin/git-undo @@ -3,7 +3,25 @@ back="^" case "$1" in - -h|--hard) + -h) + cat << EOL +This will erase any changes since your last commit. +If you want to get help info, run "git undo --help" instead. +Do you want to continue? [yN]" +EOL + read -r res + case "${res}" in + "Y" | "y") + test $2 -gt 1 > /dev/null 2>&1 && back="~$2" + git reset --hard HEAD$back + exit $? + ;; + * ) + exit 0 + ;; + esac + ;; + --hard) test $2 -gt 1 > /dev/null 2>&1 && back="~$2" git reset --hard HEAD$back && exit 0; ;; diff --git a/man/git-undo.1 b/man/git-undo.1 index 9000478..d38d9a7 100644 --- a/man/git-undo.1 +++ b/man/git-undo.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-UNDO" "1" "December 2015" "" "" +.TH "GIT\-UNDO" "1" "February 2018" "" "" . .SH "NAME" \fBgit\-undo\fR \- Remove latest commits @@ -22,7 +22,7 @@ This is the default, only rolls back the commit but changes remain un\-staged\. \-\-hard or \-h . .P -This option wipes your commit(s), so that your changes cannot be recovered\. Use with care\. +This option wipes your commit(s), so that your changes cannot be recovered\. Use with care\. To avoid being confused with \fB\-\-help\fR, there will be a confirmation when \fB\-h\fR is specified\. . .P diff --git a/man/git-undo.html b/man/git-undo.html index c26b5a7..887be11 100644 --- a/man/git-undo.html +++ b/man/git-undo.html @@ -90,7 +90,8 @@

--hard or -h

-

This option wipes your commit(s), so that your changes cannot be recovered. Use with care.

+

This option wipes your commit(s), so that your changes cannot be recovered. Use with care. + To avoid being confused with --help, there will be a confirmation when -h is specified.

<commitcount>

@@ -110,7 +111,7 @@

AUTHOR

-

Written by Kenneth Reitz <me@kennethreitz.com> and Nick Lombard <github@jigsoft.co.za>

+

Written by Kenneth Reitz <me@kennethreitz.com> and Nick Lombard <github@jigsoft.co.za>

REPORTING BUGS

@@ -123,7 +124,7 @@
  1. -
  2. December 2015
  3. +
  4. February 2018
  5. git-undo(1)
diff --git a/man/git-undo.md b/man/git-undo.md index 471f664..f101f39 100644 --- a/man/git-undo.md +++ b/man/git-undo.md @@ -18,6 +18,7 @@ git-undo(1) -- Remove latest commits --hard or -h This option wipes your commit(s), so that your changes cannot be recovered. Use with care. + To avoid being confused with `--help`, there will be a confirmation when `-h` is specified. <commitcount>