diff options
Diffstat (limited to 't/t3903-stash.sh')
-rwxr-xr-x | t/t3903-stash.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index f0a82be9de..686747e55a 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -10,6 +10,25 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh +test_expect_success 'usage on cmd and subcommand invalid option' ' + test_expect_code 129 git stash --invalid-option 2>usage && + grep "or: git stash" usage && + + test_expect_code 129 git stash push --invalid-option 2>usage && + ! grep "or: git stash" usage +' + +test_expect_success 'usage on main command -h emits a summary of subcommands' ' + test_expect_code 129 git stash -h >usage && + grep -F "usage: git stash list" usage && + grep -F "or: git stash show" usage +' + +test_expect_failure 'usage for subcommands should emit subcommand usage' ' + test_expect_code 129 git stash push -h >usage && + grep -F "usage: git stash [push" usage +' + diff_cmp () { for i in "$1" "$2" do @@ -288,6 +307,17 @@ test_expect_success 'stash --no-keep-index' ' test bar,bar2 = $(cat file),$(cat file2) ' +test_expect_success 'stash --staged' ' + echo bar3 >file && + echo bar4 >file2 && + git add file2 && + git stash --staged && + test bar3,bar2 = $(cat file),$(cat file2) && + git reset --hard && + git stash pop && + test bar,bar4 = $(cat file),$(cat file2) +' + test_expect_success 'dont assume push with non-option args' ' test_must_fail git stash -q drop 2>err && test_i18ngrep -e "subcommand wasn'\''t specified; '\''push'\'' can'\''t be assumed due to unexpected token '\''drop'\''" err @@ -1365,4 +1395,28 @@ test_expect_success 'git stash can pop directory -> file saved changes' ' ) ' +test_expect_success 'restore untracked files even when we hit conflicts' ' + git init restore_untracked_after_conflict && + ( + cd restore_untracked_after_conflict && + + echo hi >a && + echo there >b && + git add . && + git commit -m first && + echo hello >a && + echo something >c && + + git stash push --include-untracked && + + echo conflict >a && + git add a && + git commit -m second && + + test_must_fail git stash pop && + + test_path_is_file c + ) +' + test_done |