From 300f44125a5abb00f6185babc9bb828aec556015 Mon Sep 17 00:00:00 2001 From: Miha Date: Tue, 25 Feb 2014 11:56:11 +0100 Subject: [PATCH 1/6] - BUGFIX #2133 (@fourplusone) in smart_protocol.c - added MSVC cmake definitions to disable warnings - general.c is rewritten so it is ansi-c compatible and compiles ok on microsoft windows - some MSVC reported warning fixes --- CMakeLists.txt | 7 ++- examples/add.c | 2 +- examples/blame.c | 3 +- examples/cat-file.c | 2 +- examples/common.c | 2 +- examples/general.c | 82 ++++++++++++++++----------------- examples/network/clone.c | 2 +- src/transports/smart_protocol.c | 4 ++ src/transports/ssh.c | 3 +- 9 files changed, 57 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6b327503..27cf1a558 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,8 @@ INCLUDE(CheckLibraryExists) # Build options # -OPTION( SONAME "Set the (SO)VERSION of the target" ON ) +OPTION( SONAME + "Set the (SO)VERSION of the target" ON ) OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON ) OPTION( THREADSAFE "Build libgit2 as threadsafe" OFF ) OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON ) @@ -57,6 +58,10 @@ IF(MSVC) # By default, libgit2 is built with WinHTTP. To use the built-in # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument. OPTION( WINHTTP "Use Win32 WinHTTP routines" ON ) + + ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) ENDIF() # This variable will contain the libraries we need to put into diff --git a/examples/add.c b/examples/add.c index 336596bde..0c6076e81 100644 --- a/examples/add.c +++ b/examples/add.c @@ -78,7 +78,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo git_status_t status; (void)matched_pathspec; - if (git_status_file(&status, p.repo, path)) { + if (git_status_file((unsigned int*)(&status), p.repo, path)) { return -1; //abort } diff --git a/examples/blame.c b/examples/blame.c index 1f5db69a1..d7b843cc2 100644 --- a/examples/blame.c +++ b/examples/blame.c @@ -105,8 +105,9 @@ int main(int argc, char *argv[]) if (break_on_null_hunk && !hunk) break; if (hunk) { - break_on_null_hunk = 1; char sig[128] = {0}; + break_on_null_hunk = 1; + git_oid_tostr(oid, 10, &hunk->final_commit_id); snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email); diff --git a/examples/cat-file.c b/examples/cat-file.c index fa6add07b..52399fa8a 100644 --- a/examples/cat-file.c +++ b/examples/cat-file.c @@ -42,7 +42,7 @@ static void print_signature(const char *header, const git_signature *sig) static void show_blob(const git_blob *blob) { /* ? Does this need crlf filtering? */ - fwrite(git_blob_rawcontent(blob), git_blob_rawsize(blob), 1, stdout); + fwrite(git_blob_rawcontent(blob), (size_t)git_blob_rawsize(blob), 1, stdout); } /** Show each entry with its type, id and attributes */ diff --git a/examples/common.c b/examples/common.c index 12dbccf59..a066c153c 100644 --- a/examples/common.c +++ b/examples/common.c @@ -156,7 +156,7 @@ int diff_output( const git_diff_line *l, void *p) { - FILE *fp = p; + FILE *fp = (FILE*)p; (void)d; (void)h; diff --git a/examples/general.c b/examples/general.c index ae8756338..235055906 100644 --- a/examples/general.c +++ b/examples/general.c @@ -71,6 +71,43 @@ int main (int argc, char** argv) int error; const char *repo_path = (argc > 1) ? argv[1] : "/opt/libgit2-test/.git"; git_repository *repo; + char* hex; + git_oid oid; + char out[41]; + git_odb* odb; + git_odb_object *obj; + git_otype otype; + const unsigned char *data; + const char *str_type; + git_commit* commit; + const git_signature *author, *cmtter; + const char *message; + time_t ctime; + unsigned int parents, p; + git_oid tree_id, parent_id, commit_id; + git_tree *tree; + git_commit *parent; + git_tag *tag; + const char *tmessage, *tname; + git_otype ttype; + const git_tree_entry *entry; + git_object *objt; + size_t cnt; + git_blob *blob; + git_revwalk *walk; + git_commit *wcommit; + const git_signature *cauth; + const char *cmsg; + git_index *index; + unsigned int i, ecount; + git_strarray ref_list; + const char *refname; + git_reference *ref; + const char *email; + int32_t j; + git_config *cfg; + char config_path[256]; + error = git_repository_open(&repo, repo_path); check_error(error, "opening repository"); @@ -80,12 +117,11 @@ int main (int argc, char** argv) // For our first example, we will convert a 40 character hex value to the // 20 byte raw SHA1 value. printf("*Hex to Raw*\n"); - char hex[] = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"; + hex = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"; // The `git_oid` is the structure that keeps the SHA value. We will use // this throughout the example for storing the value of the current SHA // key we're working with. - git_oid oid; git_oid_fromstr(&oid, hex); // Once we've converted the string into the oid value, we can get the raw @@ -94,7 +130,6 @@ int main (int argc, char** argv) // Next we will convert the 20 byte raw SHA1 value to a human readable 40 // char hex value. printf("\n*Raw to Hex*\n"); - char out[41]; out[40] = '\0'; // If you have a oid, you can easily get the hex value of the SHA as well. @@ -109,16 +144,11 @@ int main (int argc, char** argv) // repository. // // [odb]: http://libgit2.github.com/libgit2/#HEAD/group/odb - git_odb *odb; git_repository_odb(&odb, repo); // #### Raw Object Reading printf("\n*Raw Object Read*\n"); - git_odb_object *obj; - git_otype otype; - const unsigned char *data; - const char *str_type; // We can read raw objects directly from the object database if we have // the oid (SHA) of the object. This allows us to access objects without @@ -177,17 +207,11 @@ int main (int argc, char** argv) printf("\n*Commit Parsing*\n"); - git_commit *commit; git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479"); error = git_commit_lookup(&commit, repo, &oid); check_error(error, "looking up commit"); - const git_signature *author, *cmtter; - const char *message; - time_t ctime; - unsigned int parents, p; - // Each of the properties of the commit object are accessible via methods, // including commonly needed variations, such as `git_commit_time` which // returns the author time and `git_commit_message` which gives you the @@ -229,9 +253,6 @@ int main (int argc, char** argv) // [cd]: http://libgit2.github.com/libgit2/#HEAD/group/commit printf("\n*Commit Writing*\n"); - git_oid tree_id, parent_id, commit_id; - git_tree *tree; - git_commit *parent; // Creating signatures for an authoring identity and time is simple. You // will need to do this to specify who created a commit and when. Default @@ -277,9 +298,6 @@ int main (int argc, char** argv) // // [tm]: http://libgit2.github.com/libgit2/#HEAD/group/tag printf("\n*Tag Parsing*\n"); - git_tag *tag; - const char *tmessage, *tname; - git_otype ttype; // We create an oid for the tag object if we know the SHA and look it up // the same way that we would a commit (or any other object). @@ -310,16 +328,13 @@ int main (int argc, char** argv) // [tp]: http://libgit2.github.com/libgit2/#HEAD/group/tree printf("\n*Tree Parsing*\n"); - const git_tree_entry *entry; - git_object *objt; - // Create the oid and lookup the tree object just like the other objects. git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5"); git_tree_lookup(&tree, repo, &oid); // Getting the count of entries in the tree so you can iterate over them // if you want to. - size_t cnt = git_tree_entrycount(tree); // 3 + cnt = git_tree_entrycount(tree); // 3 printf("tree entries: %d\n", (int)cnt); entry = git_tree_entry_byindex(tree, 0); @@ -351,7 +366,6 @@ int main (int argc, char** argv) // [ba]: http://libgit2.github.com/libgit2/#HEAD/group/blob printf("\n*Blob Parsing*\n"); - git_blob *blob; git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08"); git_blob_lookup(&blob, repo, &oid); @@ -376,8 +390,6 @@ int main (int argc, char** argv) // [rw]: http://libgit2.github.com/libgit2/#HEAD/group/revwalk printf("\n*Revwalking*\n"); - git_revwalk *walk; - git_commit *wcommit; git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644"); @@ -393,9 +405,6 @@ int main (int argc, char** argv) git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE); git_revwalk_push(walk, &oid); - const git_signature *cauth; - const char *cmsg; - // Now that we have the starting point pushed onto the walker, we start // asking for ancestors. It will return them in the sorting order we asked // for as commit oids. We can then lookup and parse the commited pointed @@ -427,9 +436,6 @@ int main (int argc, char** argv) printf("\n*Index Walking*\n"); - git_index *index; - unsigned int i, ecount; - // You can either open the index from the standard location in an open // repository, as we're doing here, or you can open and manipulate any // index file with `git_index_open_bare()`. The index for the repository @@ -465,12 +471,8 @@ int main (int argc, char** argv) // Here we will implement something like `git for-each-ref` simply listing // out all available references and the object SHA they resolve to. - git_strarray ref_list; git_reference_list(&ref_list, repo); - const char *refname; - git_reference *ref; - // Now that we have the list of reference names, we can lookup each ref // one at a time and resolve them to the SHA, then print both values out. for (i = 0; i < ref_list.count; ++i) { @@ -503,13 +505,7 @@ int main (int argc, char** argv) printf("\n*Config Listing*\n"); - const char *email; - int32_t j; - - git_config *cfg; - // Open a config object so we can read global values from it. - char config_path[256]; sprintf(config_path, "%s/config", repo_path); check_error(git_config_open_ondisk(&cfg, config_path), "opening config"); diff --git a/examples/network/clone.c b/examples/network/clone.c index 4df47eb7f..a982c13c2 100644 --- a/examples/network/clone.c +++ b/examples/network/clone.c @@ -22,7 +22,7 @@ static void print_progress(const progress_data *pd) int index_percent = (100*pd->fetch_progress.indexed_objects) / pd->fetch_progress.total_objects; int checkout_percent = pd->total_steps > 0 ? (100 * pd->completed_steps) / pd->total_steps - : 0.f; + : 0; int kbytes = pd->fetch_progress.received_bytes / 1024; if (pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) { diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c index dd9b5e0ed..7e8fcdd92 100644 --- a/src/transports/smart_protocol.c +++ b/src/transports/smart_protocol.c @@ -579,6 +579,10 @@ int git_smart__download_pack( done: if (writepack) writepack->free(writepack); + if (progress_cb) { + t->packetsize_cb = NULL; + t->packetsize_payload = NULL; + } return error; } diff --git a/src/transports/ssh.c b/src/transports/ssh.c index 37f17080a..bece0b45d 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c @@ -53,6 +53,7 @@ static void ssh_error(LIBSSH2_SESSION *session, const char *errmsg) static int gen_proto(git_buf *request, const char *cmd, const char *url) { char *repo; + int len; if (!git__prefixcmp(url, prefix_ssh)) { url = url + strlen(prefix_ssh); @@ -67,7 +68,7 @@ static int gen_proto(git_buf *request, const char *cmd, const char *url) return -1; } - int len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1; + len = strlen(cmd) + 1 /* Space */ + 1 /* Quote */ + strlen(repo) + 1 /* Quote */ + 1; git_buf_grow(request, len); git_buf_printf(request, "%s '%s'", cmd, repo); From 3536c168c354906e2109f49a474f51117fc9b7db Mon Sep 17 00:00:00 2001 From: Miha Date: Tue, 25 Feb 2014 14:57:47 +0100 Subject: [PATCH 2/6] - need_pack was not set to 0 when local fetch was already present causing negotiate_fetch access violation --- src/fetch.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fetch.c b/src/fetch.c index 5bf2b93c1..c7d2c83a1 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -42,8 +42,10 @@ static int maybe_want(git_remote *remote, git_remote_head *head, git_odb *odb, g return 0; /* If we have the object, mark it so we don't ask for it */ - if (git_odb_exists(odb, &head->oid)) + if (git_odb_exists(odb, &head->oid)) { head->local = 1; + remote->need_pack = 0; + } else remote->need_pack = 1; From 0330469f6d0ee51edba84df448359603b79ced55 Mon Sep 17 00:00:00 2001 From: Miha Date: Mon, 3 Mar 2014 11:42:25 +0100 Subject: [PATCH 3/6] - general.c reverted to original( before pr state ) --- examples/general.c | 82 ++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/examples/general.c b/examples/general.c index 235055906..ae8756338 100644 --- a/examples/general.c +++ b/examples/general.c @@ -71,43 +71,6 @@ int main (int argc, char** argv) int error; const char *repo_path = (argc > 1) ? argv[1] : "/opt/libgit2-test/.git"; git_repository *repo; - char* hex; - git_oid oid; - char out[41]; - git_odb* odb; - git_odb_object *obj; - git_otype otype; - const unsigned char *data; - const char *str_type; - git_commit* commit; - const git_signature *author, *cmtter; - const char *message; - time_t ctime; - unsigned int parents, p; - git_oid tree_id, parent_id, commit_id; - git_tree *tree; - git_commit *parent; - git_tag *tag; - const char *tmessage, *tname; - git_otype ttype; - const git_tree_entry *entry; - git_object *objt; - size_t cnt; - git_blob *blob; - git_revwalk *walk; - git_commit *wcommit; - const git_signature *cauth; - const char *cmsg; - git_index *index; - unsigned int i, ecount; - git_strarray ref_list; - const char *refname; - git_reference *ref; - const char *email; - int32_t j; - git_config *cfg; - char config_path[256]; - error = git_repository_open(&repo, repo_path); check_error(error, "opening repository"); @@ -117,11 +80,12 @@ int main (int argc, char** argv) // For our first example, we will convert a 40 character hex value to the // 20 byte raw SHA1 value. printf("*Hex to Raw*\n"); - hex = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"; + char hex[] = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045"; // The `git_oid` is the structure that keeps the SHA value. We will use // this throughout the example for storing the value of the current SHA // key we're working with. + git_oid oid; git_oid_fromstr(&oid, hex); // Once we've converted the string into the oid value, we can get the raw @@ -130,6 +94,7 @@ int main (int argc, char** argv) // Next we will convert the 20 byte raw SHA1 value to a human readable 40 // char hex value. printf("\n*Raw to Hex*\n"); + char out[41]; out[40] = '\0'; // If you have a oid, you can easily get the hex value of the SHA as well. @@ -144,11 +109,16 @@ int main (int argc, char** argv) // repository. // // [odb]: http://libgit2.github.com/libgit2/#HEAD/group/odb + git_odb *odb; git_repository_odb(&odb, repo); // #### Raw Object Reading printf("\n*Raw Object Read*\n"); + git_odb_object *obj; + git_otype otype; + const unsigned char *data; + const char *str_type; // We can read raw objects directly from the object database if we have // the oid (SHA) of the object. This allows us to access objects without @@ -207,11 +177,17 @@ int main (int argc, char** argv) printf("\n*Commit Parsing*\n"); + git_commit *commit; git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479"); error = git_commit_lookup(&commit, repo, &oid); check_error(error, "looking up commit"); + const git_signature *author, *cmtter; + const char *message; + time_t ctime; + unsigned int parents, p; + // Each of the properties of the commit object are accessible via methods, // including commonly needed variations, such as `git_commit_time` which // returns the author time and `git_commit_message` which gives you the @@ -253,6 +229,9 @@ int main (int argc, char** argv) // [cd]: http://libgit2.github.com/libgit2/#HEAD/group/commit printf("\n*Commit Writing*\n"); + git_oid tree_id, parent_id, commit_id; + git_tree *tree; + git_commit *parent; // Creating signatures for an authoring identity and time is simple. You // will need to do this to specify who created a commit and when. Default @@ -298,6 +277,9 @@ int main (int argc, char** argv) // // [tm]: http://libgit2.github.com/libgit2/#HEAD/group/tag printf("\n*Tag Parsing*\n"); + git_tag *tag; + const char *tmessage, *tname; + git_otype ttype; // We create an oid for the tag object if we know the SHA and look it up // the same way that we would a commit (or any other object). @@ -328,13 +310,16 @@ int main (int argc, char** argv) // [tp]: http://libgit2.github.com/libgit2/#HEAD/group/tree printf("\n*Tree Parsing*\n"); + const git_tree_entry *entry; + git_object *objt; + // Create the oid and lookup the tree object just like the other objects. git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5"); git_tree_lookup(&tree, repo, &oid); // Getting the count of entries in the tree so you can iterate over them // if you want to. - cnt = git_tree_entrycount(tree); // 3 + size_t cnt = git_tree_entrycount(tree); // 3 printf("tree entries: %d\n", (int)cnt); entry = git_tree_entry_byindex(tree, 0); @@ -366,6 +351,7 @@ int main (int argc, char** argv) // [ba]: http://libgit2.github.com/libgit2/#HEAD/group/blob printf("\n*Blob Parsing*\n"); + git_blob *blob; git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08"); git_blob_lookup(&blob, repo, &oid); @@ -390,6 +376,8 @@ int main (int argc, char** argv) // [rw]: http://libgit2.github.com/libgit2/#HEAD/group/revwalk printf("\n*Revwalking*\n"); + git_revwalk *walk; + git_commit *wcommit; git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644"); @@ -405,6 +393,9 @@ int main (int argc, char** argv) git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE); git_revwalk_push(walk, &oid); + const git_signature *cauth; + const char *cmsg; + // Now that we have the starting point pushed onto the walker, we start // asking for ancestors. It will return them in the sorting order we asked // for as commit oids. We can then lookup and parse the commited pointed @@ -436,6 +427,9 @@ int main (int argc, char** argv) printf("\n*Index Walking*\n"); + git_index *index; + unsigned int i, ecount; + // You can either open the index from the standard location in an open // repository, as we're doing here, or you can open and manipulate any // index file with `git_index_open_bare()`. The index for the repository @@ -471,8 +465,12 @@ int main (int argc, char** argv) // Here we will implement something like `git for-each-ref` simply listing // out all available references and the object SHA they resolve to. + git_strarray ref_list; git_reference_list(&ref_list, repo); + const char *refname; + git_reference *ref; + // Now that we have the list of reference names, we can lookup each ref // one at a time and resolve them to the SHA, then print both values out. for (i = 0; i < ref_list.count; ++i) { @@ -505,7 +503,13 @@ int main (int argc, char** argv) printf("\n*Config Listing*\n"); + const char *email; + int32_t j; + + git_config *cfg; + // Open a config object so we can read global values from it. + char config_path[256]; sprintf(config_path, "%s/config", repo_path); check_error(git_config_open_ondisk(&cfg, config_path), "opening config"); From 058956ce7f76c0955a8aea77831a22838ec3ede4 Mon Sep 17 00:00:00 2001 From: Miha Date: Mon, 3 Mar 2014 11:47:06 +0100 Subject: [PATCH 4/6] - CMakeLists.txt small fix --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27cf1a558..4ecb81ced 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,7 @@ INCLUDE(CheckLibraryExists) # Build options # -OPTION( SONAME - "Set the (SO)VERSION of the target" ON ) +OPTION( SONAME "Set the (SO)VERSION of the target" ON ) OPTION( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON ) OPTION( THREADSAFE "Build libgit2 as threadsafe" OFF ) OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON ) From 6874cafd84b70f6f83fdcf81e55f87c8d62bb07e Mon Sep 17 00:00:00 2001 From: Miha Date: Mon, 3 Mar 2014 12:08:17 +0100 Subject: [PATCH 5/6] cmake examples change so that general.c is off by default --- CMakeLists.txt | 2 +- examples/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ecb81ced..cca2a120c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ IF(MSVC) # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument. OPTION( WINHTTP "Use Win32 WinHTTP routines" ON ) - ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) + ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS) ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) ENDIF() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 596be45ed..d3908e0ff 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,10 +6,14 @@ ELSE() TARGET_LINK_LIBRARIES(cgit2 git2 pthread) ENDIF() +OPTION( BUILD_EXAMPLES_GENERAL "Build general example" OFF ) + FILE(GLOB SRC_EXAMPLE_APPS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c) FOREACH(src_app ${SRC_EXAMPLE_APPS}) STRING(REPLACE ".c" "" app_name ${src_app}) - IF(NOT ${app_name} STREQUAL "common") + IF(${app_name} STREQUAL "general" AND BUILD_EXAMPLES_GENERAL OR + NOT ${app_name} STREQUAL "general" AND NOT ${app_name} STREQUAL "common" + ) ADD_EXECUTABLE(${app_name} ${src_app} "common.c") TARGET_LINK_LIBRARIES(${app_name} git2) ENDIF() From b43f35fde2fa977870280d685b6e96418b82752e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miha=20Rav=C5=A1elj?= Date: Mon, 3 Mar 2014 14:59:50 +0100 Subject: [PATCH 6/6] - examples CMakeLists.txt reverted to previous state --- examples/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d3908e0ff..596be45ed 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -6,14 +6,10 @@ ELSE() TARGET_LINK_LIBRARIES(cgit2 git2 pthread) ENDIF() -OPTION( BUILD_EXAMPLES_GENERAL "Build general example" OFF ) - FILE(GLOB SRC_EXAMPLE_APPS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.c) FOREACH(src_app ${SRC_EXAMPLE_APPS}) STRING(REPLACE ".c" "" app_name ${src_app}) - IF(${app_name} STREQUAL "general" AND BUILD_EXAMPLES_GENERAL OR - NOT ${app_name} STREQUAL "general" AND NOT ${app_name} STREQUAL "common" - ) + IF(NOT ${app_name} STREQUAL "common") ADD_EXECUTABLE(${app_name} ${src_app} "common.c") TARGET_LINK_LIBRARIES(${app_name} git2) ENDIF()