Skip to content

Commit 1327dbc

Browse files
authored
Merge pull request libgit2#6133 from libgit2/ethomson/cli_redux
CLI (redux)
2 parents eca9e1c + e427d0a commit 1327dbc

File tree

882 files changed

+3332
-1225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

882 files changed

+3332
-1225
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# CMake build script for the libgit2 project
1+
# libgit2: the cross-platform, linkable library implementation of git.
22
# See `README.md` for build instructions.
3+
#
4+
# This top-level CMakeLists.txt sets up configuration options and
5+
# determines which subprojects to build.
36

47
cmake_minimum_required(VERSION 3.5.1)
58

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

ci/test.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,18 @@ fi
159159
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
160160
echo ""
161161
echo "##############################################################################"
162-
echo "## Running (offline) tests"
162+
echo "## Running core tests"
163163
echo "##############################################################################"
164164

165+
echo ""
166+
echo "Running libgit2 integration (offline) tests"
167+
echo ""
165168
run_test offline
169+
170+
echo ""
171+
echo "Running utility tests"
172+
echo ""
173+
run_test util
166174
fi
167175

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

187195
echo ""
188196
echo "##############################################################################"
189-
echo "## Running (online) tests"
197+
echo "## Running networking (online) tests"
190198
echo "##############################################################################"
191199

192200
export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository"
@@ -198,9 +206,9 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
198206
# Run the online tests that immutably change global state separately
199207
# to avoid polluting the test environment.
200208
echo ""
201-
echo "##############################################################################"
202-
echo "## Running (online_customcert) tests"
203-
echo "##############################################################################"
209+
echo "Running custom certificate (online_customcert) tests"
210+
echo ""
211+
204212
run_test online_customcert
205213
fi
206214

cmake/AddClarTest.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function(ADD_CLAR_TEST project name)
2+
if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
3+
add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
4+
else()
5+
add_test(${name} "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
6+
endif()
7+
endfunction(ADD_CLAR_TEST)

cmake/SelectHashes.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ endif()
2121

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

examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# examples: code usage examples of libgit2
2+
13
file(GLOB SRC_EXAMPLES *.c *.h)
24

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

1214
if(WIN32 OR ANDROID)
13-
target_link_libraries(lg2 git2)
15+
target_link_libraries(lg2 libgit2package)
1416
else()
15-
target_link_libraries(lg2 git2 pthread)
17+
target_link_libraries(lg2 libgit2package pthread)
1618
endif()

fuzzers/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# fuzzers: libFuzzer and standalone fuzzing utilities
2+
13
if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
24
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
35
add_c_flag(-fsanitize=fuzzer)

include/git2/errors.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ GIT_EXTERN(const git_error *) git_error_last(void);
130130
GIT_EXTERN(void) git_error_clear(void);
131131

132132
/**
133-
* Set the error message string for this thread.
133+
* Set the error message string for this thread, using `printf`-style
134+
* formatting.
134135
*
135136
* This function is public so that custom ODB backends and the like can
136137
* relay an error message through libgit2. Most regular users of libgit2
@@ -143,7 +144,20 @@ GIT_EXTERN(void) git_error_clear(void);
143144
*
144145
* @param error_class One of the `git_error_t` enum above describing the
145146
* general subsystem that is responsible for the error.
146-
* @param string The formatted error message to keep
147+
* @param fmt The `printf`-style format string; subsequent arguments must
148+
* be the arguments for the format string.
149+
*/
150+
GIT_EXTERN(void) git_error_set(int error_class, const char *fmt, ...)
151+
GIT_FORMAT_PRINTF(2, 3);
152+
153+
/**
154+
* Set the error message string for this thread. This function is like
155+
* `git_error_set` but takes a static string instead of a `printf`-style
156+
* format.
157+
*
158+
* @param error_class One of the `git_error_t` enum above describing the
159+
* general subsystem that is responsible for the error.
160+
* @param string The error message to keep
147161
* @return 0 on success or -1 on failure
148162
*/
149163
GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);

0 commit comments

Comments
 (0)