summaryrefslogtreecommitdiff
path: root/t/t3905-stash-include-untracked.sh
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2018-03-19 23:21:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-03-20 16:08:34 (GMT)
commitd319bb18b1bd3e0b7269b44b9bae5db99dfbb7dd (patch)
tree34d339f61dff6d0b93f05c97410ccd84353a3e81 /t/t3905-stash-include-untracked.sh
parent833622a945a677ec690e5ffb05a637e425591f1d (diff)
downloadgit-d319bb18b1bd3e0b7269b44b9bae5db99dfbb7dd.zip
git-d319bb18b1bd3e0b7269b44b9bae5db99dfbb7dd.tar.gz
git-d319bb18b1bd3e0b7269b44b9bae5db99dfbb7dd.tar.bz2
stash push -u: don't create empty stash
When introducing the stash push feature, and thus allowing users to pass in a pathspec to limit the files that would get stashed in df6bba0937 ("stash: teach 'push' (and 'create_stash') to honor pathspec", 2017-02-28), this developer missed one place where the pathspec should be passed in. Namely in the call to the 'untracked_files()' function in the 'no_changes()' function. This resulted in 'git stash push -u -- <non-existant>' creating an empty stash when there are untracked files in the repository other that don't match the pathspec. As 'git stash' never creates empty stashes, this behaviour is wrong and confusing for users. Instead it should just show a message "No local changes to save", and not create a stash. Luckily the 'untracked_files()' function already correctly respects pathspecs that are passed to it, so the fix is simply to pass the pathspec along to the function. 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>
Diffstat (limited to 't/t3905-stash-include-untracked.sh')
-rwxr-xr-xt/t3905-stash-include-untracked.sh6
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index 2f90455..3ea5b9b 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -274,4 +274,10 @@ test_expect_success 'stash -u -- <ignored> leaves ignored file alone' '
test_path_is_file ignored.d/bar
'
+test_expect_success 'stash -u -- <non-existant> shows no changes when there are none' '
+ git stash push -u -- non-existant >actual &&
+ echo "No local changes to save" >expect &&
+ test_i18ncmp expect actual
+'
+
test_done