Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
6fdb1b2f
Unverified
Commit
6fdb1b2f
authored
Nov 30, 2021
by
Edward Thomson
Committed by
GitHub
Nov 30, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6122 from libgit2/ethomson/cleanup
Minor code cleanups
parents
f9c4dc10
84083dcc
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
60 additions
and
70 deletions
+60
-70
CMakeLists.txt
+1
-1
cmake/IdeSplitSources.cmake
+1
-1
cmake/SelectHTTPParser.cmake
+2
-2
cmake/SelectRegex.cmake
+2
-2
cmake/SelectWinHTTP.cmake
+2
-2
cmake/SelectZlib.cmake
+4
-4
deps/winhttp/CMakeLists.txt
+3
-5
src/CMakeLists.txt
+13
-13
src/date.c
+0
-1
src/filebuf.c
+3
-3
src/filebuf.h
+1
-1
src/fs_path.h
+0
-2
src/futils.c
+4
-2
src/hash.h
+0
-1
src/index.c
+1
-1
src/indexer.c
+1
-1
src/net.c
+0
-1
src/unix/map.c
+0
-2
src/unix/posix.h
+1
-3
src/unix/realpath.c
+0
-2
tests/CMakeLists.txt
+3
-3
tests/core/copy.c
+0
-1
tests/core/env.c
+0
-1
tests/core/link.c
+0
-1
tests/core/mkdir.c
+0
-1
tests/core/sha1.c
+17
-11
tests/core/stat.c
+0
-1
tests/core/utf8.c
+1
-0
tests/path/win32.c
+0
-1
No files found.
CMakeLists.txt
View file @
6fdb1b2f
...
...
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.5.1)
project
(
libgit2 VERSION
"1.3.0"
LANGUAGES C
)
# Add find modules to the path
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
libgit2
_SOURCE_DIR
}
/cmake"
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE
_SOURCE_DIR
}
/cmake"
)
#
# Build options
...
...
cmake/IdeSplitSources.cmake
View file @
6fdb1b2f
...
...
@@ -8,7 +8,7 @@ function(IDE_SPLIT_SOURCES target)
get_target_property
(
sources
${
target
}
SOURCES
)
foreach
(
source
${
sources
}
)
if
(
source MATCHES
".*/"
)
string
(
REPLACE
${
libgit2
_SOURCE_DIR
}
/
""
rel
${
source
}
)
string
(
REPLACE
${
CMAKE
_SOURCE_DIR
}
/
""
rel
${
source
}
)
if
(
rel
)
string
(
REGEX REPLACE
"/([^/]*)$"
""
rel
${
rel
}
)
if
(
rel
)
...
...
cmake/SelectHTTPParser.cmake
View file @
6fdb1b2f
...
...
@@ -12,8 +12,8 @@ if(USE_HTTP_PARSER STREQUAL "system")
endif
()
else
()
message
(
STATUS
"http-parser version 2 was not found or disabled; using bundled 3rd-party sources."
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/http-parser"
"
${
libgit2
_BINARY_DIR
}
/deps/http-parser"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
libgit2
_SOURCE_DIR
}
/deps/http-parser"
)
add_subdirectory
(
"
${
CMAKE_SOURCE_DIR
}
/deps/http-parser"
"
${
CMAKE
_BINARY_DIR
}
/deps/http-parser"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
CMAKE
_SOURCE_DIR
}
/deps/http-parser"
)
list
(
APPEND LIBGIT2_DEPENDENCY_OBJECTS
"$<TARGET_OBJECTS:http-parser>"
)
add_feature_info
(
http-parser ON
"http-parser support (bundled)"
)
endif
()
cmake/SelectRegex.cmake
View file @
6fdb1b2f
...
...
@@ -43,8 +43,8 @@ elseif(REGEX_BACKEND STREQUAL "builtin")
add_feature_info
(
regex ON
"using bundled PCRE"
)
set
(
GIT_REGEX_BUILTIN 1
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/pcre"
"
${
libgit2
_BINARY_DIR
}
/deps/pcre"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
libgit2
_SOURCE_DIR
}
/deps/pcre"
)
add_subdirectory
(
"
${
CMAKE_SOURCE_DIR
}
/deps/pcre"
"
${
CMAKE
_BINARY_DIR
}
/deps/pcre"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
CMAKE
_SOURCE_DIR
}
/deps/pcre"
)
list
(
APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:pcre>
)
else
()
message
(
FATAL_ERROR
"The REGEX_BACKEND option provided is not supported"
)
...
...
cmake/SelectWinHTTP.cmake
View file @
6fdb1b2f
...
...
@@ -4,9 +4,9 @@ if(WIN32 AND USE_WINHTTP)
# Since MinGW does not come with headers or an import library for winhttp,
# we have to include a private header and generate our own import library
if
(
MINGW
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/winhttp"
"
${
libgit2
_BINARY_DIR
}
/deps/winhttp"
)
add_subdirectory
(
"
${
CMAKE_SOURCE_DIR
}
/deps/winhttp"
"
${
CMAKE
_BINARY_DIR
}
/deps/winhttp"
)
list
(
APPEND LIBGIT2_SYSTEM_LIBS winhttp
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
libgit2
_SOURCE_DIR
}
/deps/winhttp"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
CMAKE
_SOURCE_DIR
}
/deps/winhttp"
)
else
()
list
(
APPEND LIBGIT2_SYSTEM_LIBS
"winhttp"
)
list
(
APPEND LIBGIT2_PC_LIBS
"-lwinhttp"
)
...
...
cmake/SelectZlib.cmake
View file @
6fdb1b2f
...
...
@@ -22,13 +22,13 @@ if(USE_BUNDLED_ZLIB STREQUAL "OFF")
endif
()
endif
()
if
(
USE_BUNDLED_ZLIB STREQUAL
"Chromium"
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/chromium-zlib"
"
${
libgit2
_BINARY_DIR
}
/deps/chromium-zlib"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
libgit2
_SOURCE_DIR
}
/deps/chromium-zlib"
)
add_subdirectory
(
"
${
CMAKE_SOURCE_DIR
}
/deps/chromium-zlib"
"
${
CMAKE
_BINARY_DIR
}
/deps/chromium-zlib"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
CMAKE
_SOURCE_DIR
}
/deps/chromium-zlib"
)
list
(
APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:chromium_zlib>
)
add_feature_info
(
zlib ON
"using (Chromium) bundled zlib"
)
elseif
(
USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND
)
add_subdirectory
(
"
${
libgit2_SOURCE_DIR
}
/deps/zlib"
"
${
libgit2
_BINARY_DIR
}
/deps/zlib"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
libgit2
_SOURCE_DIR
}
/deps/zlib"
)
add_subdirectory
(
"
${
CMAKE_SOURCE_DIR
}
/deps/zlib"
"
${
CMAKE
_BINARY_DIR
}
/deps/zlib"
)
list
(
APPEND LIBGIT2_DEPENDENCY_INCLUDES
"
${
CMAKE
_SOURCE_DIR
}
/deps/zlib"
)
list
(
APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:zlib>
)
add_feature_info
(
zlib ON
"using bundled zlib"
)
endif
()
deps/winhttp/CMakeLists.txt
View file @
6fdb1b2f
...
...
@@ -3,7 +3,7 @@ if(NOT DLLTOOL)
message
(
FATAL_ERROR
"Could not find dlltool command"
)
endif
()
set
(
LIBWINHTTP_PATH
"
${
libgit2
_BINARY_DIR
}
/deps/winhttp"
)
set
(
LIBWINHTTP_PATH
"
${
CMAKE
_BINARY_DIR
}
/deps/winhttp"
)
set
(
LIBWINHTTP_PATH
${
LIBWINHTTP_PATH
}
PARENT_SCOPE
)
file
(
MAKE_DIRECTORY
${
LIBWINHTTP_PATH
}
)
...
...
@@ -17,10 +17,8 @@ add_custom_command(
OUTPUT
${
LIBWINHTTP_PATH
}
/libwinhttp.a
COMMAND
${
DLLTOOL
}
-d
${
WINHTTP_DEF
}
-k -D winhttp.dll -l libwinhttp.a
DEPENDS
${
WINHTTP_DEF
}
WORKING_DIRECTORY
${
LIBWINHTTP_PATH
}
)
WORKING_DIRECTORY
${
LIBWINHTTP_PATH
}
)
set_source_files_properties
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/transports/winhttp.c
PROPERTIES OBJECT_DEPENDS
${
LIBWINHTTP_PATH
}
/libwinhttp.a
)
PROPERTIES OBJECT_DEPENDS
${
LIBWINHTTP_PATH
}
/libwinhttp.a
)
src/CMakeLists.txt
View file @
6fdb1b2f
...
...
@@ -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
}
)
src/date.c
View file @
6fdb1b2f
...
...
@@ -11,7 +11,6 @@
#endif
#include "util.h"
#include "cache.h"
#include "posix.h"
#include "date.h"
...
...
src/filebuf.c
View file @
6fdb1b2f
...
...
@@ -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
(
o
id
);
GIT_ASSERT_ARG
(
o
ut
);
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
(
o
id
->
id
,
&
file
->
digest
);
git_hash_final
(
o
ut
,
&
file
->
digest
);
git_hash_ctx_cleanup
(
&
file
->
digest
);
file
->
compute_digest
=
0
;
...
...
src/filebuf.h
View file @
6fdb1b2f
...
...
@@ -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
);
...
...
src/fs_path.h
View file @
6fdb1b2f
...
...
@@ -14,8 +14,6 @@
#include "vector.h"
#include "utf8.h"
#include "git2/sys/path.h"
/**
* Path manipulation utils
*
...
...
src/futils.c
View file @
6fdb1b2f
...
...
@@ -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
);
...
...
src/hash.h
View file @
6fdb1b2f
...
...
@@ -10,7 +10,6 @@
#include "common.h"
#include "git2/oid.h"
#include "hash/sha1.h"
typedef
struct
{
...
...
src/index.c
View file @
6fdb1b2f
...
...
@@ -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 */
...
...
src/indexer.c
View file @
6fdb1b2f
...
...
@@ -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
));
...
...
src/net.c
View file @
6fdb1b2f
...
...
@@ -9,7 +9,6 @@
#include "netops.h"
#include <ctype.h>
#include "git2/errors.h"
#include "posix.h"
#include "str.h"
...
...
src/unix/map.c
View file @
6fdb1b2f
...
...
@@ -7,8 +7,6 @@
#include "common.h"
#include "git2/common.h"
#if !defined(GIT_WIN32) && !defined(NO_MMAP)
#include "map.h"
...
...
src/unix/posix.h
View file @
6fdb1b2f
...
...
@@ -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>
...
...
src/unix/realpath.c
View file @
6fdb1b2f
...
...
@@ -7,8 +7,6 @@
#include "common.h"
#include "git2/common.h"
#ifndef GIT_WIN32
#include <limits.h>
...
...
tests/CMakeLists.txt
View file @
6fdb1b2f
...
...
@@ -38,7 +38,7 @@ set_source_files_properties(
add_executable(libgit2_tests
${
SRC_CLAR
}
${
SRC_TEST
}
${
LIBGIT2_OBJECTS
}
)
set_target_properties(libgit2_tests PROPERTIES C_STANDARD 90)
set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${
libgit2
_BINARY_DIR
}
)
set_target_properties(libgit2_tests PROPERTIES RUNTIME_OUTPUT_DIRECTORY
${
CMAKE
_BINARY_DIR
}
)
target_include_directories(libgit2_tests PRIVATE
${
TEST_INCLUDES
}
${
LIBGIT2_INCLUDES
}
${
LIBGIT2_DEPENDENCY_INCLUDES
}
)
target_include_directories(libgit2_tests SYSTEM PRIVATE
${
LIBGIT2_SYSTEM_INCLUDES
}
)
...
...
@@ -62,9 +62,9 @@ endif()
function(ADD_CLAR_TEST name)
if(NOT USE_LEAK_CHECKER STREQUAL "
OFF
")
add_test(
${
name
}
"
${
libgit2_SOURCE_DIR
}
/script/
${
USE_LEAK_CHECKER
}
.sh
" "
${
libgit2
_BINARY_DIR
}
/libgit2_tests
"
${
ARGN
}
)
add_test(
${
name
}
"
${
CMAKE_SOURCE_DIR
}
/script/
${
USE_LEAK_CHECKER
}
.sh
" "
${
CMAKE
_BINARY_DIR
}
/libgit2_tests
"
${
ARGN
}
)
else()
add_test(
${
name
}
"
${
libgit2
_BINARY_DIR
}
/libgit2_tests
"
${
ARGN
}
)
add_test(
${
name
}
"
${
CMAKE
_BINARY_DIR
}
/libgit2_tests
"
${
ARGN
}
)
endif()
endfunction(ADD_CLAR_TEST)
...
...
tests/core/copy.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "futils.h"
#include "path.h"
#include "posix.h"
void
test_core_copy__file
(
void
)
...
...
tests/core/env.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "futils.h"
#include "sysdir.h"
#include "path.h"
#ifdef GIT_WIN32
#define NUM_VARS 5
...
...
tests/core/link.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "posix.h"
#include "path.h"
#ifdef GIT_WIN32
# include "win32/reparse.h"
...
...
tests/core/mkdir.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "futils.h"
#include "path.h"
#include "posix.h"
static
void
cleanup_basic_dirs
(
void
*
ref
)
...
...
tests/core/sha1.c
View file @
6fdb1b2f
...
...
@@ -13,7 +13,7 @@ void test_core_sha1__cleanup(void)
cl_fixture_cleanup
(
FIXTURE_DIR
);
}
static
int
sha1_file
(
git_oid
*
out
,
const
char
*
filename
)
static
int
sha1_file
(
unsigned
char
*
out
,
const
char
*
filename
)
{
git_hash_ctx
ctx
;
char
buf
[
2048
];
...
...
@@ -31,7 +31,7 @@ static int sha1_file(git_oid *out, const char *filename)
cl_assert_equal_i
(
0
,
read_len
);
p_close
(
fd
);
ret
=
git_hash_final
(
out
->
id
,
&
ctx
);
ret
=
git_hash_final
(
out
,
&
ctx
);
git_hash_ctx_cleanup
(
&
ctx
);
return
ret
;
...
...
@@ -39,26 +39,32 @@ static int sha1_file(git_oid *out, const char *filename)
void
test_core_sha1__sum
(
void
)
{
git_oid
oid
,
expected
;
unsigned
char
expected
[
GIT_HASH_SHA1_SIZE
]
=
{
0x4e
,
0x72
,
0x67
,
0x9e
,
0x3e
,
0xa4
,
0xd0
,
0x4e
,
0x0c
,
0x64
,
0x2f
,
0x02
,
0x9e
,
0x61
,
0xeb
,
0x80
,
0x56
,
0xc7
,
0xed
,
0x94
};
unsigned
char
actual
[
GIT_HASH_SHA1_SIZE
];
cl_git_pass
(
sha1_file
(
&
oid
,
FIXTURE_DIR
"/hello_c"
));
git_oid_fromstr
(
&
expected
,
"4e72679e3ea4d04e0c642f029e61eb8056c7ed94"
);
cl_assert_equal_oid
(
&
expected
,
&
oid
);
cl_git_pass
(
sha1_file
(
actual
,
FIXTURE_DIR
"/hello_c"
));
cl_assert_equal_i
(
0
,
memcmp
(
expected
,
actual
,
GIT_HASH_SHA1_SIZE
));
}
/* test that sha1 collision detection works when enabled */
void
test_core_sha1__detect_collision_attack
(
void
)
{
git_oid
oid
,
expected
;
unsigned
char
actual
[
GIT_HASH_SHA1_SIZE
];
unsigned
char
expected
[
GIT_HASH_SHA1_SIZE
]
=
{
0x38
,
0x76
,
0x2c
,
0xf7
,
0xf5
,
0x59
,
0x34
,
0xb3
,
0x4d
,
0x17
,
0x9a
,
0xe6
,
0xa4
,
0xc8
,
0x0c
,
0xad
,
0xcc
,
0xbb
,
0x7f
,
0x0a
};
#ifdef GIT_SHA1_COLLISIONDETECT
GIT_UNUSED
(
&
expected
);
cl_git_fail
(
sha1_file
(
&
oid
,
FIXTURE_DIR
"/shattered-1.pdf"
));
cl_git_fail
(
sha1_file
(
actual
,
FIXTURE_DIR
"/shattered-1.pdf"
));
cl_assert_equal_s
(
"SHA1 collision attack detected"
,
git_error_last
()
->
message
);
#else
cl_git_pass
(
sha1_file
(
&
oid
,
FIXTURE_DIR
"/shattered-1.pdf"
));
git_oid_fromstr
(
&
expected
,
"38762cf7f55934b34d179ae6a4c80cadccbb7f0a"
);
cl_assert_equal_oid
(
&
expected
,
&
oid
);
cl_git_pass
(
sha1_file
(
actual
,
FIXTURE_DIR
"/shattered-1.pdf"
));
cl_assert_equal_i
(
0
,
memcmp
(
expected
,
actual
,
GIT_HASH_SHA1_SIZE
));
#endif
}
tests/core/stat.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "futils.h"
#include "path.h"
#include "posix.h"
void
test_core_stat__initialize
(
void
)
...
...
tests/core/utf8.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "utf8.h"
void
test_core_utf8__char_length
(
void
)
{
...
...
tests/path/win32.c
View file @
6fdb1b2f
#include "clar_libgit2.h"
#include "path.h"
#ifdef GIT_WIN32
#include "win32/path_w32.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment