#include "packfile.h"
#include "fetch-object.h"
+/* The maximum size for an object header. */
+#define MAX_HEADER_LEN 32
+
const unsigned char null_sha1[GIT_MAX_RAWSZ];
const struct object_id null_oid;
const struct object_id empty_tree_oid = {
void prepare_alt_odb(void)
{
- const char *alt;
-
if (alt_odb_tail)
return;
- alt = getenv(ALTERNATE_DB_ENVIRONMENT);
-
alt_odb_tail = &alt_odb_list;
- link_alt_odb_entries(alt, PATH_SEP, NULL, 0);
+ link_alt_odb_entries(the_repository->alternate_db, PATH_SEP, NULL, 0);
read_info_alternates(get_object_directory(), 0);
}
enum object_type obj_type;
struct git_istream *st;
git_hash_ctx c;
- char hdr[32];
+ char hdr[MAX_HEADER_LEN];
int hdrlen;
if (map) {
unsigned long mapsize;
void *map;
git_zstream stream;
- char hdr[32];
+ char hdr[MAX_HEADER_LEN];
struct strbuf hdrbuf = STRBUF_INIT;
unsigned long size_scratch;
if (find_pack_entry(real->hash, &e))
break;
+ if (flags & OBJECT_INFO_IGNORE_LOOSE)
+ return -1;
+
/* Most likely it's a loose object. */
if (!sha1_loose_object_info(real->hash, oi, flags))
return 0;
/* Not a loose object; someone else may have just packed it. */
- reprepare_packed_git();
- if (find_pack_entry(real->hash, &e))
- break;
+ if (!(flags & OBJECT_INFO_QUICK)) {
+ reprepare_packed_git();
+ if (find_pack_entry(real->hash, &e))
+ break;
+ }
/* Check if it is a missing object */
if (fetch_if_missing && repository_format_partial_clone &&
int hash_object_file(const void *buf, unsigned long len, const char *type,
struct object_id *oid)
{
- char hdr[32];
+ char hdr[MAX_HEADER_LEN];
int hdrlen = sizeof(hdr);
write_object_file_prepare(buf, len, type, oid, hdr, &hdrlen);
return 0;
int write_object_file(const void *buf, unsigned long len, const char *type,
struct object_id *oid)
{
- char hdr[32];
+ char hdr[MAX_HEADER_LEN];
int hdrlen = sizeof(hdr);
/* Normally if we have it in the pack then we do not bother writing
int hdrlen, status = 0;
/* type string, SP, %lu of the length plus NUL must fit this */
- hdrlen = strlen(type) + 32;
+ hdrlen = strlen(type) + MAX_HEADER_LEN;
header = xmalloc(hdrlen);
write_object_file_prepare(buf, len, type, oid, header, &hdrlen);
void *buf;
unsigned long len;
enum object_type type;
- char hdr[32];
+ char hdr[MAX_HEADER_LEN];
int hdrlen;
int ret;
void *map = NULL;
unsigned long mapsize;
git_zstream stream;
- char hdr[32];
+ char hdr[MAX_HEADER_LEN];
*contents = NULL;