git-zlib: move declarations for git-zlib functions from cache.h

Move functions from cache.h for zlib.c into a new header file.  Since
adding a "zlib.h" would cause issues with the real zlib, rename zlib.c
to git-zlib.c while we are at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren 2023-04-11 00:41:51 -07:00 committed by Junio C Hamano
parent e93fc5d721
commit d88dbaa718
9 changed files with 39 additions and 26 deletions

View File

@ -1036,6 +1036,7 @@ LIB_OBJS += fsmonitor.o
LIB_OBJS += fsmonitor-ipc.o LIB_OBJS += fsmonitor-ipc.o
LIB_OBJS += fsmonitor-settings.o LIB_OBJS += fsmonitor-settings.o
LIB_OBJS += gettext.o LIB_OBJS += gettext.o
LIB_OBJS += git-zlib.o
LIB_OBJS += gpg-interface.o LIB_OBJS += gpg-interface.o
LIB_OBJS += graph.o LIB_OBJS += graph.o
LIB_OBJS += grep.o LIB_OBJS += grep.o
@ -1196,7 +1197,6 @@ LIB_OBJS += write-or-die.o
LIB_OBJS += ws.o LIB_OBJS += ws.o
LIB_OBJS += wt-status.o LIB_OBJS += wt-status.o
LIB_OBJS += xdiff-interface.o LIB_OBJS += xdiff-interface.o
LIB_OBJS += zlib.o
BUILTIN_OBJS += builtin/add.o BUILTIN_OBJS += builtin/add.o
BUILTIN_OBJS += builtin/am.o BUILTIN_OBJS += builtin/am.o

View File

@ -5,6 +5,7 @@
#include "alloc.h" #include "alloc.h"
#include "config.h" #include "config.h"
#include "gettext.h" #include "gettext.h"
#include "git-zlib.h"
#include "hex.h" #include "hex.h"
#include "tar.h" #include "tar.h"
#include "archive.h" #include "archive.h"

View File

@ -5,6 +5,7 @@
#include "config.h" #include "config.h"
#include "archive.h" #include "archive.h"
#include "gettext.h" #include "gettext.h"
#include "git-zlib.h"
#include "hex.h" #include "hex.h"
#include "streaming.h" #include "streaming.h"
#include "utf8.h" #include "utf8.h"

View File

@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include "environment.h" #include "environment.h"
#include "gettext.h" #include "gettext.h"
#include "git-zlib.h"
#include "hex.h" #include "hex.h"
#include "object-store.h" #include "object-store.h"
#include "object.h" #include "object.h"

25
cache.h
View File

@ -3,6 +3,7 @@
#include "git-compat-util.h" #include "git-compat-util.h"
#include "strbuf.h" #include "strbuf.h"
#include "git-zlib.h"
#include "hashmap.h" #include "hashmap.h"
#include "list.h" #include "list.h"
#include "gettext.h" #include "gettext.h"
@ -14,30 +15,6 @@
#include "repository.h" #include "repository.h"
#include "statinfo.h" #include "statinfo.h"
typedef struct git_zstream {
z_stream z;
unsigned long avail_in;
unsigned long avail_out;
unsigned long total_in;
unsigned long total_out;
unsigned char *next_in;
unsigned char *next_out;
} git_zstream;
void git_inflate_init(git_zstream *);
void git_inflate_init_gzip_only(git_zstream *);
void git_inflate_end(git_zstream *);
int git_inflate(git_zstream *, int flush);
void git_deflate_init(git_zstream *, int level);
void git_deflate_init_gzip(git_zstream *, int level);
void git_deflate_init_raw(git_zstream *, int level);
void git_deflate_end(git_zstream *);
int git_deflate_abort(git_zstream *);
int git_deflate_end_gently(git_zstream *);
int git_deflate(git_zstream *, int flush);
unsigned long git_deflate_bound(git_zstream *, unsigned long);
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT) #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type) #define DTYPE(de) ((de)->d_type)
#else #else

View File

@ -2,7 +2,8 @@
* zlib wrappers to make sure we don't silently miss errors * zlib wrappers to make sure we don't silently miss errors
* at init time. * at init time.
*/ */
#include "cache.h" #include "git-compat-util.h"
#include "git-zlib.h"
static const char *zerr_to_string(int status) static const char *zerr_to_string(int status)
{ {

28
git-zlib.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef GIT_ZLIB_H
#define GIT_ZLIB_H
typedef struct git_zstream {
z_stream z;
unsigned long avail_in;
unsigned long avail_out;
unsigned long total_in;
unsigned long total_out;
unsigned char *next_in;
unsigned char *next_out;
} git_zstream;
void git_inflate_init(git_zstream *);
void git_inflate_init_gzip_only(git_zstream *);
void git_inflate_end(git_zstream *);
int git_inflate(git_zstream *, int flush);
void git_deflate_init(git_zstream *, int level);
void git_deflate_init_gzip(git_zstream *, int level);
void git_deflate_init_raw(git_zstream *, int level);
void git_deflate_end(git_zstream *);
int git_deflate_abort(git_zstream *);
int git_deflate_end_gently(git_zstream *);
int git_deflate(git_zstream *, int flush);
unsigned long git_deflate_bound(git_zstream *, unsigned long);
#endif /* GIT_ZLIB_H */

View File

@ -2,6 +2,7 @@
#include "alloc.h" #include "alloc.h"
#include "config.h" #include "config.h"
#include "environment.h" #include "environment.h"
#include "git-zlib.h"
#include "hex.h" #include "hex.h"
#include "repository.h" #include "repository.h"
#include "refs.h" #include "refs.h"

3
http.h
View File

@ -1,7 +1,10 @@
#ifndef HTTP_H #ifndef HTTP_H
#define HTTP_H #define HTTP_H
struct packed_git;
#include "cache.h" #include "cache.h"
#include "git-zlib.h"
#include <curl/curl.h> #include <curl/curl.h>
#include <curl/easy.h> #include <curl/easy.h>