Skip to content

Commit

Permalink
update libgit2 to mwindow branch as experiment
Browse files Browse the repository at this point in the history
Merge commit '52f15a632bc889c9de387a14ebcdbf7017be8aba' into mwindow
  • Loading branch information
josharian committed Feb 6, 2020
2 parents 387e5ed + 52f15a6 commit 65e6374
Show file tree
Hide file tree
Showing 85 changed files with 4,106 additions and 2,462 deletions.
2 changes: 1 addition & 1 deletion libgit2/README.md
Expand Up @@ -331,7 +331,7 @@ Here are the bindings to libgit2 that are currently available:
* Java
* Jagged <https://github.com/ethomson/jagged>
* Julia
* LibGit2.jl <https://github.com/jakebolewski/LibGit2.jl>
* LibGit2.jl <https://github.com/JuliaLang/julia/tree/master/stdlib/LibGit2>
* Lua
* luagit2 <https://github.com/libgit2/luagit2>
* .NET
Expand Down
17 changes: 13 additions & 4 deletions libgit2/azure-pipelines.yml
Expand Up @@ -19,7 +19,8 @@ jobs:
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Ninja
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
- job: linux_amd64_xenial_gcc_mbedtls
displayName: 'Linux (amd64; Xenial; GCC; mbedTLS)'
Expand All @@ -34,7 +35,8 @@ jobs:
environmentVariables: |
CC=gcc
CMAKE_GENERATOR=Ninja
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
- job: linux_amd64_xenial_clang_openssl
displayName: 'Linux (amd64; Xenial; Clang; OpenSSL)'
Expand All @@ -49,7 +51,8 @@ jobs:
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Ninja
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
- job: linux_amd64_xenial_clang_mbedtls
displayName: 'Linux (amd64; Xenial; Clang; mbedTLS)'
Expand All @@ -64,7 +67,8 @@ jobs:
environmentVariables: |
CC=clang
CMAKE_GENERATOR=Ninja
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DVALGRIND=on -DUSE_GSSAPI=ON
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
- job: macos
displayName: 'macOS'
Expand All @@ -81,6 +85,7 @@ jobs:
CMAKE_GENERATOR: Ninja
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
SKIP_SSH_TESTS: true
GITTEST_NEGOTIATE_PASSWORD: ${{ variables.GITTEST_NEGOTIATE_PASSWORD }}

- job: windows_vs_amd64
displayName: 'Windows (amd64; Visual Studio)'
Expand All @@ -92,6 +97,7 @@ jobs:
CMAKE_GENERATOR: Visual Studio 12 2013 Win64
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true

- job: windows_vs_x86
displayName: 'Windows (x86; Visual Studio)'
Expand All @@ -103,6 +109,7 @@ jobs:
CMAKE_GENERATOR: Visual Studio 12 2013
CMAKE_OPTIONS: -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true

- job: windows_mingw_amd64
displayName: 'Windows (amd64; MinGW)'
Expand All @@ -120,6 +127,7 @@ jobs:
CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true

- job: windows_mingw_x86
displayName: 'Windows (x86; MinGW)'
Expand All @@ -138,6 +146,7 @@ jobs:
CMAKE_GENERATOR: MinGW Makefiles
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
SKIP_SSH_TESTS: true
SKIP_NEGOTIATE_TESTS: true

- job: documentation
displayName: 'Generate Documentation'
Expand Down
4 changes: 3 additions & 1 deletion libgit2/azure-pipelines/docker/xenial
@@ -1,16 +1,18 @@
ARG BASE
FROM $BASE AS apt
RUN apt-get update && \
apt-get install -y --no-install-recommends \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
bzip2 \
clang \
cmake \
curl \
gcc \
git \
gosu \
krb5-user \
libcurl4-gnutls-dev \
libgcrypt20-dev \
libkrb5-dev \
libpcre3-dev \
libssl-dev \
libz-dev \
Expand Down
74 changes: 74 additions & 0 deletions libgit2/azure-pipelines/test.sh
Expand Up @@ -6,6 +6,11 @@ if [ -n "$SKIP_TESTS" ]; then
exit 0
fi

# Windows doesn't run the NTLM tests properly (yet)
if [[ "$(uname -s)" == MINGW* ]]; then
SKIP_NTLM_TESTS=1
fi

SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
TMPDIR=${TMPDIR:-/tmp}
Expand Down Expand Up @@ -89,6 +94,16 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
fi

if [ -z "$SKIP_NTLM_TESTS" ]; then
curl -L https://github.com/ethomson/poxygit/releases/download/v0.4.0/poxygit-0.4.0.jar >poxygit.jar

echo ""
echo "Starting HTTP server..."
NTLM_DIR=`mktemp -d ${TMPDIR}/ntlm.XXXXXXXX`
git init --bare "${NTLM_DIR}/test.git"
java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${NTLM_DIR}" &
fi

if [ -z "$SKIP_SSH_TESTS" ]; then
echo "Starting ssh daemon..."
HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
Expand Down Expand Up @@ -207,6 +222,65 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
unset GITTEST_REMOTE_PROXY_PASS
fi

if [ -z "$SKIP_NTLM_TESTS" ]; then
echo ""
echo "Running NTLM tests (IIS emulation)"
echo ""

export GITTEST_REMOTE_URL="http://localhost:9000/ntlm/test.git"
export GITTEST_REMOTE_USER="foo"
export GITTEST_REMOTE_PASS="baz"
run_test auth_clone_and_push
unset GITTEST_REMOTE_URL
unset GITTEST_REMOTE_USER
unset GITTEST_REMOTE_PASS

echo ""
echo "Running NTLM tests (Apache emulation)"
echo ""

export GITTEST_REMOTE_URL="http://localhost:9000/broken-ntlm/test.git"
export GITTEST_REMOTE_USER="foo"
export GITTEST_REMOTE_PASS="baz"
run_test auth_clone_and_push
unset GITTEST_REMOTE_URL
unset GITTEST_REMOTE_USER
unset GITTEST_REMOTE_PASS
fi

if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
echo ""
echo "Running SPNEGO tests"
echo ""

if [ "$(uname -s)" = "Darwin" ]; then
KINIT_FLAGS="--password-file=STDIN"
fi

echo $GITTEST_NEGOTIATE_PASSWORD | kinit $KINIT_FLAGS test@LIBGIT2.ORG
klist -5f

export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
export GITTEST_REMOTE_DEFAULT="true"
run_test auth_clone
unset GITTEST_REMOTE_URL
unset GITTEST_REMOTE_DEFAULT

echo ""
echo "Running SPNEGO tests (expect/continue)"
echo ""

export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
export GITTEST_REMOTE_DEFAULT="true"
export GITTEST_REMOTE_EXPECTCONTINUE="true"
run_test auth_clone
unset GITTEST_REMOTE_URL
unset GITTEST_REMOTE_DEFAULT
unset GITTEST_REMOTE_EXPECTCONTINUE

kdestroy -A
fi

if [ -z "$SKIP_SSH_TESTS" ]; then
echo ""
echo "Running ssh tests"
Expand Down
2 changes: 1 addition & 1 deletion libgit2/cmake/Modules/SelectGSSAPI.cmake
Expand Up @@ -49,5 +49,5 @@ IF(GSS_BACKEND)
ENDIF()
ELSE()
SET(GIT_GSSAPI 0)
ADD_FEATURE_INFO(SPNEGO NO "")
ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
ENDIF()
14 changes: 7 additions & 7 deletions libgit2/examples/common.c
Expand Up @@ -176,7 +176,7 @@ static int ask(char **out, const char *prompt, char optional)
return 0;
}

int cred_acquire_cb(git_cred **out,
int cred_acquire_cb(git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
Expand All @@ -195,7 +195,7 @@ int cred_acquire_cb(git_cred **out,
goto out;
}

if (allowed_types & GIT_CREDTYPE_SSH_KEY) {
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
int n;

if ((error = ask(&privkey, "SSH Key:", 0)) < 0 ||
Expand All @@ -207,14 +207,14 @@ int cred_acquire_cb(git_cred **out,
(n = snprintf(pubkey, n + 1, "%s.pub", privkey)) < 0)
goto out;

error = git_cred_ssh_key_new(out, username, pubkey, privkey, password);
} else if (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT) {
error = git_credential_ssh_key_new(out, username, pubkey, privkey, password);
} else if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
if ((error = ask(&password, "Password:", 1)) < 0)
goto out;

error = git_cred_userpass_plaintext_new(out, username, password);
} else if (allowed_types & GIT_CREDTYPE_USERNAME) {
error = git_cred_username_new(out, username);
error = git_credential_userpass_plaintext_new(out, username, password);
} else if (allowed_types & GIT_CREDENTIAL_USERNAME) {
error = git_credential_username_new(out, username);
}

out:
Expand Down
2 changes: 1 addition & 1 deletion libgit2/examples/common.h
Expand Up @@ -125,7 +125,7 @@ extern int resolve_refish(git_annotated_commit **commit, git_repository *repo, c
/**
* Acquire credentials via command line
*/
extern int cred_acquire_cb(git_cred **out,
extern int cred_acquire_cb(git_credential **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
Expand Down
2 changes: 1 addition & 1 deletion libgit2/include/git2.h
Expand Up @@ -22,7 +22,7 @@
#include "git2/commit.h"
#include "git2/common.h"
#include "git2/config.h"
#include "git2/cred.h"
#include "git2/credential.h"
#include "git2/deprecated.h"
#include "git2/describe.h"
#include "git2/diff.h"
Expand Down
5 changes: 4 additions & 1 deletion libgit2/include/git2/attr.h
Expand Up @@ -238,8 +238,11 @@ GIT_EXTERN(int) git_attr_foreach(
* disk no longer match the cached contents of memory. This will cause
* the attributes files to be reloaded the next time that an attribute
* access function is called.
*
* @param repo The repository containing the gitattributes cache
* @return 0 on success, or an error code
*/
GIT_EXTERN(void) git_attr_cache_flush(
GIT_EXTERN(int) git_attr_cache_flush(
git_repository *repo);

/**
Expand Down
25 changes: 22 additions & 3 deletions libgit2/include/git2/common.h
Expand Up @@ -117,8 +117,9 @@ GIT_BEGIN_DECL
* @param major Store the major version number
* @param minor Store the minor version number
* @param rev Store the revision (patch) number
* @return 0 on success or an error code on failure
*/
GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
GIT_EXTERN(int) git_libgit2_version(int *major, int *minor, int *rev);

/**
* Combinations of these values describe the features with which libgit2
Expand Down Expand Up @@ -203,7 +204,10 @@ typedef enum {
GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY,
GIT_OPT_GET_PACK_MAX_OBJECTS,
GIT_OPT_SET_PACK_MAX_OBJECTS,
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS
GIT_OPT_DISABLE_PACK_KEEP_FILE_CHECKS,
GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE,
GIT_OPT_GET_MWINDOW_OPEN_LIMIT,
GIT_OPT_SET_MWINDOW_OPEN_LIMIT
} git_libgit2_opt_t;

/**
Expand All @@ -225,7 +229,7 @@ typedef enum {
*
* * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
*
* >Set the maximum amount of memory that can be mapped at any time
* > Set the maximum amount of memory that can be mapped at any time
* by the library
*
* * opts(GIT_OPT_GET_SEARCH_PATH, int level, git_buf *buf)
Expand Down Expand Up @@ -397,6 +401,21 @@ typedef enum {
* > This will cause .keep file existence checks to be skipped when
* > accessing packfiles, which can help performance with remote filesystems.
*
* opts(GIT_OPT_ENABLE_HTTP_EXPECT_CONTINUE, int enabled)
* > When connecting to a server using NTLM or Negotiate
* > authentication, use expect/continue when POSTing data.
* > This option is not available on Windows.
*
* * opts(GIT_OPT_GET_MWINDOW_OPEN_LIMIT, unsigned int *):
*
* > Get the maximum number of files that will be mapped at any time by the library
*
* * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, unsigned int):
*
* > Set the maximum number of files that can be mapped at any time
* by the library
*
*
* @param option Option key
* @param ... value to set the option
* @return 0 on success, <0 on failure
Expand Down
46 changes: 4 additions & 42 deletions libgit2/include/git2/cred_helpers.h
Expand Up @@ -7,47 +7,9 @@
#ifndef INCLUDE_git_cred_helpers_h__
#define INCLUDE_git_cred_helpers_h__

#include "transport.h"

/**
* @file git2/cred_helpers.h
* @brief Utility functions for credential management
* @defgroup git_cred_helpers credential management helpers
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL

/**
* Payload for git_cred_stock_userpass_plaintext.
*/
typedef struct git_cred_userpass_payload {
const char *username;
const char *password;
} git_cred_userpass_payload;


/**
* Stock callback usable as a git_cred_acquire_cb. This calls
* git_cred_userpass_plaintext_new unless the protocol has not specified
* `GIT_CREDTYPE_USERPASS_PLAINTEXT` as an allowed type.
*
* @param cred The newly created credential object.
* @param url The resource for which we are demanding a credential.
* @param user_from_url The username that was embedded in a "user\@host"
* remote url, or NULL if not included.
* @param allowed_types A bitmask stating which cred types are OK to return.
* @param payload The payload provided when specifying this callback. (This is
* interpreted as a `git_cred_userpass_payload*`.)
*/
GIT_EXTERN(int) git_cred_userpass(
git_cred **cred,
const char *url,
const char *user_from_url,
unsigned int allowed_types,
void *payload);

/* These declarations have moved. */
#ifndef GIT_DEPRECATE_HARD
# include "git2/credential_helpers.h"
#endif

/** @} */
GIT_END_DECL
#endif

0 comments on commit 65e6374

Please sign in to comment.