Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions bin/buildlibs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,69 @@ function remove_src {
fi
}

function ensure_libssh2 {
if ! copy_from_package libssh2.a ; then
ensure_musl
ensure_openssl
get_src libssh2 https://github.com/libssh2/libssh2.git
colorln CYAN "Building libssh2"
mkdir -p build
cd build
cmake .. \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DCRYPTO_BACKEND=OpenSSL \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_SSL_LIBRARY=${MY_LIBS}/libssl.a \
-DOPENSSL_CRYPTO_LIBRARY=${MY_LIBS}/libcrypto.a
make -j4
cp src/libssh2.a ${MY_LIBS}
# Copy the public header so libgit2 cmake can find it.
INCLUDE_OUT=${DEPS_DIR}/include
mkdir -p ${INCLUDE_OUT}
cp ../include/libssh2.h ${INCLUDE_OUT}/
if [[ -f ${MY_LIBS}/libssh2.a ]] ; then
echo $(color GREEN Installed libssh2 to:) ${MY_LIBS}/libssh2.a
else
colorln RED "Installation of libssh2 failed!"
exit 1
fi
fi
}

function ensure_libgit2 {
if ! copy_from_package libgit2.a ; then
ensure_musl
ensure_zlib
ensure_openssl
ensure_libssh2
get_src libgit2 https://github.com/libgit2/libgit2.git
colorln CYAN "Building libgit2"
mkdir -p build
cd build
cmake .. \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTS=OFF \
-DUSE_SSH=libssh2 \
-DUSE_HTTPS=OpenSSL \
-DUSE_NTLMCLIENT=OFF \
-DREGEX_BACKEND=builtin \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_SSL_LIBRARY=${MY_LIBS}/libssl.a \
-DOPENSSL_CRYPTO_LIBRARY=${MY_LIBS}/libcrypto.a \
-DLIBSSH2_INCLUDE_DIR=${DEPS_DIR}/include \
-DLIBSSH2_LIBRARY=${MY_LIBS}/libssh2.a
make -j4
cp libgit2.a ${MY_LIBS}
if [[ -f ${MY_LIBS}/libgit2.a ]] ; then
echo $(color GREEN Installed libgit2 to:) ${MY_LIBS}/libgit2.a
else
colorln RED "Installation of libgit2 failed!"
exit 1
fi
fi
}

ensure_musl
ensure_kernel_headers
ensure_openssl
Expand All @@ -347,6 +410,8 @@ ensure_hatrack
ensure_ffi
ensure_sodium
ensure_zlib
ensure_libssh2
ensure_libgit2

colorln GREEN All dependencies satisfied.
remove_src
Binary file added files/deps/lib/linux-amd64/libgit2.a
Binary file not shown.
Binary file added files/deps/lib/linux-amd64/libssh2.a
Binary file not shown.
Binary file added files/deps/lib/linux-arm64/libgit2.a
Binary file not shown.
Binary file added files/deps/lib/linux-arm64/libssh2.a
Binary file not shown.
Binary file added files/deps/lib/macosx-arm64/libgit2.a
Binary file not shown.
Binary file added files/deps/lib/macosx-arm64/libssh2.a
Binary file not shown.
74 changes: 74 additions & 0 deletions nimutils/c/git2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/

#ifndef INCLUDE_git_git_h__
#define INCLUDE_git_git_h__

#include "git2/annotated_commit.h"
#include "git2/apply.h"
#include "git2/attr.h"
#include "git2/blob.h"
#include "git2/blame.h"
#include "git2/branch.h"
#include "git2/buffer.h"
#include "git2/cert.h"
#include "git2/checkout.h"
#include "git2/cherrypick.h"
#include "git2/clone.h"
#include "git2/commit.h"
#include "git2/common.h"
#include "git2/config.h"
#include "git2/credential.h"
#include "git2/deprecated.h"
#include "git2/describe.h"
#include "git2/diff.h"
#include "git2/email.h"
#include "git2/errors.h"
#include "git2/experimental.h"
#include "git2/filter.h"
#include "git2/global.h"
#include "git2/graph.h"
#include "git2/ignore.h"
#include "git2/index.h"
#include "git2/indexer.h"
#include "git2/mailmap.h"
#include "git2/merge.h"
#include "git2/message.h"
#include "git2/net.h"
#include "git2/notes.h"
#include "git2/object.h"
#include "git2/odb.h"
#include "git2/odb_backend.h"
#include "git2/oid.h"
#include "git2/pack.h"
#include "git2/patch.h"
#include "git2/pathspec.h"
#include "git2/proxy.h"
#include "git2/rebase.h"
#include "git2/refdb.h"
#include "git2/reflog.h"
#include "git2/refs.h"
#include "git2/refspec.h"
#include "git2/remote.h"
#include "git2/repository.h"
#include "git2/reset.h"
#include "git2/revert.h"
#include "git2/revparse.h"
#include "git2/revwalk.h"
#include "git2/signature.h"
#include "git2/stash.h"
#include "git2/status.h"
#include "git2/submodule.h"
#include "git2/tag.h"
#include "git2/transport.h"
#include "git2/transaction.h"
#include "git2/tree.h"
#include "git2/types.h"
#include "git2/version.h"
#include "git2/worktree.h"

#endif
132 changes: 132 additions & 0 deletions nimutils/c/git2/annotated_commit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_annotated_commit_h__
#define INCLUDE_git_annotated_commit_h__

#include "common.h"
#include "repository.h"
#include "types.h"

/**
* @file git2/annotated_commit.h
* @brief A commit and information about how it was looked up by the user.
* @defgroup git_annotated_commit Git annotated commit routines
* @ingroup Git
*
* An "annotated commit" is a commit that contains information about
* how the commit was resolved, which can be used for maintaining the
* user's "intent" through commands like merge and rebase. For example,
* if a user wants to "merge HEAD" then an annotated commit is used to
* both contain the HEAD commit _and_ the fact that it was resolved as
* the HEAD ref.
* @{
*/
GIT_BEGIN_DECL

/**
* Creates a `git_annotated_commit` from the given reference.
* The resulting git_annotated_commit must be freed with
* `git_annotated_commit_free`.
*
* @param[out] out pointer to store the git_annotated_commit result in
* @param repo repository that contains the given reference
* @param ref reference to use to lookup the git_annotated_commit
* @return 0 on success or error code
*/
GIT_EXTERN(int) git_annotated_commit_from_ref(
git_annotated_commit **out,
git_repository *repo,
const git_reference *ref);

/**
* Creates a `git_annotated_commit` from the given fetch head data.
* The resulting git_annotated_commit must be freed with
* `git_annotated_commit_free`.
*
* @param[out] out pointer to store the git_annotated_commit result in
* @param repo repository that contains the given commit
* @param branch_name name of the (remote) branch
* @param remote_url url of the remote
* @param id the commit object id of the remote branch
* @return 0 on success or error code
*/
GIT_EXTERN(int) git_annotated_commit_from_fetchhead(
git_annotated_commit **out,
git_repository *repo,
const char *branch_name,
const char *remote_url,
const git_oid *id);

/**
* Creates a `git_annotated_commit` from the given commit id.
* The resulting git_annotated_commit must be freed with
* `git_annotated_commit_free`.
*
* An annotated commit contains information about how it was
* looked up, which may be useful for functions like merge or
* rebase to provide context to the operation. For example,
* conflict files will include the name of the source or target
* branches being merged. It is therefore preferable to use the
* most specific function (eg `git_annotated_commit_from_ref`)
* instead of this one when that data is known.
*
* @param[out] out pointer to store the git_annotated_commit result in
* @param repo repository that contains the given commit
* @param id the commit object id to lookup
* @return 0 on success or error code
*/
GIT_EXTERN(int) git_annotated_commit_lookup(
git_annotated_commit **out,
git_repository *repo,
const git_oid *id);

/**
* Creates a `git_annotated_commit` from a revision string.
*
* See `man gitrevisions`, or
* http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions for
* information on the syntax accepted.
*
* @param[out] out pointer to store the git_annotated_commit result in
* @param repo repository that contains the given commit
* @param revspec the extended sha syntax string to use to lookup the commit
* @return 0 on success or error code
*/
GIT_EXTERN(int) git_annotated_commit_from_revspec(
git_annotated_commit **out,
git_repository *repo,
const char *revspec);

/**
* Gets the commit ID that the given `git_annotated_commit` refers to.
*
* @param commit the given annotated commit
* @return commit id
*/
GIT_EXTERN(const git_oid *) git_annotated_commit_id(
const git_annotated_commit *commit);

/**
* Get the refname that the given `git_annotated_commit` refers to.
*
* @param commit the given annotated commit
* @return ref name.
*/
GIT_EXTERN(const char *) git_annotated_commit_ref(
const git_annotated_commit *commit);

/**
* Frees a `git_annotated_commit`.
*
* @param commit annotated commit to free
*/
GIT_EXTERN(void) git_annotated_commit_free(
git_annotated_commit *commit);

/** @} */
GIT_END_DECL
#endif
Loading
Loading