[PATCH] stash: simplify parsing fixes

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jon Seymour
Date: Monday, September 27, 2010 - 8:32 am

This patch simplifies Brian's fix for the recent regression by:

* eliminating the extra loop
* eliminating use of git rev-parse for parsing flags
* making use of the for opt idiom for the retained loop
* eliminating the redundant -- case

The patch has been tested with the tests in current maint.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
 git-stash.sh |   28 +++++++---------------------
 1 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index 57f36ce..23a9ab5 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -264,36 +264,22 @@ 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 --flags "$@" 2>/dev/null)
-
-	set -- $FLAGS
 
 	FLAGS=
-	while test $# -ne 0
+	for opt
 	do
-		case "$1" in
+		case "$opt" in
+			-q|--quiet)
+				GIT_QUIET=-t
+			;;
 			--index)
 				INDEX_OPTION=--index
 			;;
-			--)
-				:
-			;;
-			*)
-				FLAGS="${FLAGS}${FLAGS:+ }$1"
+			-*)
+				FLAGS="${FLAGS}${FLAGS:+ }$opt"
 			;;
 		esac
-		shift
 	done
 
 	set -- $REV
-- 
1.7.3.2.g9027fa.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] t/t3903-stash: improve testing of git-stash show, Brandon Casey, (Fri Sep 24, 1:40 pm)
Re: [PATCH] t/t3903-stash: improve testing of git-stash show, Brian Gernhardt, (Fri Sep 24, 1:43 pm)
Re: [PATCH] t/t3903-stash: improve testing of git-stash show, Brian Gernhardt, (Fri Sep 24, 2:49 pm)
[PATCH] git-stash: fix flag parsing, Brian Gernhardt, (Fri Sep 24, 3:15 pm)
[PATCH] stash show: fix breakage in 1.7.3, Jon Seymour, (Fri Sep 24, 7:54 pm)
Re: [PATCH] git-stash: fix flag parsing, Jon Seymour, (Fri Sep 24, 7:58 pm)
[PATCH v1] stash show: fix breakage in 1.7.3, Jon Seymour, (Fri Sep 24, 8:32 pm)
Re: [PATCH v1] stash show: fix breakage in 1.7.3, Brian Gernhardt, (Fri Sep 24, 9:45 pm)
Re: [PATCH v1] stash show: fix breakage in 1.7.3, Jon Seymour, (Fri Sep 24, 11:19 pm)
Re: [PATCH v1] stash show: fix breakage in 1.7.3, Jon Seymour, (Sat Sep 25, 12:15 am)
Re: [PATCH] git-stash: fix flag parsing, Junio C Hamano, (Sun Sep 26, 9:36 pm)
[PATCH] stash: simplify parsing fixes, Jon Seymour, (Mon Sep 27, 8:32 am)
Re: [PATCH v1] stash show: fix breakage in 1.7.3, Jon Seymour, (Mon Sep 27, 8:38 am)