Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --strip-trees-with-ids option #166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ltrzesniewski
Copy link

I was looking for a reliable way to strip a directory based on its path, and this is a quick solution I came up with (since you said in #79 the proper built-in way would be hard to implement).

This simply adds a --strip-trees-with-ids option, based on what --strip-blobs-with-ids does. You may prefer to merge both of these options into a single one, but I didn't want to break existing behavior.

Here's how it's supposed to be used:

git rev-list --all --objects | git cat-file --batch-check='%(objectname) %(objecttype) %(rest)' | grep -Pe '^\w+ tree path/to/the/directory/to/delete$' | cut -d' ' -f1 > ./to-delete.txt
java -jar bfg.jar --no-blob-protection --strip-trees-with-ids ./to-delete.txt

This is much more reliable than the solution in my previous comment here, since it only discards the subtrees, which means if any blob is also used in a different path you don't intent to delete, it won't be affected.

Please note that I absolutely don't know anything about Scala, and just hacked it together without really knowing what I was doing so please bear with me 😄

@jacquesknipper
Copy link

Would be very handy to have that option implemented 👍 :)
I'm facing the exact same problem: same blob used for multiple copied files I don't want to remove.
Do you plan to merge this MR?
Thanks!

Copy link

@jacquesknipper jacquesknipper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried with loads of projects and it's working pretty well, except that some of the commits are still referencing non existing files - but it's not a big deal and I'm not sure we can do something about it. It's just noise I would say.

Whoaa512 pushed a commit to Whoaa512/bfg-repo-cleaner that referenced this pull request Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants