Subject: Git filter branch - removing empty commits

From: Peter Waller <[email-masked]>
Date: Mon, 6 Oct 2008 07:57:22 -0700 (PDT)

Dear List,

I have removed lots of files from my history with a procedure something like
this:

1) Clone repository

2) git filter-branch --index-filter 'git rm --quiet -r Archive; git ls-files
-z '\''*.png'\'' '\''*.eps'\'' | xargs -0r git rm --quiet; true'

3) git reflog expire --expire=0 --all

4) git prune; git gc

The problem is that this leaves many empty commits.

The helpful people over at #git advised I do:

git filter-branch --commit-filter 'if [ z$1 = z`git rev-parse $3^{tree} 2>
/dev/null` ]; then skip_commit "$@"; else git commit-tree "$@"; fi'

But this gets to about commit 70/1300 and grinds to a halt. I modified
/usr/libexec/git-core/git-filter-branch to say #!/bin/sh -x, and the result
was over 80mb in a few seconds.

I have pasted the last few lines here:
http://rafb.net/p/ABWvCy44.html

It is like it is following some exponential behaviour and not getting
anywhere.

Any ideas what is wrong?

I have tried a couple of scripts I have found around that should do the same
thing, for example:

skip_commit()
{
        shift
        while [[ -n $1 ]] ; do
                shift
                map "$1"
                shift
        done
}

our_tree="$1"
our_parent_tree=$(map $3)

if [[ ${our_tree} == $(git rev-parse $(map $3)) ]]; then
        git commit-tree "$@"
else
        skip_commit "$@"
fi

This goes much faster, but when it reaches the final commit, it says this:
Ref 'refs/heads/master' was deleted
fatal: Not a valid object name HEAD

And not much useful seems to have happened.

Any help appreciated.

Regards,

- Peter
-- 
View this message in context: http://www.nabble.com/Git-filter-branch---removing-empty-commits-tp19839587p19839587.html
Sent from the git mailing list archive at Nabble.com.