Merge branch 'rs/avoid-overflow-in-midpoint-computation' into maint
[gitweb.git] / t / t3903-stash.sh
index 78d50bcf1e17362b0d7051f4f7b5c3b4d182aedd..b22e671608119d37dd73bf6b0df41ce62e1a26f9 100755 (executable)
@@ -612,7 +612,25 @@ test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
        test_cmp expected actual
 '
 
-test_expect_success 'stash drop - fail early if specified stash is not a stash reference' '
+test_expect_success 'stash show --patience shows diff' '
+       git reset --hard &&
+       echo foo >>file &&
+       STASH_ID=$(git stash create) &&
+       git reset --hard &&
+       cat >expected <<-EOF &&
+       diff --git a/file b/file
+       index 7601807..71b52c4 100644
+       --- a/file
+       +++ b/file
+       @@ -1 +1,2 @@
+        baz
+       +foo
+       EOF
+       git stash show --patience ${STASH_ID} >actual &&
+       test_cmp expected actual
+'
+
+test_expect_success 'drop: fail early if specified stash is not a stash ref' '
        git stash clear &&
        test_when_finished "git reset --hard HEAD && git stash clear" &&
        git reset --hard &&
@@ -626,7 +644,7 @@ test_expect_success 'stash drop - fail early if specified stash is not a stash r
        git reset --hard HEAD
 '
 
-test_expect_success 'stash pop - fail early if specified stash is not a stash reference' '
+test_expect_success 'pop: fail early if specified stash is not a stash ref' '
        git stash clear &&
        test_when_finished "git reset --hard HEAD && git stash clear" &&
        git reset --hard &&
@@ -690,7 +708,25 @@ test_expect_success 'invalid ref of the form "n", n >= N' '
        git stash drop
 '
 
-test_expect_success 'stash branch should not drop the stash if the branch exists' '
+test_expect_success 'valid ref of the form "n", n < N' '
+       git stash clear &&
+       echo bar5 >file &&
+       echo bar6 >file2 &&
+       git add file2 &&
+       git stash &&
+       git stash show 0 &&
+       git stash branch tmp 0 &&
+       git checkout master &&
+       git stash &&
+       git stash apply 0 &&
+       git reset --hard &&
+       git stash pop 0 &&
+       git stash &&
+       git stash drop 0 &&
+       test_must_fail git stash drop
+'
+
+test_expect_success 'branch: do not drop the stash if the branch exists' '
        git stash clear &&
        echo foo >file &&
        git add file &&
@@ -701,7 +737,7 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
        git rev-parse stash@{0} --
 '
 
-test_expect_success 'stash branch should not drop the stash if the apply fails' '
+test_expect_success 'branch: should not drop the stash if the apply fails' '
        git stash clear &&
        git reset HEAD~1 --hard &&
        echo foo >file &&
@@ -715,7 +751,7 @@ test_expect_success 'stash branch should not drop the stash if the apply fails'
        git rev-parse stash@{0} --
 '
 
-test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
+test_expect_success 'apply: show same status as git status (relative to ./)' '
        git stash clear &&
        echo 1 >subdir/subfile1 &&
        echo 2 >subdir/subfile2 &&
@@ -1056,7 +1092,7 @@ test_expect_success 'stash push -p with pathspec shows no changes only once' '
        test_i18ncmp expect actual
 '
 
-test_expect_success 'stash push with pathspec shows no changes when there are none' '
+test_expect_success 'push <pathspec>: show no changes when there are none' '
        >foo &&
        git add foo &&
        git commit -m "tmp" &&
@@ -1066,12 +1102,35 @@ test_expect_success 'stash push with pathspec shows no changes when there are no
        test_i18ncmp expect actual
 '
 
-test_expect_success 'stash push with pathspec not in the repository errors out' '
+test_expect_success 'push: <pathspec> not in the repository errors out' '
        >untracked &&
        test_must_fail git stash push untracked &&
        test_path_is_file untracked
 '
 
+test_expect_success 'push: -q is quiet with changes' '
+       >foo &&
+       git add foo &&
+       git stash push -q >output 2>&1 &&
+       test_must_be_empty output
+'
+
+test_expect_success 'push: -q is quiet with no changes' '
+       git stash push -q >output 2>&1 &&
+       test_must_be_empty output
+'
+
+test_expect_success 'push: -q is quiet even if there is no initial commit' '
+       git init foo_dir &&
+       test_when_finished rm -rf foo_dir &&
+       (
+               cd foo_dir &&
+               >bar &&
+               test_must_fail git stash push -q >output 2>&1 &&
+               test_must_be_empty output
+       )
+'
+
 test_expect_success 'untracked files are left in place when -u is not given' '
        >file &&
        git add file &&