Re: git-filter-branch behavior

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

 



Hello,

David Neu wrote:

> Running
> 
> git-filter-branch --tree-filter 'rm -rf subdir/' -- --all
> 
> as shown below seems to leave empty commits
> corresponding to subdir/ in the tree.  Is this the expected
> behavior?  If so is there a command to remove the empty
> commits?

The following is probably overkill, but it is what I would do.
It's completely untested.  If you'd prefer to do things by hand
instead, my only advice is that using grafts with filter-branch
might be easier than rebase -i.

-- snipsnip --
# prune-empty-commits - filter-branch filter to avoid boring commits
#
# Usage: git-filter-branch --tree-filter <something> \
# 		--commit-filter 'prune-empty-commits "$@"' -- <refs>
# Public domain.

interesting=

test "$#" -eq 1 && interesting=t

committree=$1
shift

for sha1 in "$@"
do
	test z"$sha1" = z-p && continue
	map "$sha1" | while read parent
	do
		parenttree=$(git log -1 --pretty=format:%T "$parent")
		test "$committree" != "$parenttree" &&
			interesting=t
		test -n "$interesting" && break
	done
	test "-n interesting" && break
done

test -n "$interesting" && git commit-tree "$@" || skip_commit "$@"
--
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