mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 21:59:33 +00:00
- 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
This commit is contained in:
parent
cb81c3a764
commit
300f44125a
@ -21,7 +21,8 @@ INCLUDE(CheckLibraryExists)
|
|||||||
|
|
||||||
# Build options
|
# 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( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON )
|
||||||
OPTION( THREADSAFE "Build libgit2 as threadsafe" OFF )
|
OPTION( THREADSAFE "Build libgit2 as threadsafe" OFF )
|
||||||
OPTION( BUILD_CLAR "Build Tests using the Clar suite" ON )
|
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
|
# By default, libgit2 is built with WinHTTP. To use the built-in
|
||||||
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
|
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
|
||||||
OPTION( WINHTTP "Use Win32 WinHTTP routines" ON )
|
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()
|
ENDIF()
|
||||||
|
|
||||||
# This variable will contain the libraries we need to put into
|
# This variable will contain the libraries we need to put into
|
||||||
|
@ -78,7 +78,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
|
|||||||
git_status_t status;
|
git_status_t status;
|
||||||
(void)matched_pathspec;
|
(void)matched_pathspec;
|
||||||
|
|
||||||
if (git_status_file(&status, p.repo, path)) {
|
if (git_status_file((unsigned int*)(&status), p.repo, path)) {
|
||||||
return -1; //abort
|
return -1; //abort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +105,9 @@ int main(int argc, char *argv[])
|
|||||||
if (break_on_null_hunk && !hunk) break;
|
if (break_on_null_hunk && !hunk) break;
|
||||||
|
|
||||||
if (hunk) {
|
if (hunk) {
|
||||||
break_on_null_hunk = 1;
|
|
||||||
char sig[128] = {0};
|
char sig[128] = {0};
|
||||||
|
break_on_null_hunk = 1;
|
||||||
|
|
||||||
|
|
||||||
git_oid_tostr(oid, 10, &hunk->final_commit_id);
|
git_oid_tostr(oid, 10, &hunk->final_commit_id);
|
||||||
snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email);
|
snprintf(sig, 30, "%s <%s>", hunk->final_signature->name, hunk->final_signature->email);
|
||||||
|
@ -42,7 +42,7 @@ static void print_signature(const char *header, const git_signature *sig)
|
|||||||
static void show_blob(const git_blob *blob)
|
static void show_blob(const git_blob *blob)
|
||||||
{
|
{
|
||||||
/* ? Does this need crlf filtering? */
|
/* ? 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 */
|
/** Show each entry with its type, id and attributes */
|
||||||
|
@ -156,7 +156,7 @@ int diff_output(
|
|||||||
const git_diff_line *l,
|
const git_diff_line *l,
|
||||||
void *p)
|
void *p)
|
||||||
{
|
{
|
||||||
FILE *fp = p;
|
FILE *fp = (FILE*)p;
|
||||||
|
|
||||||
(void)d; (void)h;
|
(void)d; (void)h;
|
||||||
|
|
||||||
|
@ -71,6 +71,43 @@ int main (int argc, char** argv)
|
|||||||
int error;
|
int error;
|
||||||
const char *repo_path = (argc > 1) ? argv[1] : "/opt/libgit2-test/.git";
|
const char *repo_path = (argc > 1) ? argv[1] : "/opt/libgit2-test/.git";
|
||||||
git_repository *repo;
|
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);
|
error = git_repository_open(&repo, repo_path);
|
||||||
check_error(error, "opening repository");
|
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
|
// For our first example, we will convert a 40 character hex value to the
|
||||||
// 20 byte raw SHA1 value.
|
// 20 byte raw SHA1 value.
|
||||||
printf("*Hex to Raw*\n");
|
printf("*Hex to Raw*\n");
|
||||||
char hex[] = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045";
|
hex = "4a202b346bb0fb0db7eff3cffeb3c70babbd2045";
|
||||||
|
|
||||||
// The `git_oid` is the structure that keeps the SHA value. We will use
|
// 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
|
// this throughout the example for storing the value of the current SHA
|
||||||
// key we're working with.
|
// key we're working with.
|
||||||
git_oid oid;
|
|
||||||
git_oid_fromstr(&oid, hex);
|
git_oid_fromstr(&oid, hex);
|
||||||
|
|
||||||
// Once we've converted the string into the oid value, we can get the raw
|
// 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
|
// Next we will convert the 20 byte raw SHA1 value to a human readable 40
|
||||||
// char hex value.
|
// char hex value.
|
||||||
printf("\n*Raw to Hex*\n");
|
printf("\n*Raw to Hex*\n");
|
||||||
char out[41];
|
|
||||||
out[40] = '\0';
|
out[40] = '\0';
|
||||||
|
|
||||||
// If you have a oid, you can easily get the hex value of the SHA as well.
|
// 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.
|
// repository.
|
||||||
//
|
//
|
||||||
// [odb]: http://libgit2.github.com/libgit2/#HEAD/group/odb
|
// [odb]: http://libgit2.github.com/libgit2/#HEAD/group/odb
|
||||||
git_odb *odb;
|
|
||||||
git_repository_odb(&odb, repo);
|
git_repository_odb(&odb, repo);
|
||||||
|
|
||||||
// #### Raw Object Reading
|
// #### Raw Object Reading
|
||||||
|
|
||||||
printf("\n*Raw Object Read*\n");
|
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
|
// 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
|
// 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");
|
printf("\n*Commit Parsing*\n");
|
||||||
|
|
||||||
git_commit *commit;
|
|
||||||
git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479");
|
git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479");
|
||||||
|
|
||||||
error = git_commit_lookup(&commit, repo, &oid);
|
error = git_commit_lookup(&commit, repo, &oid);
|
||||||
check_error(error, "looking up commit");
|
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,
|
// Each of the properties of the commit object are accessible via methods,
|
||||||
// including commonly needed variations, such as `git_commit_time` which
|
// including commonly needed variations, such as `git_commit_time` which
|
||||||
// returns the author time and `git_commit_message` which gives you the
|
// 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
|
// [cd]: http://libgit2.github.com/libgit2/#HEAD/group/commit
|
||||||
|
|
||||||
printf("\n*Commit Writing*\n");
|
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
|
// 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
|
// 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
|
// [tm]: http://libgit2.github.com/libgit2/#HEAD/group/tag
|
||||||
printf("\n*Tag Parsing*\n");
|
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
|
// 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).
|
// 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
|
// [tp]: http://libgit2.github.com/libgit2/#HEAD/group/tree
|
||||||
printf("\n*Tree Parsing*\n");
|
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.
|
// Create the oid and lookup the tree object just like the other objects.
|
||||||
git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5");
|
git_oid_fromstr(&oid, "2a741c18ac5ff082a7caaec6e74db3075a1906b5");
|
||||||
git_tree_lookup(&tree, repo, &oid);
|
git_tree_lookup(&tree, repo, &oid);
|
||||||
|
|
||||||
// Getting the count of entries in the tree so you can iterate over them
|
// Getting the count of entries in the tree so you can iterate over them
|
||||||
// if you want to.
|
// 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);
|
printf("tree entries: %d\n", (int)cnt);
|
||||||
|
|
||||||
entry = git_tree_entry_byindex(tree, 0);
|
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
|
// [ba]: http://libgit2.github.com/libgit2/#HEAD/group/blob
|
||||||
|
|
||||||
printf("\n*Blob Parsing*\n");
|
printf("\n*Blob Parsing*\n");
|
||||||
git_blob *blob;
|
|
||||||
|
|
||||||
git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08");
|
git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08");
|
||||||
git_blob_lookup(&blob, repo, &oid);
|
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
|
// [rw]: http://libgit2.github.com/libgit2/#HEAD/group/revwalk
|
||||||
|
|
||||||
printf("\n*Revwalking*\n");
|
printf("\n*Revwalking*\n");
|
||||||
git_revwalk *walk;
|
|
||||||
git_commit *wcommit;
|
|
||||||
|
|
||||||
git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
|
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_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
|
||||||
git_revwalk_push(walk, &oid);
|
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
|
// 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
|
// 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
|
// 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");
|
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
|
// 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
|
// 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
|
// 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
|
// Here we will implement something like `git for-each-ref` simply listing
|
||||||
// out all available references and the object SHA they resolve to.
|
// out all available references and the object SHA they resolve to.
|
||||||
git_strarray ref_list;
|
|
||||||
git_reference_list(&ref_list, repo);
|
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
|
// 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.
|
// one at a time and resolve them to the SHA, then print both values out.
|
||||||
for (i = 0; i < ref_list.count; ++i) {
|
for (i = 0; i < ref_list.count; ++i) {
|
||||||
@ -503,13 +505,7 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
printf("\n*Config Listing*\n");
|
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.
|
// Open a config object so we can read global values from it.
|
||||||
char config_path[256];
|
|
||||||
sprintf(config_path, "%s/config", repo_path);
|
sprintf(config_path, "%s/config", repo_path);
|
||||||
check_error(git_config_open_ondisk(&cfg, config_path), "opening config");
|
check_error(git_config_open_ondisk(&cfg, config_path), "opening config");
|
||||||
|
|
||||||
|
@ -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 index_percent = (100*pd->fetch_progress.indexed_objects) / pd->fetch_progress.total_objects;
|
||||||
int checkout_percent = pd->total_steps > 0
|
int checkout_percent = pd->total_steps > 0
|
||||||
? (100 * pd->completed_steps) / pd->total_steps
|
? (100 * pd->completed_steps) / pd->total_steps
|
||||||
: 0.f;
|
: 0;
|
||||||
int kbytes = pd->fetch_progress.received_bytes / 1024;
|
int kbytes = pd->fetch_progress.received_bytes / 1024;
|
||||||
|
|
||||||
if (pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) {
|
if (pd->fetch_progress.received_objects == pd->fetch_progress.total_objects) {
|
||||||
|
@ -579,6 +579,10 @@ int git_smart__download_pack(
|
|||||||
done:
|
done:
|
||||||
if (writepack)
|
if (writepack)
|
||||||
writepack->free(writepack);
|
writepack->free(writepack);
|
||||||
|
if (progress_cb) {
|
||||||
|
t->packetsize_cb = NULL;
|
||||||
|
t->packetsize_payload = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -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)
|
static int gen_proto(git_buf *request, const char *cmd, const char *url)
|
||||||
{
|
{
|
||||||
char *repo;
|
char *repo;
|
||||||
|
int len;
|
||||||
|
|
||||||
if (!git__prefixcmp(url, prefix_ssh)) {
|
if (!git__prefixcmp(url, prefix_ssh)) {
|
||||||
url = url + strlen(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;
|
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_grow(request, len);
|
||||||
git_buf_printf(request, "%s '%s'", cmd, repo);
|
git_buf_printf(request, "%s '%s'", cmd, repo);
|
||||||
|
Loading…
Reference in New Issue
Block a user