Skip to content
Snippets Groups Projects
Commit 76c076f8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Merge tag 'v2.9.5' of https://github.com/github/linguist

Linguist 2.9.5
parents c3d6fc5a a00967dd
No related branches found
No related tags found
No related merge requests found
Showing with 16149 additions and 0 deletions
#include "cache.h"
#include "blob.h"
const char *blob_type = "blob";
struct blob *lookup_blob(const unsigned char *sha1)
{
struct object *obj = lookup_object(sha1);
if (!obj)
return create_object(sha1, OBJ_BLOB, alloc_blob_node());
if (!obj->type)
obj->type = OBJ_BLOB;
if (obj->type != OBJ_BLOB) {
error("Object %s is a %s, not a blob",
sha1_to_hex(sha1), typename(obj->type));
return NULL;
}
return (struct blob *) obj;
}
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size)
{
item->object.parsed = 1;
return 0;
}
#ifndef BLOB_H
#define BLOB_H
#include "object.h"
extern const char *blob_type;
struct blob {
struct object object;
};
struct blob *lookup_blob(const unsigned char *sha1);
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
/**
* Blobs do not contain references to other objects and do not have
* structured data that needs parsing. However, code may use the
* "parsed" bit in the struct object for a blob to determine whether
* its content has been found to actually be available, so
* parse_blob_buffer() is used (by object.c) to flag that the object
* has been read successfully from the database.
**/
#endif /* BLOB_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2009-2012 the libgit2 contributors
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "common.h"
#include "hash.h"
#if defined(PPC_SHA1)
# include "ppc/sha1.h"
#else
# include "sha1.h"
#endif
struct git_hash_ctx {
SHA_CTX c;
};
git_hash_ctx *git_hash_new_ctx(void)
{
git_hash_ctx *ctx = git__malloc(sizeof(*ctx));
if (!ctx)
return NULL;
SHA1_Init(&ctx->c);
return ctx;
}
void git_hash_free_ctx(git_hash_ctx *ctx)
{
git__free(ctx);
}
void git_hash_init(git_hash_ctx *ctx)
{
assert(ctx);
SHA1_Init(&ctx->c);
}
void git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
{
assert(ctx);
SHA1_Update(&ctx->c, data, len);
}
void git_hash_final(git_oid *out, git_hash_ctx *ctx)
{
assert(ctx);
SHA1_Final(out->id, &ctx->c);
}
void git_hash_buf(git_oid *out, const void *data, size_t len)
{
SHA_CTX c;
SHA1_Init(&c);
SHA1_Update(&c, data, len);
SHA1_Final(out->id, &c);
}
void git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n)
{
SHA_CTX c;
size_t i;
SHA1_Init(&c);
for (i = 0; i < n; i++)
SHA1_Update(&c, vec[i].data, vec[i].len);
SHA1_Final(out->id, &c);
}
File moved
File moved
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment