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

Blob ID in commit-callback cannot be used to get file contents #597

Open
rzuckerm opened this issue Sep 5, 2024 · 1 comment
Open

Blob ID in commit-callback cannot be used to get file contents #597

rzuckerm opened this issue Sep 5, 2024 · 1 comment

Comments

@rzuckerm
Copy link

rzuckerm commented Sep 5, 2024

I'm using the latest version of git-filter-repo, 2.45.0. My git version is 2.34.1.

I'm trying to write a commit-callback that modifies a single file. I'm basing this callback on this example. However, instead of a object ID, I'm getting an integer that I cannot use with git cat-file --batch. What I really need is the object ID.

I ended up just using the blob-callback and making sure that the blob I'm processing has a very specific prefix that is unique to that file before making changes to it.

I saw this issue, #549 , and if I had that, I'd use it instead.

@rzuckerm
Copy link
Author

I have a workaround. I created a blob_callback that creates a dict where the key is the blob ID and the value is the object ID:

import git_filter_repo as fr

BLOB_IDS = {}

def blob_callback(blob: fr.Blob, _metadata):
    BLOB_IDS[blob.id] = blob.original_id

I can use that dict to convert the blob ID I get from the commit callback into an object ID that I can pass to git cat-file to get the contents.

While this works, it would be nice if the original_id where part of the blob information passed in files_changed, or if there were a way to access the blob to get its contents. That would remove the need for git cat-file.

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

No branches or pull requests

1 participant