git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 10/24] git-zlib: move declarations for git-zlib functions from cache.h

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 4, 2023, 01:22 UTC
Message-ID
<54545bbb02cc1cc1f7148b5bb39ea16a8914ef61.1680571351.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1509.v2.git.1680571348.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

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>
---
 Makefile                 |  2 +-
 archive-tar.c            |  1 +
 archive-zip.c            |  1 +
 builtin/unpack-objects.c |  1 +
 cache.h                  | 25 +------------------------
 zlib.c => git-zlib.c     |  3 ++-
 git-zlib.h               | 28 ++++++++++++++++++++++++++++
 http-backend.c           |  1 +
 http.h                   |  3 +++
 9 files changed, 39 insertions(+), 26 deletions(-)
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h
diff --git a/Makefile b/Makefile
index 50ee51fde32..0c367881bff 100644
--- a/Makefile
+++ b/Makefile
@@ -1036,6 +1036,7 @@ LIB_OBJS += fsmonitor.o
 LIB_OBJS += fsmonitor-ipc.o
 LIB_OBJS += fsmonitor-settings.o
 LIB_OBJS += gettext.o
+LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
@@ -1196,7 +1197,6 @@ LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
 LIB_OBJS += xdiff-interface.o
-LIB_OBJS += zlib.o
 
 BUILTIN_OBJS += builtin/add.o
 BUILTIN_OBJS += builtin/am.o
diff --git a/archive-tar.c b/archive-tar.c
index 497dad0b3af..4cd81d8161e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -5,6 +5,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "tar.h"
 #include "archive.h"
diff --git a/archive-zip.c b/archive-zip.c
index e6f5c10a14f..ef538a90df4 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -5,6 +5,7 @@
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "streaming.h"
 #include "utf8.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index f2c1323e661..ddbdb3dd226 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/cache.h b/cache.h
index 21db5da39a5..c06778b69cd 100644
--- a/cache.h
+++ b/cache.h
@@ -3,6 +3,7 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
+#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -14,30 +15,6 @@
 #include "repository.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)
 #define DTYPE(de)	((de)->d_type)
 #else
diff --git a/zlib.c b/git-zlib.c
similarity index 99%
rename from zlib.c
rename to git-zlib.c
index d594cba3fc9..d43bbeb6daa 100644
--- a/zlib.c
+++ b/git-zlib.c
@@ -2,7 +2,8 @@
  * zlib wrappers to make sure we don't silently miss errors
  * at init time.
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "git-zlib.h"
 
 static const char *zerr_to_string(int status)
 {
diff --git a/git-zlib.h b/git-zlib.h
new file mode 100644
index 00000000000..d8a670aff9f
--- /dev/null
+++ b/git-zlib.h
@@ -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 */
diff --git a/http-backend.c b/http-backend.c
index 89aad1b42c7..d41b3b9e1e7 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/http.h b/http.h
index 77c042706c6..783b2b09b8b 100644
--- a/http.h
+++ b/http.h
@@ -1,7 +1,10 @@
 #ifndef HTTP_H
 #define HTTP_H
 
+struct packed_git;
+
 #include "cache.h"
+#include "git-zlib.h"
 
 #include <curl/curl.h>
 #include <curl/easy.h>
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 36 of 101 in “Header cleanups (splitting up cache.h)”
  1. 00/24 Header cleanups (splitting up cache.h)Elijah Newren via GitGitGadget, Apr 1, 2023
  2. 03/24 treewide: be explicit about dependence on convert.hElijah Newren via GitGitGadget, Apr 1, 2023
  3. 01/24 treewide: be explicit about dependence on trace.h & trace2.hElijah Newren via GitGitGadget, Apr 1, 2023
  4. 02/24 treewide: be explicit about dependence on advice.hElijah Newren via GitGitGadget, Apr 1, 2023
  5. 04/24 treewide: be explicit about dependence on pack-revindex.hElijah Newren via GitGitGadget, Apr 1, 2023
  6. 05/24 treewide: be explicit about dependence on oid-array.hElijah Newren via GitGitGadget, Apr 1, 2023
  7. 06/24 treewide: be explicit about dependence on mem-pool.hElijah Newren via GitGitGadget, Apr 1, 2023
  8. 10/24 git-zlib: move declarations for git-zlib functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  9. 07/24 treewide: remove unnecessary cache.h inclusionElijah Newren via GitGitGadget, Apr 1, 2023
  10. 09/24 treewide: remove cache.h inclusion due to object-name.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  11. 11/24 treewide: remove cache.h inclusion due to git-zlib changesElijah Newren via GitGitGadget, Apr 1, 2023
  12. 13/24 treewide: remove cache.h inclusion due to object-file.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  13. 08/24 object-name.h: move declarations for object-name.c functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  14. 14/24 object.h: move an inline function and some defines from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  15. 17/24 pager.h: move declarations for pager.c functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  16. 12/24 object-file.h: move declarations for object-file.c functions from cache.hElijah Newren via GitGitGadget, Apr 1, 2023
  17. 16/24 treewide: remove cache.h inclusion due to editor.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  18. 20/24 strbuf: move forward declarations to beginning of fileElijah Newren via GitGitGadget, Apr 1, 2023
  19. 19/24 cache.h: remove unnecessary includesElijah Newren via GitGitGadget, Apr 1, 2023
  20. 15/24 editor: move editor-related functions and declarations into common fileElijah Newren via GitGitGadget, Apr 1, 2023
  21. 23/24 chdir-notify, quote: replace cache.h include with path.hElijah Newren via GitGitGadget, Apr 1, 2023
  22. 22/24 treewide: reduce includes of cache.h in other headersElijah Newren via GitGitGadget, Apr 1, 2023
  23. 21/24 treewide: remove double forward declaration of read_in_fullElijah Newren via GitGitGadget, Apr 1, 2023
  24. 18/24 treewide: remove cache.h inclusion due to pager.h changesElijah Newren via GitGitGadget, Apr 1, 2023
  25. 24/24 mailmap, quote: move declarations of global vars to correct unitElijah Newren via GitGitGadget, Apr 1, 2023
  26. Elijah NewrenApr 3, 2023
  27. 00/24 Header cleanups (splitting up cache.h)Elijah Newren via GitGitGadget, Apr 4, 2023
  28. 01/24 treewide: be explicit about dependence on trace.h & trace2.hElijah Newren via GitGitGadget, Apr 4, 2023
  29. 04/24 treewide: be explicit about dependence on pack-revindex.hElijah Newren via GitGitGadget, Apr 4, 2023
  30. 05/24 treewide: be explicit about dependence on oid-array.hElijah Newren via GitGitGadget, Apr 4, 2023
  31. 03/24 treewide: be explicit about dependence on convert.hElijah Newren via GitGitGadget, Apr 4, 2023
  32. 06/24 treewide: be explicit about dependence on mem-pool.hElijah Newren via GitGitGadget, Apr 4, 2023
  33. 02/24 treewide: be explicit about dependence on advice.hElijah Newren via GitGitGadget, Apr 4, 2023
  34. 07/24 treewide: remove unnecessary cache.h inclusionElijah Newren via GitGitGadget, Apr 4, 2023
  35. 11/24 treewide: remove cache.h inclusion due to git-zlib changesElijah Newren via GitGitGadget, Apr 4, 2023
  36. 10/24 git-zlib: move declarations for git-zlib functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  37. 09/24 treewide: remove cache.h inclusion due to object-name.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  38. 08/24 object-name.h: move declarations for object-name.c functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  39. 13/24 treewide: remove cache.h inclusion due to object-file.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  40. 17/24 treewide: remove cache.h inclusion due to editor.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  41. 14/24 object.h: move some inline functions and defines from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  42. 12/24 object-file.h: move declarations for object-file.c functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  43. 15/24 treewide: remove cache.h inclusion due to object.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  44. 16/24 editor: move editor-related functions and declarations into common fileElijah Newren via GitGitGadget, Apr 4, 2023
  45. 20/24 cache.h: remove unnecessary includesElijah Newren via GitGitGadget, Apr 4, 2023
  46. 18/24 pager.h: move declarations for pager.c functions from cache.hElijah Newren via GitGitGadget, Apr 4, 2023
  47. 19/24 treewide: remove cache.h inclusion due to pager.h changesElijah Newren via GitGitGadget, Apr 4, 2023
  48. 22/24 treewide: remove double forward declaration of read_in_fullElijah Newren via GitGitGadget, Apr 4, 2023
  49. 21/24 strbuf: move forward declarations to beginning of fileElijah Newren via GitGitGadget, Apr 4, 2023
  50. Calvin WanApr 5, 2023
  51. Elijah NewrenApr 7, 2023
  52. Calvin WanApr 10, 2023
  53. Elijah NewrenApr 10, 2023
  54. 24/24 mailmap, quote: move declarations of global vars to correct unitElijah Newren via GitGitGadget, Apr 4, 2023
  55. 23/24 treewide: reduce includes of cache.h in other headersElijah Newren via GitGitGadget, Apr 4, 2023
  56. Calvin WanApr 5, 2023
  57. Elijah NewrenApr 7, 2023
  58. Calvin WanApr 10, 2023
  59. 00/23 Header cleanups (splitting up cache.h)Elijah Newren via GitGitGadget, Apr 11, 2023
  60. 02/23 treewide: be explicit about dependence on advice.hElijah Newren via GitGitGadget, Apr 11, 2023
  61. 03/23 treewide: be explicit about dependence on convert.hElijah Newren via GitGitGadget, Apr 11, 2023
  62. 01/23 treewide: be explicit about dependence on trace.h & trace2.hElijah Newren via GitGitGadget, Apr 11, 2023
  63. 04/23 treewide: be explicit about dependence on pack-revindex.hElijah Newren via GitGitGadget, Apr 11, 2023
  64. 05/23 treewide: be explicit about dependence on oid-array.hElijah Newren via GitGitGadget, Apr 11, 2023
  65. 06/23 treewide: be explicit about dependence on mem-pool.hElijah Newren, Apr 11, 2023
  66. 07/23 treewide: remove unnecessary cache.h inclusionElijah Newren, Apr 11, 2023
  67. fix connection via git protocolMichael J Gruber, Apr 15, 2023
  68. Elijah NewrenApr 16, 2023
  69. Elijah NewrenApr 16, 2023
  70. Michael J GruberApr 16, 2023
  71. Jeff KingApr 17, 2023
  72. Junio C HamanoApr 17, 2023
  73. Junio C HamanoApr 17, 2023
  74. Jeff KingApr 18, 2023
  75. Junio C HamanoApr 18, 2023
  76. Elijah NewrenApr 18, 2023
  77. Jeff KingApr 18, 2023
  78. Junio C HamanoApr 17, 2023
  79. Elijah NewrenApr 18, 2023
  80. Junio C HamanoApr 18, 2023
  81. Eric SunshineApr 18, 2023
  82. Elijah NewrenApr 19, 2023
  83. Junio C HamanoApr 24, 2023
  84. Elijah NewrenApr 19, 2023
  85. 09/23 treewide: remove cache.h inclusion due to object-name.h changesElijah Newren, Apr 11, 2023
  86. 10/23 git-zlib: move declarations for git-zlib functions from cache.hElijah Newren, Apr 11, 2023
  87. 08/23 object-name.h: move declarations for object-name.c functions from cache.hElijah Newren, Apr 11, 2023
  88. 11/23 treewide: remove cache.h inclusion due to git-zlib changesElijah Newren, Apr 11, 2023
  89. 13/23 treewide: remove cache.h inclusion due to object-file.h changesElijah Newren, Apr 11, 2023
  90. 12/23 object-file.h: move declarations for object-file.c functions from cache.hElijah Newren, Apr 11, 2023
  91. 14/23 object.h: move some inline functions and defines from cache.hElijah Newren, Apr 11, 2023
  92. 15/23 treewide: remove cache.h inclusion due to object.h changesElijah Newren, Apr 11, 2023
  93. 16/23 editor: move editor-related functions and declarations into common fileElijah Newren, Apr 11, 2023
  94. 17/23 treewide: remove cache.h inclusion due to editor.h changesElijah Newren, Apr 11, 2023
  95. 18/23 pager.h: move declarations for pager.c functions from cache.hElijah Newren, Apr 11, 2023
  96. 19/23 treewide: remove cache.h inclusion due to pager.h changesElijah Newren, Apr 11, 2023
  97. 20/23 cache.h: remove unnecessary includesElijah Newren, Apr 11, 2023
  98. 21/23 treewide: remove double forward declaration of read_in_fullElijah Newren, Apr 11, 2023
  99. 22/23 treewide: reduce includes of cache.h in other headersElijah Newren, Apr 11, 2023
  100. 23/23 mailmap, quote: move declarations of global vars to correct unitElijah Newren, Apr 11, 2023
  101. Elijah NewrenApr 11, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.