Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Hashing and writing arbitrary blobs into a repo #1483

Copy link
Copy link
Open
@runxiyu

Description

@runxiyu
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.