From 602f415a5fe769b786efb2abd03a480661b6e0c4 Mon Sep 17 00:00:00 2001 From: Kristian Lein-Mathisen Date: Sun, 13 Jun 2021 22:56:18 +0200 Subject: [PATCH 1/3] Fix mismatched blob-create-frombuffer signature Before this patch, the new test case would produce an error like this: Error: bad argument count - received 2 but expected 3: # --- git.scm | 2 +- libgit2.scm | 2 +- tests/run.scm | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/git.scm b/git.scm index b33cd45..c8762d1 100644 --- a/git.scm +++ b/git.scm @@ -785,7 +785,7 @@ (git-blob-lookup repo* (cond ((chicken-blob? source) - (git-blob-create-frombuffer repo* source)) + (git-blob-create-frombuffer repo* source (number-of-bytes source))) ((string? source) (if (regular-file? source) (git-blob-create-fromdisk repo* source) diff --git a/libgit2.scm b/libgit2.scm index a1e095c..83334c3 100644 --- a/libgit2.scm +++ b/libgit2.scm @@ -295,7 +295,7 @@ (define blob-lookup-prefix (foreign-lambda/allocate blob* git_blob_lookup_prefix repository oid unsigned-int)) (define blob-create-fromdisk (foreign-lambda/allocate oid git_blob_create_fromdisk repository nonnull-c-string)) (define blob-create-fromworkdir (foreign-lambda/allocate oid git_blob_create_fromworkdir repository nonnull-c-string)) -(define blob-create-frombuffer (foreign-lambda/allocate oid git_blob_create_frombuffer repository nonnull-c-string unsigned-int)) +(define blob-create-frombuffer (foreign-lambda/allocate oid git_blob_create_frombuffer repository nonnull-scheme-pointer size_t)) (define blob-id (foreign-lambda/copy oid git_blob_id blob*)) (define blob-free (foreign-lambda void git_blob_free blob*)) (define blob-rawcontent (foreign-lambda c-pointer git_blob_rawcontent blob*)) diff --git a/tests/run.scm b/tests/run.scm index b73e97f..7ede8da 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -393,6 +393,7 @@ (test-group "blob" (test-error "blob with nonexistent sha" (blob repo (make-string 40 #\a))) + (test "create-blob from memory source" 4 (blob-length (create-blob repo #${41424344}))) (let ((t (commit-tree commit))) (with-current-directory repo-path (lambda () -- 2.31.1