Commit fc42c28ebe8bd4b524cc0f1594395a04b7d8e796

Edward Thomson 2021-11-19T09:36:03

util: don't include unnecessary system libraries Remove some unnecessary includes from utility code.

diff --git a/src/date.c b/src/date.c
index 52cc308..1529276 100644
--- a/src/date.c
+++ b/src/date.c
@@ -11,7 +11,6 @@
 #endif
 
 #include "util.h"
-#include "cache.h"
 #include "posix.h"
 #include "date.h"
 
diff --git a/src/fs_path.h b/src/fs_path.h
index 188dcf3..9720d34 100644
--- a/src/fs_path.h
+++ b/src/fs_path.h
@@ -14,8 +14,6 @@
 #include "vector.h"
 #include "utf8.h"
 
-#include "git2/sys/path.h"
-
 /**
  * Path manipulation utils
  *
diff --git a/src/futils.c b/src/futils.c
index 7ec1009..454ed79 100644
--- a/src/futils.c
+++ b/src/futils.c
@@ -15,6 +15,8 @@
 #include "win32/findfile.h"
 #endif
 
+#define GIT_FILEMODE_DEFAULT 0100666
+
 int git_futils_mkpath2file(const char *file_path, const mode_t mode)
 {
 	return git_futils_mkdir(
@@ -256,7 +258,7 @@ int git_futils_readbuffer(git_str *buf, const char *path)
 }
 
 int git_futils_writebuffer(
-	const git_str *buf,	const char *path, int flags, mode_t mode)
+	const git_str *buf, const char *path, int flags, mode_t mode)
 {
 	int fd, do_fsync = 0, error = 0;
 
@@ -269,7 +271,7 @@ int git_futils_writebuffer(
 	flags &= ~O_FSYNC;
 
 	if (!mode)
-		mode = GIT_FILEMODE_BLOB;
+		mode = GIT_FILEMODE_DEFAULT;
 
 	if ((fd = p_open(path, flags, mode)) < 0) {
 		git_error_set(GIT_ERROR_OS, "could not open '%s' for writing", path);
diff --git a/src/hash.h b/src/hash.h
index 10b14a9..2b2eaf6 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -10,7 +10,6 @@
 
 #include "common.h"
 
-#include "git2/oid.h"
 #include "hash/sha1.h"
 
 typedef struct {
diff --git a/src/net.c b/src/net.c
index 58792ee..a91e746 100644
--- a/src/net.c
+++ b/src/net.c
@@ -9,7 +9,6 @@
 #include "netops.h"
 
 #include <ctype.h>
-#include "git2/errors.h"
 
 #include "posix.h"
 #include "str.h"
diff --git a/src/unix/map.c b/src/unix/map.c
index 88f283c..23fcb78 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -7,8 +7,6 @@
 
 #include "common.h"
 
-#include "git2/common.h"
-
 #if !defined(GIT_WIN32) && !defined(NO_MMAP)
 
 #include "map.h"
diff --git a/src/unix/posix.h b/src/unix/posix.h
index 7b3325e..27a8fec 100644
--- a/src/unix/posix.h
+++ b/src/unix/posix.h
@@ -7,9 +7,7 @@
 #ifndef INCLUDE_unix_posix_h__
 #define INCLUDE_unix_posix_h__
 
-#ifndef LIBGIT2_NO_FEATURES_H
-# include "git2/sys/features.h"
-#endif
+#include "common.h"
 
 #include <stdio.h>
 #include <dirent.h>
diff --git a/src/unix/realpath.c b/src/unix/realpath.c
index 893bac8..f1ca669 100644
--- a/src/unix/realpath.c
+++ b/src/unix/realpath.c
@@ -7,8 +7,6 @@
 
 #include "common.h"
 
-#include "git2/common.h"
-
 #ifndef GIT_WIN32
 
 #include <limits.h>
diff --git a/tests/core/copy.c b/tests/core/copy.c
index b03d710..6d22b50 100644
--- a/tests/core/copy.c
+++ b/tests/core/copy.c
@@ -1,6 +1,5 @@
 #include "clar_libgit2.h"
 #include "futils.h"
-#include "path.h"
 #include "posix.h"
 
 void test_core_copy__file(void)
diff --git a/tests/core/env.c b/tests/core/env.c
index 88c5c6a..8ba9b91 100644
--- a/tests/core/env.c
+++ b/tests/core/env.c
@@ -1,7 +1,6 @@
 #include "clar_libgit2.h"
 #include "futils.h"
 #include "sysdir.h"
-#include "path.h"
 
 #ifdef GIT_WIN32
 #define NUM_VARS 5
diff --git a/tests/core/link.c b/tests/core/link.c
index 6ab79b2..a1e2706 100644
--- a/tests/core/link.c
+++ b/tests/core/link.c
@@ -1,6 +1,5 @@
 #include "clar_libgit2.h"
 #include "posix.h"
-#include "path.h"
 
 #ifdef GIT_WIN32
 # include "win32/reparse.h"
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index 8d4b9af..58a4cfc 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -1,6 +1,5 @@
 #include "clar_libgit2.h"
 #include "futils.h"
-#include "path.h"
 #include "posix.h"
 
 static void cleanup_basic_dirs(void *ref)
diff --git a/tests/core/stat.c b/tests/core/stat.c
index 022380b..210072f 100644
--- a/tests/core/stat.c
+++ b/tests/core/stat.c
@@ -1,6 +1,5 @@
 #include "clar_libgit2.h"
 #include "futils.h"
-#include "path.h"
 #include "posix.h"
 
 void test_core_stat__initialize(void)
diff --git a/tests/path/win32.c b/tests/path/win32.c
index ff16639..64d8d8e 100644
--- a/tests/path/win32.c
+++ b/tests/path/win32.c
@@ -1,6 +1,5 @@
 
 #include "clar_libgit2.h"
-#include "path.h"
 
 #ifdef GIT_WIN32
 #include "win32/path_w32.h"