From fc42c28ebe8bd4b524cc0f1594395a04b7d8e796 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Fri, 19 Nov 2021 09:36:03 -0500 Subject: util: don't include unnecessary system libraries Remove some unnecessary includes from utility code. --- src/date.c | 1 - src/fs_path.h | 2 -- src/futils.c | 6 ++++-- src/hash.h | 1 - src/net.c | 1 - src/unix/map.c | 2 -- src/unix/posix.h | 4 +--- src/unix/realpath.c | 2 -- tests/core/copy.c | 1 - tests/core/env.c | 1 - tests/core/link.c | 1 - tests/core/mkdir.c | 1 - tests/core/stat.c | 1 - tests/path/win32.c | 1 - 14 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/date.c b/src/date.c index 52cc30824..1529276e2 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 188dcf303..9720d34ce 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 7ec1009bd..454ed79de 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 10b14a904..2b2eaf6d6 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 58792ee7d..a91e7460e 100644 --- a/src/net.c +++ b/src/net.c @@ -9,7 +9,6 @@ #include "netops.h" #include -#include "git2/errors.h" #include "posix.h" #include "str.h" diff --git a/src/unix/map.c b/src/unix/map.c index 88f283ce8..23fcb786e 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 7b3325e78..27a8fecd4 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 #include diff --git a/src/unix/realpath.c b/src/unix/realpath.c index 893bac87b..f1ca669f7 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 diff --git a/tests/core/copy.c b/tests/core/copy.c index b03d71083..6d22b503d 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 88c5c6aa3..8ba9b9124 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 6ab79b2a8..a1e2706b2 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 8d4b9afd6..58a4cfcdb 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 022380ba6..210072fe3 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 ff166395d..64d8d8e08 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" -- cgit v1.2.1