summaryrefslogtreecommitdiff
path: root/include/git2/blob.h
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2012-12-17 10:13:36 -0800
committerVicent Martí <vicent@github.com>2012-12-17 10:13:36 -0800
commit0d10e79dd9b4c5dee72066526a6a3c99e19c545b (patch)
tree649f1693dcb21b8733238fec2f4856aa56c8ebe5 /include/git2/blob.h
parentf79535092d86b531793640834bb010fa67dd4c3c (diff)
parenta3337f10bb604fce96e185088411feab53ab3d64 (diff)
downloadlibgit2-0d10e79dd9b4c5dee72066526a6a3c99e19c545b.tar.gz
Merge pull request #1149 from nulltoken/topic/blob_isbinary
Introduce git_blob_is_binary()
Diffstat (limited to 'include/git2/blob.h')
-rw-r--r--include/git2/blob.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/git2/blob.h b/include/git2/blob.h
index a68c78b5a..30055b614 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -183,6 +183,19 @@ GIT_EXTERN(int) git_blob_create_fromchunks(
*/
GIT_EXTERN(int) git_blob_create_frombuffer(git_oid *oid, git_repository *repo, const void *buffer, size_t len);
+/**
+ * Determine if the blob content is most certainly binary or not.
+ *
+ * The heuristic used to guess if a file is binary is taken from core git:
+ * Searching for NUL bytes and looking for a reasonable ratio of printable
+ * to non-printable characters among the first 4000 bytes.
+ *
+ * @param blob The blob which content should be analyzed
+ * @return 1 if the content of the blob is detected
+ * as binary; 0 otherwise.
+ */
+GIT_EXTERN(int) git_blob_is_binary(git_blob *blob);
+
/** @} */
GIT_END_DECL
#endif