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

[PATCH v2] filter-branch: skip commits present on --state-branch

From
MBMichael Barabanov <michael.barabanov@gmail.com>
Date
Jun 26, 2018, 04:07 UTC
Message-ID
<20180626040733.30757-1-michael.barabanov@gmail.com>
In-Reply-To
<20180623043639.7727-1-michael.barabanov@gmail.com>

The commits in state:filter.map have already been processed, so don't filter them again. This makes incremental git filter-branch much faster.

Also add tests for --state-branch option.
Signed-off-by: Michael Barabanov <michael.barabanov@gmail.com>
---
 git-filter-branch.sh     |  1 +
 t/t7003-filter-branch.sh | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ccceaf19a..5c5afa2b9 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -372,6 +372,7 @@ while read commit parents; do
 	git_filter_branch__commit_count=$(($git_filter_branch__commit_count+1))
 
 	report_progress
+	test -f "$workdir"/../map/$commit && continue
 
 	case "$filter_subdir" in
 	"")
diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
index ec4b160dd..e23de7d0b 100755
--- a/t/t7003-filter-branch.sh
+++ b/t/t7003-filter-branch.sh
@@ -107,6 +107,21 @@ test_expect_success 'test that the directory was renamed' '
 	test dir/D = "$(cat diroh/D.t)"
 '
 
+V=$(git rev-parse HEAD)
+
+test_expect_success 'populate --state-branch' '
+	git filter-branch --state-branch state -f --tree-filter "touch file || :" HEAD
+'
+
+W=$(git rev-parse HEAD)
+
+test_expect_success 'using --state-branch to skip already rewritten commits' '
+	test_when_finished git reset --hard $V &&
+	git reset --hard $V &&
+	git filter-branch --state-branch state -f --tree-filter "touch file || :" HEAD &&
+	test_cmp_rev $W HEAD
+'
+
 git tag oldD HEAD~4
 test_expect_success 'rewrite one branch, keeping a side branch' '
 	git branch modD oldD &&
-- 
2.18.0
Previous: Junio C HamanoNext: Ian Campbell
Message 3 of 5 in “filter-branch: skip commits present on --state-branch”
  1. filter-branch: skip commits present on --state-branchMichael Barabanov, Jun 23, 2018
  2. Junio C HamanoJun 25, 2018
  3. filter-branch: skip commits present on --state-branchMichael Barabanov, Jun 26, 2018
  4. Ian CampbellJun 26, 2018
  5. Junio C HamanoJun 26, 2018

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.