From a582a82d2444b627260a764c17d3137d9d255531 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Thu, 23 Feb 2017 02:27:35 -0600 Subject: filter-branch: fix --prune-empty on parentless commits Previously, the git_commit_non_empty_tree function would always pass any commit with no parents to git-commit-tree, regardless of whether the tree was nonempty. The new commit would then be recorded in the filter-branch revision map, and subsequent commits which leave the tree untouched would be correctly filtered. With this change, parentless commits with an empty tree are correctly pruned, and an empty file is recorded in the revision map, signifying that it was rewritten to "no commits." This works naturally with the parent mapping for subsequent commits. Signed-off-by: Devin J. Pohly Signed-off-by: Junio C Hamano --- git-filter-branch.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git-filter-branch.sh') diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 86b2ff1e07..2b8cdba157 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -46,6 +46,8 @@ git_commit_non_empty_tree() { if test $# = 3 && test "$1" = $(git rev-parse "$3^{tree}"); then map "$3" + elif test $# = 1 && test "$1" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904; then + : else git commit-tree "$@" fi -- cgit v1.2.3