stash push: avoid printing errors
commit833622a945a677ec690e5ffb05a637e425591f1d
authorThomas Gummerer <t.gummerer@gmail.com>
Mon, 19 Mar 2018 23:21:55 +0000 (19 23:21 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 20 Mar 2018 16:08:34 +0000 (20 09:08 -0700)
tree91657dc3955a10f1c2986bd7ef3e9a72a5ff8849
parentd97e4fa748071635bb7e861ef0c1e7900fcae7c8
stash push: avoid printing errors

'git stash push -u -- <pathspec>' prints the following errors if
<pathspec> only matches untracked files:

    fatal: pathspec 'untracked' did not match any files
    error: unrecognized input

This is because we first clean up the untracked files using 'git clean
<pathspec>', and then use a command chain involving 'git add -u
<pathspec>' and 'git apply' to clear the changes to files that are in
the index and were stashed.

As the <pathspec> only includes untracked files that were already
removed by 'git clean', the 'git add' call will barf, and so will 'git
apply', as there are no changes that need to be applied.

Fix this by avoiding the 'git clean' if a pathspec is given, and use the
pipeline that's used for pathspec mode to get rid of the untracked files
as well.

Reported-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-stash.sh
t/t3905-stash-include-untracked.sh