Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CLI (redux) #6133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CMake build script for the libgit2 project
# libgit2: the cross-platform, linkable library implementation of git.
# See `README.md` for build instructions.
#
# This top-level CMakeLists.txt sets up configuration options and
# determines which subprojects to build.

cmake_minimum_required(VERSION 3.5.1)

Expand All @@ -15,6 +18,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
# Optional subsystems
option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
option(BUILD_TESTS "Build Tests using the Clar suite" ON)
option(BUILD_CLI "Build the command-line interface" ON)
option(BUILD_EXAMPLES "Build library usage example apps" OFF)
option(BUILD_FUZZERS "Build the fuzz targets" OFF)

Expand Down
18 changes: 13 additions & 5 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,18 @@ fi
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
echo ""
echo "##############################################################################"
echo "## Running (offline) tests"
echo "## Running core tests"
echo "##############################################################################"

echo ""
echo "Running libgit2 integration (offline) tests"
echo ""
run_test offline

echo ""
echo "Running utility tests"
echo ""
run_test util
fi

if [ -n "$RUN_INVASIVE_TESTS" ]; then
Expand All @@ -186,7 +194,7 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then

echo ""
echo "##############################################################################"
echo "## Running (online) tests"
echo "## Running networking (online) tests"
echo "##############################################################################"

export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository"
Expand All @@ -198,9 +206,9 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
# Run the online tests that immutably change global state separately
# to avoid polluting the test environment.
echo ""
echo "##############################################################################"
echo "## Running (online_customcert) tests"
echo "##############################################################################"
echo "Running custom certificate (online_customcert) tests"
echo ""

run_test online_customcert
fi

Expand Down
7 changes: 7 additions & 0 deletions cmake/AddClarTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function(ADD_CLAR_TEST project name)
if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
else()
add_test(${name} "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
endif()
endfunction(ADD_CLAR_TEST)
3 changes: 0 additions & 3 deletions cmake/SelectHashes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ endif()

if(USE_SHA1 STREQUAL "CollisionDetection")
set(GIT_SHA1_COLLISIONDETECT 1)
add_definitions(-DSHA1DC_NO_STANDARD_INCLUDES=1)
add_definitions(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
add_definitions(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
elseif(USE_SHA1 STREQUAL "OpenSSL")
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS

Expand Down
6 changes: 4 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# examples: code usage examples of libgit2

file(GLOB SRC_EXAMPLES *.c *.h)

add_executable(lg2 ${SRC_EXAMPLES})
Expand All @@ -10,7 +12,7 @@ target_include_directories(lg2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_
target_include_directories(lg2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})

if(WIN32 OR ANDROID)
target_link_libraries(lg2 git2)
target_link_libraries(lg2 libgit2package)
else()
target_link_libraries(lg2 git2 pthread)
target_link_libraries(lg2 libgit2package pthread)
endif()
2 changes: 2 additions & 0 deletions fuzzers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# fuzzers: libFuzzer and standalone fuzzing utilities

if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
add_c_flag(-fsanitize=fuzzer)
Expand Down
18 changes: 16 additions & 2 deletions include/git2/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ GIT_EXTERN(const git_error *) git_error_last(void);
GIT_EXTERN(void) git_error_clear(void);

/**
* Set the error message string for this thread.
* Set the error message string for this thread, using `printf`-style
* formatting.
*
* This function is public so that custom ODB backends and the like can
* relay an error message through libgit2. Most regular users of libgit2
Expand All @@ -143,7 +144,20 @@ GIT_EXTERN(void) git_error_clear(void);
*
* @param error_class One of the `git_error_t` enum above describing the
* general subsystem that is responsible for the error.
* @param string The formatted error message to keep
* @param fmt The `printf`-style format string; subsequent arguments must
* be the arguments for the format string.
*/
GIT_EXTERN(void) git_error_set(int error_class, const char *fmt, ...)
GIT_FORMAT_PRINTF(2, 3);

/**
* Set the error message string for this thread. This function is like
* `git_error_set` but takes a static string instead of a `printf`-style
* format.
*
* @param error_class One of the `git_error_t` enum above describing the
* general subsystem that is responsible for the error.
* @param string The error message to keep
* @return 0 on success or -1 on failure
*/
GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);
Expand Down
Loading