8000 Hashing and writing arbitrary blobs into a repo · Issue #1483 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content
Hashing and writing arbitrary blobs into a repo #1483
Closed
@runxiyu

Description

@runxiyu

I thought this would be a relatively simple question since in upstream Git it's just git hash-object -w -t blob --stdin, but I can't seem to find the proper documentation to do this.

Given an arbitrary blob expressed as an io.Reader or a []byte, how can I store it into a repo, returning its hash?

The Storer interface does not seem to provide for this.


X-Y problem background: I'm writing a Git-based forge. I need a function that accepts an email patch and applies it on a newly created branch based on the HEAD of an on-disk bare repository. I already have functions that can parse the email patch and apply each file to a given source file. My current thought is to make a copy of the tree object of HEAD, iterate through the patch, taking source files from the tree as necessary then patching it then hash-object'ing the resulting blob into the repo, then editing the tree object to point towards these new blobs and ultimately committing the modified tree object on a new branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0