Skip to content

Commit 9027fa9

Browse files
Benabikgitster
authored andcommitted
git-stash: fix flag parsing
Currently git-stash uses `git rev-parse --no-revs -- "$@"` to set its FLAGS variable. This is the same as `FLAGS="-- $@"`. It should use `git rev-parse --no-revs --flags "$@"`, but that eats any "-q" or "--quiet" argument. So move the check for quiet before rev-parse. Signed-off-by: Brian Gernhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3fcb887 commit 9027fa9

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

git-stash.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,25 @@ parse_flags_and_rev()
264264
b_tree=
265265
i_tree=
266266

267+
# Work around rev-parse --flags eating -q
268+
for opt
269+
do
270+
case "$opt" in
271+
-q|--quiet)
272+
GIT_QUIET=t
273+
;;
274+
esac
275+
done
276+
267277
REV=$(git rev-parse --no-flags --symbolic "$@" 2>/dev/null)
268-
FLAGS=$(git rev-parse --no-revs -- "$@" 2>/dev/null)
278+
FLAGS=$(git rev-parse --no-revs --flags "$@" 2>/dev/null)
269279

270280
set -- $FLAGS
271281

272282
FLAGS=
273283
while test $# -ne 0
274284
do
275285
case "$1" in
276-
-q|--quiet)
277-
GIT_QUIET=-t
278-
;;
279286
--index)
280287
INDEX_OPTION=--index
281288
;;

t/t3903-stash.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
406406
test $(git ls-files --modified | wc -l) -eq 1
407407
'
408408

409-
test_expect_failure 'stash show - stashes on stack, stash-like argument' '
409+
test_expect_success 'stash show - stashes on stack, stash-like argument' '
410410
git stash clear &&
411411
test_when_finished "git reset --hard HEAD" &&
412412
git reset --hard &&
@@ -424,7 +424,7 @@ test_expect_failure 'stash show - stashes on stack, stash-like argument' '
424424
test_cmp expected actual
425425
'
426426

427-
test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '
427+
test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
428428
git stash clear &&
429429
test_when_finished "git reset --hard HEAD" &&
430430
git reset --hard &&
@@ -447,7 +447,7 @@ test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '
447447
test_cmp expected actual
448448
'
449449

450-
test_expect_failure 'stash show - no stashes on stack, stash-like argument' '
450+
test_expect_success 'stash show - no stashes on stack, stash-like argument' '
451451
git stash clear &&
452452
test_when_finished "git reset --hard HEAD" &&
453453
git reset --hard &&
@@ -462,7 +462,7 @@ test_expect_failure 'stash show - no stashes on stack, stash-like argument' '
462462
test_cmp expected actual
463463
'
464464

465-
test_expect_failure 'stash show -p - no stashes on stack, stash-like argument' '
465+
test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
466466
git stash clear &&
467467
test_when_finished "git reset --hard HEAD" &&
468468
git reset --hard &&

0 commit comments

Comments
 (0)