git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] git-merge: refactor option parsing

From
LHLars Hjemli <hjemli@gmail.com>
Date
Sep 22, 2007, 00:33 UTC
Message-ID
<1190421186-21784-3-git-send-email-hjemli@gmail.com>
In-Reply-To
<1190421186-21784-2-git-send-email-hjemli@gmail.com>

Move the option parsing into a separate function as preparation for reuse by the next commit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 git-merge.sh |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/git-merge.sh b/git-merge.sh
index 3a01db0..a3ef676 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -119,11 +119,7 @@ merge_name () {
 	fi
 }
 
-case "$#" in 0) usage ;; esac
-
-have_message=
-while case "$#" in 0) break ;; esac
-do
+parse_option () {
 	case "$1" in
 	-n|--n|--no|--no-|--no-s|--no-su|--no-sum|--no-summ|\
 		--no-summa|--no-summar|--no-summary)
@@ -166,9 +162,21 @@ do
 		have_message=t
 		;;
 	-*)	usage ;;
-	*)	break ;;
+	*)	return 1 ;;
 	esac
 	shift
+	args_left="$#"
+}
+
+case "$#" in 0) usage ;; esac
+
+have_message=
+while parse_option "$@"
+do
+	while test $args_left -lt $#
+	do
+		shift
+	done
 done
 
 if test -z "$show_diffstat"; then
-- 
1.5.3.2.82.g75c8d
Previous: Lars HjemliNext: Lars Hjemli
Message 3 of 14 in “per branch options for git-merge incl. --no-ff”
  1. 0/5 per branch options for git-merge incl. --no-ffLars Hjemli, Sep 22, 2007
  2. 1/5 Add test-script for git-merge porcelainLars Hjemli, Sep 22, 2007
  3. 2/5 git-merge: refactor option parsingLars Hjemli, Sep 22, 2007
  4. 3/5 git-merge: add support for branch.<name>.mergeoptionsLars Hjemli, Sep 22, 2007
  5. 4/5 git-merge: add support for --commitLars Hjemli, Sep 22, 2007
  6. 5/5 git-merge: add --ff and --no-ff optionsLars Hjemli, Sep 22, 2007
  7. Junio C HamanoSep 23, 2007
  8. Lars HjemliSep 23, 2007
  9. Junio C HamanoSep 23, 2007
  10. Lars HjemliSep 23, 2007
  11. Junio C HamanoSep 23, 2007
  12. Lars HjemliSep 23, 2007
  13. Junio C HamanoSep 23, 2007
  14. Lars HjemliSep 23, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.