Now that we have 'git checkout --no-overlay', we can use it in git
stash, making the codepaths for 'git stash push' with and without
pathspec more similar, and thus easier to follow.

Signed-off-by: Thomas Gummerer <t.gumme...@gmail.com>
---

As mentioned in the cover letter, not sure if we want to apply this
now.  There are two reasons I did this:
- Showing the new functionality of git checkout
- Increased test coverage, as we are running the new code with all git
  stash tests for free, which helped look at some cases that I was
  missing initially.

 git-stash.sh | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index 94793c1a91..67be04d996 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -314,19 +314,15 @@ push_stash () {
 
        if test -z "$patch_mode"
        then
-               test "$untracked" = "all" && CLEAN_X_OPTION=-x || 
CLEAN_X_OPTION=
-               if test -n "$untracked" && test $# = 0
+               test "$untracked" = "all" && CLEAN_X_OPTION=-X || 
CLEAN_X_OPTION=
+               if test -n "$untracked"
                then
-                       git clean --force --quiet -d $CLEAN_X_OPTION
+                       git clean --force --quiet -d $CLEAN_X_OPTION -- "$@"
                fi
 
                if test $# != 0
                then
-                       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
+                       git checkout --quiet --no-overlay --ignore-unmatched 
HEAD -- "$@"
                else
                        git reset --hard -q
                fi
-- 
2.20.0.405.gbc1bbc6f85

Reply via email to