stash push: avoid printing errors
[gitweb.git] / git-stash.sh
index 4c92ec931ff231aa7b10468914a34daa87cd117d..5e06f96da592e87ecf590cdd8e8d5c1ba2ccaed0 100755 (executable)
@@ -308,14 +308,16 @@ push_stash () {
        if test -z "$patch_mode"
        then
                test "$untracked" = "all" && CLEAN_X_OPTION=-x || CLEAN_X_OPTION=
-               if test -n "$untracked"
+               if test -n "$untracked" && test $# = 0
                then
                        git clean --force --quiet -d $CLEAN_X_OPTION -- "$@"
                fi
 
                if test $# != 0
                then
-                       git add -u -- "$@"
+                       test -z "$untracked" && UPDATE_OPTION="-u" || UPDATE_OPTION=
+                       test "$untracked" = "all" && FORCE_OPTION="--force" || FORCE_OPTION=
+                       git add $UPDATE_OPTION $FORCE_OPTION -- "$@"
                        git diff-index -p --cached --binary HEAD -- "$@" |
                        git apply --index -R
                else