tag: use OPT_CMDMODE
[gitweb.git] / git-stash.sh
index 1e541a21257c70fa67c0fee552ccb05fc5b6a280..85c9e2c0817c171d67f7458a0764df8d31fb10ad 100755 (executable)
@@ -195,6 +195,7 @@ save_stash () {
        keep_index=
        patch_mode=
        untracked=
+       force=
        while test $# != 0
        do
                case "$1" in
@@ -215,6 +216,9 @@ save_stash () {
                -u|--include-untracked)
                        untracked=untracked
                        ;;
+               -f|--force)
+                       force=t
+                       ;;
                -a|--all)
                        untracked=all
                        ;;
@@ -258,6 +262,14 @@ save_stash () {
                say "$(gettext "No local changes to save")"
                exit 0
        fi
+       if test -z "$untracked$force" &&
+          test -n "$(git ls-files --killed | head -n 1)"
+       then
+               say "$(gettext "The following untracked files would NOT be saved but need to be removed by stash save:")"
+               test -n "$GIT_QUIET" || git ls-files --killed | sed 's/^/\t/'
+               say "$(gettext "Aborting. Consider using either the --force or --include-untracked option.")" >&2
+               exit 1
+       fi
        test -f "$GIT_DIR/logs/$ref_stash" ||
                clear_stash || die "$(gettext "Cannot initialize stash")"