[PATCH] make git-filter-branch use parse-options.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pierre Habouzit <madcoder@xxxxxxxxxx>
---
 git-filter-branch.sh |   93 +++++++++++++++++++++-----------------------------
 1 files changed, 39 insertions(+), 54 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 81392ad..8af3126 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -87,14 +87,26 @@ set_ident () {
 	echo "case \"\$GIT_${uid}_NAME\" in \"\") GIT_${uid}_NAME=\"\${GIT_${uid}_EMAIL%%@*}\" && export GIT_${uid}_NAME;; esac"
 }
 
-USAGE="[--env-filter <command>] [--tree-filter <command>] \
-[--index-filter <command>] [--parent-filter <command>] \
-[--msg-filter <command>] [--commit-filter <command>] \
-[--tag-name-filter <command>] [--subdirectory-filter <directory>] \
-[--original <namespace>] [-d <directory>] [-f | --force] \
-[<rev-list options>...]"
-
-OPTIONS_SPEC=
+OPTIONS_KEEPDASHDASH=
+OPTIONS_SPEC="\
+git filter-branch [options] [<rev-list options>...]
+--
+d=                      temporary path to use for rewriting
+f,force                 force filter-branch to run
+subdirectory-filter=    only look at the history touching that specific subdirectory
+original=               namespace where the original commits will be stored (default: refs/original)
+
+ Filters that you can run:
+
+env-filter=             environment filter to run
+tree-filter=            tree rewriting filter to run
+index-filter=           index rewriting filter to run
+parent-filter=          parent rewriting filter to run
+msg-filter=             commit message rewriting filter to run
+commit-filter=          commit rewriting filter to run
+tag-name-filter=        tag name rewriting filter to run
+"
+
 . git-sh-setup
 
 if [ "$(is_bare_repository)" = false ]; then
@@ -117,63 +129,36 @@ force=
 while :
 do
 	case "$1" in
-	--)
-		shift
-		break
-		;;
 	--force|-f)
-		shift
-		force=t
-		continue
-		;;
-	-*)
-		;;
-	*)
-		break;
-	esac
-
-	# all switches take one argument
-	ARG="$1"
-	case "$#" in 1) usage ;; esac
-	shift
-	OPTARG="$1"
-	shift
-
-	case "$ARG" in
+		force=t;;
 	-d)
-		tempdir="$OPTARG"
-		;;
+		tempdir="$2"; shift;;
+	--subdirectory-filter)
+		filter_subdir="$2"; shift;;
+	--original)
+		orig_namespace=$(expr "$2/" : '\(.*[^/]\)/*$')/
+		shift;;
+
 	--env-filter)
-		filter_env="$OPTARG"
-		;;
+		filter_env="$2"; shift;;
 	--tree-filter)
-		filter_tree="$OPTARG"
-		;;
+		filter_tree="$2"; shift;;
 	--index-filter)
-		filter_index="$OPTARG"
-		;;
+		filter_index="$2"; shift;;
 	--parent-filter)
-		filter_parent="$OPTARG"
-		;;
+		filter_parent="$2"; shift;;
 	--msg-filter)
-		filter_msg="$OPTARG"
-		;;
+		filter_msg="$2"; shift;;
 	--commit-filter)
-		filter_commit="$functions; $OPTARG"
-		;;
+		filter_commit="$functions; $2"; shift;;
 	--tag-name-filter)
-		filter_tag_name="$OPTARG"
-		;;
-	--subdirectory-filter)
-		filter_subdir="$OPTARG"
-		;;
-	--original)
-		orig_namespace=$(expr "$OPTARG/" : '\(.*[^/]\)/*$')/
-		;;
+		filter_tag_name="$2"; shift;;
+	--)
+		shift; break;;
 	*)
-		usage
-		;;
+		usage;;
 	esac
+	shift
 done
 
 case "$force" in
-- 
1.6.0.3.758.gc29b0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux