git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Git filter branch - removing empty commits
@ 2008-10-06 14:57 Peter Waller
  0 siblings, 0 replies; only message in thread
From: Peter Waller @ 2008-10-06 14:57 UTC (permalink / raw)
  To: git


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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-06 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-06 14:57 Git filter branch - removing empty commits Peter Waller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).