Skip to content

Conversation

@rafaelgieschke
Copy link
Contributor

#1010 added Blob.createFromStream() but no way to actually use the resulting Writestream.

This pull request adds Writstream#write, so you can create blobs like:

#!/usr/bin/env node

const Git = require("nodegit");

(async () => {
  const repo = await Git.Repository.init("test", 1);
  const stream = await Git.Blob.createFromStream(repo, "");
  const buffer = new Buffer("test\n");
  await stream.write(buffer, buffer.byteLength);
  const buffer2 = new Buffer("test2\n");
  await stream.write(buffer2, buffer2.byteLength);
  const oid = await Git.Blob.createFromstreamCommit(stream);
  console.log(oid);
})();

It does so by declaring a fake git_writestream_write function, matching the write function in struct writestream of libgit2 (https://github.com/libgit2/libgit2/blob/HEAD/include/git2/types.h#L430).

@johnhaley81
Copy link
Collaborator

@rafaelgieschke thanks again. Same as the #1254 with adding tests to ensure functionality.

@rafaelgieschke
Copy link
Contributor Author

Added a test.

implausible
implausible previously approved these changes Nov 28, 2017
@implausible
Copy link
Member

@rafaelgieschke Any chance you can fix the conflicts? I'd like toget this into the codebase.

@rafaelgieschke
Copy link
Contributor Author

@implausible Thanks for looking at this! I've rebased the PR onto the current master.

@zawata
Copy link
Contributor

zawata commented Nov 26, 2025

please rebase and reopen if still relevant

@zawata zawata closed this Nov 26, 2025
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.

4 participants