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 <brian@gernhardtsoftware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brian Gernhardt committed
Sep 24, 2010 at 18:15 UTC
9027fa9eb7df606b6658dd48a40bb993ce222ddd
2 files changed
+15
-8
git-stash.sh
+11
-4
@@ -264,8 +264,18 @@ parse_flags_and_rev()
264
b_tree=
265
i_tree=
266
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
+
277
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)
279
280
set -- $FLAGS
281
@@ -273,9 +283,6 @@ parse_flags_and_rev()
283
while test $# -ne 0
284
do
285
case "$1" in
276
- -q|--quiet)
277
- GIT_QUIET=-t
278
- ;;
286
--index)
287
INDEX_OPTION=--index
288
;;
t/t3903-stash.sh
+4
-4
@@ -406,7 +406,7 @@ test_expect_success 'stash branch - stashes on stack, stash-like argument' '
406
test $(git ls-files --modified | wc -l) -eq 1
407
'
408
409
-test_expect_failure 'stash show - stashes on stack, stash-like argument' '
409
+test_expect_success 'stash show - stashes on stack, stash-like argument' '
410
git stash clear &&
411
test_when_finished "git reset --hard HEAD" &&
412
git reset --hard &&
@@ -424,7 +424,7 @@ test_expect_failure 'stash show - stashes on stack, stash-like argument' '
424
test_cmp expected actual
425
'
426
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' '
428
git stash clear &&
429
test_when_finished "git reset --hard HEAD" &&
430
git reset --hard &&
@@ -447,7 +447,7 @@ test_expect_failure 'stash show -p - stashes on stack, stash-like argument' '
447
test_cmp expected actual
448
'
449
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' '
451
git stash clear &&
452
test_when_finished "git reset --hard HEAD" &&
453
git reset --hard &&
@@ -462,7 +462,7 @@ test_expect_failure 'stash show - no stashes on stack, stash-like argument' '
462
test_cmp expected actual
463
'
464
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' '
466
git stash clear &&
467
test_when_finished "git reset --hard HEAD" &&
468
git reset --hard &&