[kernel] r22653 - people/benh

Ben Hutchings benh at moszumanska.debian.org
Sun May 17 18:38:36 UTC 2015


Author: benh
Date: Sun May 17 18:38:36 2015
New Revision: 22653

Log:
Reorganise option parsing into while/case statements

Modified:
   people/benh/git-format-patch-for-debian

Modified: people/benh/git-format-patch-for-debian
==============================================================================
--- people/benh/git-format-patch-for-debian	Sun May 17 00:57:43 2015	(r22652)
+++ people/benh/git-format-patch-for-debian	Sun May 17 18:38:36 2015	(r22653)
@@ -1,6 +1,6 @@
-#!/bin/sh
+#!/bin/bash
 
-# Copyright 2010,2012,2013 Ben Hutchings
+# Copyright 2010,2012,2013,2015 Ben Hutchings
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -18,34 +18,46 @@
 
 set -e
 
-if [ "x$1" = x--url ]; then
-    case "$2" in
-	http*/gitweb\?p=* | */\?p=*)
-	    export GIT_URL_BASE="$2;a=commit;h="
-	    ;;
-	http*/cgit/*)
-	    export GIT_URL_BASE="$2/commit?id="
-	    ;;
-	https://github.com/*)
-	    export GIT_URL_BASE="$2/commit/"
-	    ;;
-	http://sourceforge.net/p/*)
-	    export GIT_URL_BASE="$2/ci/"
-	    ;;
-	http://git.infradead.org/*.git)
-	    # Ugh. This is gitweb but the URL structure is different.
-	    export GIT_URL_BASE="$2/commit/"
+unset GIT_URL_BASE
+
+while [ $# -ge 1 ]; do
+    case "$1" in
+	--url)
+	    case "$2" in
+		http*/gitweb\?p=* | */\?p=*)
+		    export GIT_URL_BASE="$2;a=commit;h="
+		    ;;
+		http*/cgit/*)
+		    export GIT_URL_BASE="$2/commit?id="
+		    ;;
+		https://github.com/*)
+		    export GIT_URL_BASE="$2/commit/"
+		    ;;
+		http://sourceforge.net/p/*)
+		    export GIT_URL_BASE="$2/ci/"
+		    ;;
+		http://git.infradead.org/*.git)
+		    # Ugh. This is gitweb but the URL structure is different.
+		    export GIT_URL_BASE="$2/commit/"
+		    ;;
+		*)
+		    echo >&2 "E: URL '$2' not recognised as gitweb, cgit, github or sourceforge"
+		    exit 2
+		    ;;
+	    esac
+	    shift 2
+	    ;;
+	--local)
+	    export GIT_URL_BASE=
+	    shift 1
 	    ;;
 	*)
-	    echo >&2 "E: URL '$2' not recognised as gitweb, cgit, github or sourceforge"
-	    exit 2
+	    break
 	    ;;
     esac
-    shift 2
-elif [ "x$1" = x--local ]; then
-    export GIT_URL_BASE=
-    shift 1
-else
+done
+
+if [ ! -v GIT_URL_BASE ]; then
     echo >&2 "I: Assuming this patch is in Linus's tree."
     echo >&2 "I: If not, use the --url option to specify the git web URL."
     export GIT_URL_BASE=https://git.kernel.org/linus/



More information about the Kernel-svn-changes mailing list