X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=sha1_file.c;h=aa09b4646abff2f82d30c9968ae277d35db8c438;hb=72fdfb50f721460e4cdff16fbe9c72d4ce6c668c;hp=c08da35d8a2c9f9fb02370769e87578ec1f2fcce;hpb=26125f6b9be8dac31f56bf3da60dfa0df6dc0b59;p=git.git diff --git a/sha1_file.c b/sha1_file.c index c08da35d..aa09b464 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -564,7 +564,7 @@ static void prepare_packed_git_one(char *objdir, int local) dir = opendir(path); if (!dir) { if (errno != ENOENT) - error("unable to open object pack directory: %s: %s\n", + error("unable to open object pack directory: %s: %s", path, strerror(errno)); return; } @@ -841,6 +841,25 @@ static unsigned long unpack_object_header(struct packed_git *p, unsigned long of return offset; } +int check_reuse_pack_delta(struct packed_git *p, unsigned long offset, + unsigned char *base, unsigned long *sizep, + enum object_type *kindp) +{ + unsigned long ptr; + int status = -1; + + use_packed_git(p); + ptr = offset; + ptr = unpack_object_header(p, ptr, kindp, sizep); + if (*kindp != OBJ_DELTA) + goto done; + memcpy(base, p->pack_base + ptr, 20); + status = 0; + done: + unuse_packed_git(p); + return status; +} + void packed_object_info_detail(struct pack_entry *e, char *type, unsigned long *size, @@ -1494,7 +1513,8 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer, local = mkstemp(tmpfile); if (local < 0) - return error("Couldn't open %s for %s\n", tmpfile, sha1_to_hex(sha1)); + return error("Couldn't open %s for %s", + tmpfile, sha1_to_hex(sha1)); memset(&stream, 0, sizeof(stream)); @@ -1542,7 +1562,7 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer, } if (memcmp(sha1, real_sha1, 20)) { unlink(tmpfile); - return error("File %s has bad hash\n", sha1_to_hex(sha1)); + return error("File %s has bad hash", sha1_to_hex(sha1)); } return move_temp_to_file(tmpfile, sha1_file_name(sha1));