Merge branch 'tg/stash-untracked-with-pathspec-fix'
"git stash push -u -- <pathspec>" gave an unnecessary and confusing error message when there was no tracked files that match the <pathspec>, which has been fixed. * tg/stash-untracked-with-pathspec-fix: stash: drop superfluos pathspec parameter stash push -u: don't create empty stash stash push: avoid printing errors stash: fix nonsense pipeline
This commit is contained in:
commit
cbf0339439
14
git-stash.sh
14
git-stash.sh
@ -39,7 +39,7 @@ fi
|
||||
no_changes () {
|
||||
git diff-index --quiet --cached HEAD --ignore-submodules -- "$@" &&
|
||||
git diff-files --quiet --ignore-submodules -- "$@" &&
|
||||
(test -z "$untracked" || test -z "$(untracked_files)")
|
||||
(test -z "$untracked" || test -z "$(untracked_files "$@")")
|
||||
}
|
||||
|
||||
untracked_files () {
|
||||
@ -315,16 +315,18 @@ 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 -- "$@"
|
||||
git clean --force --quiet -d $CLEAN_X_OPTION
|
||||
fi
|
||||
|
||||
if test $# != 0
|
||||
then
|
||||
git add -u -- "$@" |
|
||||
git checkout-index -z --force --stdin
|
||||
git diff-index -p --cached --binary HEAD -- "$@" | git apply --index -R
|
||||
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
|
||||
git reset --hard -q
|
||||
fi
|
||||
|
@ -228,4 +228,56 @@ test_expect_success 'stash previously ignored file' '
|
||||
test_path_is_file ignored.d/foo
|
||||
'
|
||||
|
||||
test_expect_success 'stash -u -- <untracked> doesnt print error' '
|
||||
>untracked &&
|
||||
git stash push -u -- untracked 2>actual &&
|
||||
test_path_is_missing untracked &&
|
||||
test_line_count = 0 actual
|
||||
'
|
||||
|
||||
test_expect_success 'stash -u -- <untracked> leaves rest of working tree in place' '
|
||||
>tracked &&
|
||||
git add tracked &&
|
||||
>untracked &&
|
||||
git stash push -u -- untracked &&
|
||||
test_path_is_missing untracked &&
|
||||
test_path_is_file tracked
|
||||
'
|
||||
|
||||
test_expect_success 'stash -u -- <tracked> <untracked> clears changes in both' '
|
||||
>tracked &&
|
||||
git add tracked &&
|
||||
>untracked &&
|
||||
git stash push -u -- tracked untracked &&
|
||||
test_path_is_missing tracked &&
|
||||
test_path_is_missing untracked
|
||||
'
|
||||
|
||||
test_expect_success 'stash --all -- <ignored> stashes ignored file' '
|
||||
>ignored.d/bar &&
|
||||
git stash push --all -- ignored.d/bar &&
|
||||
test_path_is_missing ignored.d/bar
|
||||
'
|
||||
|
||||
test_expect_success 'stash --all -- <tracked> <ignored> clears changes in both' '
|
||||
>tracked &&
|
||||
git add tracked &&
|
||||
>ignored.d/bar &&
|
||||
git stash push --all -- tracked ignored.d/bar &&
|
||||
test_path_is_missing tracked &&
|
||||
test_path_is_missing ignored.d/bar
|
||||
'
|
||||
|
||||
test_expect_success 'stash -u -- <ignored> leaves ignored file alone' '
|
||||
>ignored.d/bar &&
|
||||
git stash push -u -- ignored.d/bar &&
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user