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

[RFC PATCH 2/3] filter-branch: optionally load existing mappings prior to filtering

From
Thomas Rast <trast@student.ethz.ch>
Date
Dec 31, 2010, 15:29 UTC
Message-ID
<f89203efcf1b2f49fb33097b3e7fc27e070626fb.1293809100.git.trast@student.ethz.ch>
In-Reply-To
<cover.1293809100.git.trast@student.ethz.ch>

In the previous commit filter-branch learned to dump its mappings. Introduce a --load-map option that lets it load map files in the same format.

This option does not accumulate; only the last one counts. Letting it accumulate would require two argument-parsing passes since we need to know the $tempdir before we can establish any maps.

Also, the maps add to all filtered maps. This is a bit of a tradeoff. As it stands, it could be useful to remap refs in another repository using the map file from elsewere. On the other hand, it does mean that it may rewrite more refs than the user intended.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 git-filter-branch.sh |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 020b076..9feeb26 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -127,6 +127,7 @@ force=
 prune_empty=
 remap_to_ancestor=
 dump_map=
+load_map=
 while :
 do
 	case "$1" in
@@ -205,6 +206,16 @@ do
 			;;
 		esac
 		;;
+	--load-map)
+		case "$OPTARG" in
+		/*)
+			load_map="$OPTARG"
+			;;
+		*)
+			load_map="$(pwd)/$OPTARG"
+			;;
+		esac
+		;;
 	*)
 		usage
 		;;
@@ -275,6 +286,14 @@ export GIT_INDEX_FILE
 # map old->new commit ids for rewriting parents
 mkdir ../map || die "Could not create map/ directory"
 
+if test -n "$load_map"
+then
+	while read pre post
+	do
+		echo $post > ../map/$pre
+	done < "$load_map"
+fi
+
 # we need "--" only if there are no path arguments in $@
 nonrevs=$(git rev-parse --no-revs "$@") || exit
 if test -z "$nonrevs"
-- 
1.7.4.rc0.240.g44e61
Previous: Johannes SixtNext: Johannes Sixt
Message 4 of 11 in “Submodule filtering for filter-branch”
  1. 0/3 Submodule filtering for filter-branchThomas Rast, Dec 31, 2010
  2. 1/3 filter-branch: optionally dump all mappings at the endThomas Rast, Dec 31, 2010
  3. Johannes SixtDec 31, 2010
  4. 2/3 filter-branch: optionally load existing mappings prior to filteringThomas Rast, Dec 31, 2010
  5. Johannes SixtDec 31, 2010
  6. 3/3 filter-branch: support --submodule-filterThomas Rast, Dec 31, 2010
  7. Johannes SixtDec 31, 2010
  8. Jeffrey Phillips FreemanJan 3, 2011
  9. Thomas RastJan 4, 2011
  10. Junio C HamanoJan 4, 2011
  11. Johannes SixtDec 31, 2010

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.