mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
Merge branch 'master' into next
* master: git-stash: fix flag parsing t/t3903-stash: improve testing of git-stash show
This commit is contained in:
15
git-stash.sh
15
git-stash.sh
@@ -264,8 +264,18 @@ parse_flags_and_rev()
|
||||
b_tree=
|
||||
i_tree=
|
||||
|
||||
# Work around rev-parse --flags eating -q
|
||||
for opt
|
||||
do
|
||||
case "$opt" in
|
||||
-q|--quiet)
|
||||
GIT_QUIET=t
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
REV=$(git rev-parse --no-flags --symbolic "$@" 2>/dev/null)
|
||||
FLAGS=$(git rev-parse --no-revs -- "$@" 2>/dev/null)
|
||||
FLAGS=$(git rev-parse --no-revs --flags "$@" 2>/dev/null)
|
||||
|
||||
set -- $FLAGS
|
||||
|
||||
@@ -273,9 +283,6 @@ parse_flags_and_rev()
|
||||
while test $# -ne 0
|
||||
do
|
||||
case "$1" in
|
||||
-q|--quiet)
|
||||
GIT_QUIET=-t
|
||||
;;
|
||||
--index)
|
||||
INDEX_OPTION=--index
|
||||
;;
|
||||
|
||||
@@ -416,8 +416,37 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
|
||||
echo bar >> file &&
|
||||
STASH_ID=$(git stash create) &&
|
||||
git reset --hard &&
|
||||
git stash show ${STASH_ID}
|
||||
cat >expected <<-EOF &&
|
||||
file | 1 +
|
||||
1 files changed, 1 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
git stash show ${STASH_ID} >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
|
||||
git stash clear &&
|
||||
test_when_finished "git reset --hard HEAD" &&
|
||||
git reset --hard &&
|
||||
echo foo >> file &&
|
||||
git stash &&
|
||||
test_when_finished "git stash drop" &&
|
||||
echo bar >> file &&
|
||||
STASH_ID=$(git stash create) &&
|
||||
git reset --hard &&
|
||||
cat >expected <<-EOF &&
|
||||
diff --git a/file b/file
|
||||
index 7601807..935fbd3 100644
|
||||
--- a/file
|
||||
+++ b/file
|
||||
@@ -1 +1,2 @@
|
||||
baz
|
||||
+bar
|
||||
EOF
|
||||
git stash show -p ${STASH_ID} >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'stash show - no stashes on stack, stash-like argument' '
|
||||
git stash clear &&
|
||||
test_when_finished "git reset --hard HEAD" &&
|
||||
@@ -425,7 +454,32 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
|
||||
echo foo >> file &&
|
||||
STASH_ID=$(git stash create) &&
|
||||
git reset --hard &&
|
||||
git stash show ${STASH_ID}
|
||||
cat >expected <<-EOF &&
|
||||
file | 1 +
|
||||
1 files changed, 1 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
git stash show ${STASH_ID} >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
|
||||
git stash clear &&
|
||||
test_when_finished "git reset --hard HEAD" &&
|
||||
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 -p ${STASH_ID} >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'stash drop - fail early if specified stash is not a stash reference' '
|
||||
|
||||
Reference in New Issue
Block a user