diff options
| author | Edward Thomson <ethomson@edwardthomson.com> | 2021-11-30 21:09:57 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-30 21:09:57 -0500 |
| commit | 6fdb1b2f55da9593576b096ee2eecce61995fb51 (patch) | |
| tree | bfd2ca7930f2643b0ada9b9f4935f832fdf1c18a /src | |
| parent | f9c4dc10d90732cfbe2271dd58b01dd8f4003d15 (diff) | |
| parent | 84083dcc8bd41332ccac9d7b537f3e254d79011c (diff) | |
| download | libgit2-6fdb1b2f55da9593576b096ee2eecce61995fb51.tar.gz | |
Merge pull request #6122 from libgit2/ethomson/cleanup
Minor code cleanups
Diffstat (limited to 'src')
| -rw-r--r-- | src/CMakeLists.txt | 26 | ||||
| -rw-r--r-- | src/date.c | 1 | ||||
| -rw-r--r-- | src/filebuf.c | 6 | ||||
| -rw-r--r-- | src/filebuf.h | 2 | ||||
| -rw-r--r-- | src/fs_path.h | 2 | ||||
| -rw-r--r-- | src/futils.c | 6 | ||||
| -rw-r--r-- | src/hash.h | 1 | ||||
| -rw-r--r-- | src/index.c | 2 | ||||
| -rw-r--r-- | src/indexer.c | 2 | ||||
| -rw-r--r-- | src/net.c | 1 | ||||
| -rw-r--r-- | src/unix/map.c | 2 | ||||
| -rw-r--r-- | src/unix/posix.h | 4 | ||||
| -rw-r--r-- | src/unix/realpath.c | 2 |
13 files changed, 24 insertions, 33 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d6a103667..03609b681 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,8 +36,8 @@ set(LIBGIT2_PC_LIBS "") set(LIBGIT2_INCLUDES "${CMAKE_CURRENT_BINARY_DIR}" - "${libgit2_SOURCE_DIR}/src" - "${libgit2_SOURCE_DIR}/include") + "${CMAKE_SOURCE_DIR}/src" + "${CMAKE_SOURCE_DIR}/include") if(HAVE_FUTIMENS) set(GIT_USE_FUTIMENS 1) @@ -117,8 +117,8 @@ target_sources(git2internal PRIVATE ${SRC_SHA1}) # Optional external dependency: ntlmclient if(USE_NTLMCLIENT) set(GIT_NTLM 1) - add_subdirectory("${libgit2_SOURCE_DIR}/deps/ntlmclient" "${libgit2_BINARY_DIR}/deps/ntlmclient") - list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${libgit2_SOURCE_DIR}/deps/ntlmclient") + add_subdirectory("${CMAKE_SOURCE_DIR}/deps/ntlmclient" "${CMAKE_BINARY_DIR}/deps/ntlmclient") + list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${CMAKE_SOURCE_DIR}/deps/ntlmclient") list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:ntlmclient>") endif() add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix") @@ -164,9 +164,9 @@ target_compile_definitions(git2internal PRIVATE _FILE_OFFSET_BITS=64) # Collect sourcefiles file(GLOB SRC_H - "${libgit2_SOURCE_DIR}/include/git2.h" - "${libgit2_SOURCE_DIR}/include/git2/*.h" - "${libgit2_SOURCE_DIR}/include/git2/sys/*.h") + "${CMAKE_SOURCE_DIR}/include/git2.h" + "${CMAKE_SOURCE_DIR}/include/git2/*.h" + "${CMAKE_SOURCE_DIR}/include/git2/sys/*.h") list(SORT SRC_H) target_sources(git2internal PRIVATE ${SRC_H}) @@ -225,7 +225,7 @@ configure_file(features.h.in git2/sys/features.h) ide_split_sources(git2internal) list(APPEND LIBGIT2_OBJECTS $<TARGET_OBJECTS:git2internal> ${LIBGIT2_DEPENDENCY_OBJECTS}) -target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${libgit2_SOURCE_DIR}/include) +target_include_directories(git2internal PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES} PUBLIC ${CMAKE_SOURCE_DIR}/include) target_include_directories(git2internal SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES}) set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE) @@ -247,9 +247,9 @@ add_library(git2 ${WIN_RC} ${LIBGIT2_OBJECTS}) target_link_libraries(git2 ${LIBGIT2_SYSTEM_LIBS}) set_target_properties(git2 PROPERTIES C_STANDARD 90) -set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) -set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) -set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${libgit2_BINARY_DIR}) +set_target_properties(git2 PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set_target_properties(git2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set_target_properties(git2 PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) # Workaround for Cmake bug #0011240 (see http://public.kitware.com/Bug/view.php?id=11240) # Win64+MSVC+static libs = linker error @@ -290,5 +290,5 @@ install(TARGETS git2 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${CMAKE_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 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/filebuf.c b/src/filebuf.c index f0bd0004f..eafcba3bd 100644 --- a/src/filebuf.c +++ b/src/filebuf.c @@ -386,9 +386,9 @@ cleanup: return error; } -int git_filebuf_hash(git_oid *oid, git_filebuf *file) +int git_filebuf_hash(unsigned char *out, git_filebuf *file) { - GIT_ASSERT_ARG(oid); + GIT_ASSERT_ARG(out); GIT_ASSERT_ARG(file); GIT_ASSERT_ARG(file->compute_digest); @@ -397,7 +397,7 @@ int git_filebuf_hash(git_oid *oid, git_filebuf *file) if (verify_last_error(file) < 0) return -1; - git_hash_final(oid->id, &file->digest); + git_hash_final(out, &file->digest); git_hash_ctx_cleanup(&file->digest); file->compute_digest = 0; diff --git a/src/filebuf.h b/src/filebuf.h index 9d53bc307..adbb19936 100644 --- a/src/filebuf.h +++ b/src/filebuf.h @@ -87,7 +87,7 @@ int git_filebuf_open_withsize(git_filebuf *file, const char *path, int flags, mo int git_filebuf_commit(git_filebuf *lock); int git_filebuf_commit_at(git_filebuf *lock, const char *path); void git_filebuf_cleanup(git_filebuf *lock); -int git_filebuf_hash(git_oid *oid, git_filebuf *file); +int git_filebuf_hash(unsigned char *out, git_filebuf *file); int git_filebuf_flush(git_filebuf *file); int git_filebuf_stats(time_t *mtime, size_t *size, git_filebuf *file); 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/index.c b/src/index.c index 7ade4341f..a2d80bc6e 100644 --- a/src/index.c +++ b/src/index.c @@ -3080,7 +3080,7 @@ static int write_index(git_oid *checksum, git_index *index, git_filebuf *file) return -1; /* get out the hash for all the contents we've appended to the file */ - git_filebuf_hash(&hash_final, file); + git_filebuf_hash(hash_final.id, file); git_oid_cpy(checksum, &hash_final); /* write it at the end of the file */ diff --git a/src/indexer.c b/src/indexer.c index 213ad7581..d9396e058 100644 --- a/src/indexer.c +++ b/src/indexer.c @@ -1289,7 +1289,7 @@ int git_indexer_commit(git_indexer *idx, git_indexer_progress *stats) goto on_error; /* Write out the hash of the idx */ - if (git_filebuf_hash(&trailer_hash, &index_file) < 0) + if (git_filebuf_hash(trailer_hash.id, &index_file) < 0) goto on_error; git_filebuf_write(&index_file, &trailer_hash, sizeof(git_oid)); @@ -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 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 <stdio.h> #include <dirent.h> 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 <limits.h> |
