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

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

From
Pierre Habouzit <madcoder@debian.org>
Date
Oct 30, 2008, 16:18 UTC
Message-ID
<1225383538-23666-2-git-send-email-madcoder@debian.org>
In-Reply-To
<1225383538-23666-1-git-send-email-madcoder@debian.org>
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---
 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
Previous: Pierre HabouzitNext: Pierre Habouzit
Message 8 of 25 in “git-filter-branch: Add an example on how to remove empty commits”
  1. git-filter-branch: Add an example on how to remove empty commitsPetr Baudis, Oct 30, 2008
  2. Sam VilainOct 30, 2008
  3. Johannes SchindelinOct 30, 2008
  4. Pierre HabouzitOct 30, 2008
  5. Deskin MillerOct 30, 2008
  6. Pierre HabouzitOct 30, 2008
  7. filter-branch enhancementsPierre Habouzit, Oct 30, 2008
  8. make git-filter-branch use parse-options.Pierre Habouzit, Oct 30, 2008
  9. implement --prune-empty switch for filter-branchPierre Habouzit, Oct 30, 2008
  10. Pierre HabouzitOct 31, 2008
  11. filter-branch: add git_commit_non_empty_tree and --prune-empty.Pierre Habouzit, Oct 31, 2008
  12. Johannes SchindelinOct 31, 2008
  13. Pierre HabouzitOct 31, 2008
  14. Junio C HamanoNov 3, 2008
  15. Pierre HabouzitNov 3, 2008
  16. Pierre HabouzitNov 3, 2008
  17. Jay SoffianJan 9, 2009
  18. Pierre HabouzitJan 11, 2009
  19. Johannes SchindelinJan 11, 2009
  20. Pierre HabouzitJan 11, 2009
  21. Sverre RabbelierJan 11, 2009
  22. Pierre HabouzitJan 11, 2009
  23. Sverre RabbelierJan 11, 2009
  24. Junio C HamanoJan 11, 2009
  25. Johannes SchindelinJan 11, 2009

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.