diff -Nru r-cran-git2r-0.21.0/cleanup r-cran-git2r-0.22.1/cleanup --- r-cran-git2r-0.21.0/cleanup 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/cleanup 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,7 @@ #!/bin/sh rm -f config.* +rm -f confdefs.h rm -f src/Makevars rm -rf autom4te.cache rm -f src/*.o @@ -8,6 +9,7 @@ rm -f src/libmygit.a rm -f src/libgit2/src/*.o rm -f src/libgit2/src/hash/*.o +rm -f src/libgit2/src/hash/sha1dc/*.o rm -f src/libgit2/src/streams/*.o rm -f src/libgit2/src/transports/*.o rm -f src/libgit2/src/unix/*.o diff -Nru r-cran-git2r-0.21.0/configure r-cran-git2r-0.22.1/configure --- r-cran-git2r-0.21.0/configure 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/configure 2018-07-10 13:23:34.000000000 +0000 @@ -622,31 +622,29 @@ # include #endif" -ac_subst_vars='LTLIBOBJS -LIBOBJS -PKG_LIBS -PKG_CPPFLAGS -PKG_CFLAGS +ac_subst_vars='PKG_CPPFLAGS GIT2R_SRC_REGEX +EGREP +GREP +CPP LIBCURL LIBCURL_CPPFLAGS _libcurl_config AWK -LTLIBICONV -LIBICONV libssh2_LIBS libssh2_CFLAGS openssl_LIBS openssl_CFLAGS zlib_LIBS zlib_CFLAGS -EGREP -GREP -CPP +LTLIBOBJS +LIBOBJS +PKG_LIBS +PKG_CFLAGS +BREW PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG -BREW OBJEXT EXEEXT ac_ct_CC @@ -703,15 +701,6 @@ ac_subst_files='' ac_user_opts=' enable_option_checking -with_zlib_include -with_zlib_lib -with_libssh2_include -with_libssh2_lib -with_libssl_include -with_libssl_lib -with_gnu_ld -enable_rpath -with_libiconv_prefix with_libcurl ' ac_precious_vars='build_alias @@ -725,13 +714,13 @@ PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR -CPP zlib_CFLAGS zlib_LIBS openssl_CFLAGS openssl_LIBS libssh2_CFLAGS -libssh2_LIBS' +libssh2_LIBS +CPP' # Initialize some variables set by options. @@ -1341,30 +1330,9 @@ esac cat <<\_ACEOF -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-rpath do not hardcode runtime library paths - Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --with-zlib-include=INCLUDE_PATH - the location of the zlib header files - --with-zlib-lib=LIB_PATH - the location of the zlib library - --with-libssh2-include=INCLUDE_PATH - the location of the LibSSH2 header files - --with-libssh2-lib=LIB_PATH - the location of the LibSSH2 library - --with-libssl-include=INCLUDE_PATH - the location of the libssl header files - --with-libssl-lib=LIB_PATH - the location of the libssl library - --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib - --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libcurl=PREFIX look for the curl library in PREFIX/lib and headers in PREFIX/include @@ -1381,7 +1349,6 @@ directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path - CPP C preprocessor zlib_CFLAGS C compiler flags for zlib, overriding pkg-config zlib_LIBS linker flags for zlib, overriding pkg-config openssl_CFLAGS @@ -1392,6 +1359,7 @@ C compiler flags for libssh2, overriding pkg-config libssh2_LIBS linker flags for libssh2, overriding pkg-config + CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1511,299 +1479,6 @@ } # ac_fn_c_try_compile -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES -# -------------------------------------------- -# Tries to find the compile-time value of EXPR in a program that includes -# INCLUDES, setting VAR accordingly. Returns whether the value could be -# computed -ac_fn_c_compute_int () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if test "$cross_compiling" = yes; then - # Depending upon the size, compute the lo and hi bounds. -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=0 ac_mid=0 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid; break -else - as_fn_arith $ac_mid + 1 && ac_lo=$as_val - if test $ac_lo -le $ac_mid; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=-1 ac_mid=-1 - while :; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_lo=$ac_mid; break -else - as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val - if test $ac_mid -le $ac_hi; then - ac_lo= ac_hi= - break - fi - as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - done -else - ac_lo= ac_hi= -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -# Binary search between lo and hi bounds. -while test "x$ac_lo" != "x$ac_hi"; do - as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0; -return test_array [0]; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_hi=$ac_mid -else - as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -done -case $ac_lo in #(( -?*) eval "$3=\$ac_lo"; ac_retval=0 ;; -'') ac_retval=1 ;; -esac - else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -static long int longval () { return $2; } -static unsigned long int ulongval () { return $2; } -#include -#include -int -main () -{ - - FILE *f = fopen ("conftest.val", "w"); - if (! f) - return 1; - if (($2) < 0) - { - long int i = longval (); - if (i != ($2)) - return 1; - fprintf (f, "%ld", i); - } - else - { - unsigned long int i = ulongval (); - if (i != ($2)) - return 1; - fprintf (f, "%lu", i); - } - /* Do not output a trailing newline, as this causes \r\n confusion - on some platforms. */ - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - echo >>conftest.val; read $3 &5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_cpp - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -1973,26 +1648,136 @@ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by git2r $as_me see.DESCRIPTION.file, which was -generated by GNU Autoconf 2.69. Invocation command line was - $ $0 $@ - -_ACEOF -exec 5>>config.log +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () { -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by git2r $as_me see.DESCRIPTION.file, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` @@ -3277,52 +3062,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -## check for brew on OS X - -case "${host_os}" in - darwin*) - # Extract the first word of "brew", so it can be a program name with args. -set dummy brew; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_BREW+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$BREW"; then - ac_cv_prog_BREW="$BREW" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_BREW="yes" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -BREW=$ac_cv_prog_BREW -if test -n "$BREW"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BREW" >&5 -$as_echo "$BREW" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - +## Check for brew on macOS - if test "x${BREW}" = xyes; then - BREW_DIR=`brew --prefix` - fi - ;; -esac # Check for pkg-config @@ -3446,531 +3187,1379 @@ fi fi -# Optional include and library paths +# Check for R +: ${R_HOME=`R RHOME`} +if test -z "${R_HOME}"; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Could not determine R_HOME +See \`config.log' for more details" "$LINENO" 5; } +fi +RBIN="${R_HOME}/bin/R" -# zlib include and library path +# Library settings -# Check whether --with-zlib-include was given. -if test "${with_zlib_include+set}" = set; then : - withval=$with_zlib_include; zlib_include_path=$withval -fi +PKG_CONFIG_NAME="libgit2" +PKG_BREW_NAME="libgit2" +PKG_LIBS="-lgit2" +PKG_CFLAGS="" +# Check if building against bundled libgit2 or system libgit2 +USE_BUNDLED_LIBGIT2=yes +if test "x${INCLUDE_DIR}${LIB_DIR}" = x; then + if test -n "$PKG_CONFIG" ; then + PKGCONFIG_CFLAGS=`"${PKG_CONFIG}" --cflags "${PKG_CONFIG_NAME}"` + PKGCONFIG_LIBS=`"${PKG_CONFIG}" --libs "${PKG_CONFIG_NAME}"` + fi -# Check whether --with-zlib-lib was given. -if test "${with_zlib_lib+set}" = set; then : - withval=$with_zlib_lib; zlib_lib_path=$withval + # Hack for CRAN server: do not use preinstalled libgit2 + CRAN_server=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /Builds/CRAN-QA-Simon" >&5 +$as_echo_n "checking for /Builds/CRAN-QA-Simon... " >&6; } +if ${ac_cv_file__Builds_CRAN_QA_Simon+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "/Builds/CRAN-QA-Simon"; then + ac_cv_file__Builds_CRAN_QA_Simon=yes +else + ac_cv_file__Builds_CRAN_QA_Simon=no fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__Builds_CRAN_QA_Simon" >&5 +$as_echo "$ac_cv_file__Builds_CRAN_QA_Simon" >&6; } +if test "x$ac_cv_file__Builds_CRAN_QA_Simon" = xyes; then : + CRAN_server=yes +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /Volumes/SSD-Data/Builds" >&5 +$as_echo_n "checking for /Volumes/SSD-Data/Builds... " >&6; } +if ${ac_cv_file__Volumes_SSD_Data_Builds+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "/Volumes/SSD-Data/Builds"; then + ac_cv_file__Volumes_SSD_Data_Builds=yes +else + ac_cv_file__Volumes_SSD_Data_Builds=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__Volumes_SSD_Data_Builds" >&5 +$as_echo "$ac_cv_file__Volumes_SSD_Data_Builds" >&6; } +if test "x$ac_cv_file__Volumes_SSD_Data_Builds" = xyes; then : + CRAN_server=yes +fi -# LibSSH2 include and library path - -# Check whether --with-libssh2-include was given. -if test "${with_libssh2_include+set}" = set; then : - withval=$with_libssh2_include; libssh2_include_path=$withval fi + if test "x${CRAN_server}" = xyes; then + unset PKGCONFIG_CFLAGS + unset PKGCONFIG_LIBS + fi + if test "x${PKGCONFIG_CFLAGS}${PKGCONFIG_LIBS}" = x; then + case "${host_os}" in + darwin*) + # Extract the first word of "brew", so it can be a program name with args. +set dummy brew; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_BREW+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$BREW"; then + ac_cv_prog_BREW="$BREW" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_BREW="yes" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -# Check whether --with-libssh2-lib was given. -if test "${with_libssh2_lib+set}" = set; then : - withval=$with_libssh2_lib; libssh2_lib_path=$withval +fi +fi +BREW=$ac_cv_prog_BREW +if test -n "$BREW"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BREW" >&5 +$as_echo "$BREW" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -# libssl include and library path + if test "x${BREW}" = xyes; then + BREWDIR=`brew --prefix` + else + curl -sfL "https://jeroen.github.io/autobrew/${PKG_BREW_NAME}" > autobrew + source autobrew + fi + USE_BUNDLED_LIBGIT2=no + ;; + esac + else + echo "Found pkg-config cflags and libs!" + PKG_CFLAGS="${PKGCONFIG_CFLAGS}" + PKG_LIBS="${PKGCONFIG_LIBS}" + USE_BUNDLED_LIBGIT2=no + fi +else + echo "Found INCLUDE_DIR and/or LIB_DIR!" + PKG_CFLAGS="-I${INCLUDE_DIR} ${PKG_CFLAGS}" + PKG_LIBS="-L${LIB_DIR} ${PKG_LIBS}" + USE_BUNDLED_LIBGIT2=no, +fi + +################# Begin configuration to use system libgit2 ################## +if test "x${USE_BUNDLED_LIBGIT2}" = xno; then + # Find the compiler and compiler flags to use + CC=`"${RBIN}" CMD config CC` + CFLAGS=`"${RBIN}" CMD config CFLAGS` + CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the libgit2 version will work in git2r" >&5 +$as_echo_n "checking whether the libgit2 version will work in git2r... " >&6; } + libgit2_ver_ok=no + ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E tools/version.c >/dev/null 2>&1 && libgit2_ver_ok=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libgit2_ver_ok}" >&5 +$as_echo "${libgit2_ver_ok}" >&6; } + + # For debugging + echo "----- Results of the git2r package configure -----" + echo "" + echo " PKG_CFLAGS: ${PKG_CFLAGS}" + echo " PKG_LIBS: ${PKG_LIBS}" + echo "" + echo "--------------------------------------------------" -# Check whether --with-libssl-include was given. -if test "${with_libssl_include+set}" = set; then : - withval=$with_libssl_include; libssl_include_path=$withval -fi + if test "x${libgit2_ver_ok}" = xno; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? " + --------------------------------------------- + The libgit2 library that is required to build git2r was not found. + Please install: + libgit2-dev (package on e.g. Debian and Ubuntu) + libgit2-devel (package on e.g. Fedora, CentOS and RHEL) + libgit2 (Homebrew package on macOS) + and try again. + If the libgit2 library is installed on your system but the git2r configuration is + unable to find it, you can specify the include and lib path to libgit2 with: + R CMD INSTALL git2r --configure-vars='INCLUDE_DIR=path/to/include LIB_DIR=path/to/lib' + --------------------------------------------- +See \`config.log' for more details" "$LINENO" 5; } + fi -# Check whether --with-libssl-lib was given. -if test "${with_libssl_lib+set}" = set; then : - withval=$with_libssl_lib; libssl_lib_path=$withval -fi + PKG_CFLAGS="${PKG_CFLAGS}" + PKG_LIBS="${PKG_LIBS}" -# Find the compiler and compiler flags to use -: ${R_HOME=`R RHOME`} -if test -z "${R_HOME}"; then - echo "could not determine R_HOME" - exit 1 -fi -RBIN="${R_HOME}/bin/R" -CC=`"${RBIN}" CMD config CC` -CFLAGS=`"${RBIN}" CMD config CFLAGS` -CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` -CPICFLAGS=`"${RBIN}" CMD config CPICFLAGS` + ac_config_files="$ac_config_files src/Makevars" -# Determine architecture of the machine -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 + cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by git2r $as_me see.DESCRIPTION.file, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +git2r config.status see.DESCRIPTION.file +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : -else - # Broken: fails on valid input. -continue +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" fi -rm -f conftest.err conftest.i conftest.$ac_ext - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' else - # Passes both tests. -ac_preproc_ok=: -break + ac_cs_awk_cr=$ac_cr fi -rm -f conftest.err conftest.i conftest.$ac_ext -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } - done - ac_cv_prog_CPP=$CPP + print line +} -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer to if __STDC__ is defined, since - # exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include -#else -# include -#endif - Syntax error +_ACAWK _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +eval set X " :F $CONFIG_FILES " +shift +for ac_tag do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift - $ac_path_GREP_found && break 3 + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#include -#include + case $ac_mode in + :F) + # + # CONFIG_FILE + # -int -main () -{ +_ACEOF - ; - return 0; +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q } +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub _ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then -$as_echo "#define STDC_HEADERS 1" >>confdefs.h -fi + esac -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF +done # for ac_tag -fi -done +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 -# The cast to long int works around a bug in the HP C Compiler -# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects -# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. -# This bug is HP SR number 8606223364. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void*" >&5 -$as_echo_n "checking size of void*... " >&6; } -if ${ac_cv_sizeof_voidp+:} false; then : - $as_echo_n "(cached) " >&6 -else - if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void*))" "ac_cv_sizeof_voidp" "$ac_includes_default"; then : -else - if test "$ac_cv_type_voidp" = yes; then - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot compute sizeof (void*) -See \`config.log' for more details" "$LINENO" 5; } - else - ac_cv_sizeof_voidp=0 - fi +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 fi - +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_voidp" >&5 -$as_echo "$ac_cv_sizeof_voidp" >&6; } +fi +################# End configuration to use system libgit2 #################### +################# Begin configuration to build bundled libgit2 ############### +if test "x${USE_BUNDLED_LIBGIT2}" = xyes; then -cat >>confdefs.h <<_ACEOF -#define SIZEOF_VOIDP $ac_cv_sizeof_voidp -_ACEOF +{ $as_echo "$as_me:${as_lineno-$LINENO}: Attempting configuration of bundled libgit2" >&5 +$as_echo "$as_me: Attempting configuration of bundled libgit2" >&6;} +# Find the compiler and compiler flags to use +CC=`"${RBIN}" CMD config CC` +CFLAGS=`"${RBIN}" CMD config CFLAGS` +CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` -if test "x$ac_cv_sizeof_voidp" = "x8"; then +# Use R to determine architecture of the machine +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void*" >&5 +$as_echo_n "checking size of void*... " >&6; } +sizeof_voidp=`"${RBIN}" --slave --vanilla -e "cat(.Machine\\$sizeof.pointer)"` +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sizeof_voidp" >&5 +$as_echo "$sizeof_voidp" >&6; } +if test "x$sizeof_voidp" = "x8"; then CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_64" -elif test "x$ac_cv_sizeof_voidp" = "x4"; then +elif test "x$sizeof_voidp" = "x4"; then CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_32" else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void*" >&5 -$as_echo_n "checking size of void*... " >&6; } - sizeof_voidp=`"${RBIN}" --slave -e "cat(.Machine\\$sizeof.pointer)"` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sizeof_voidp" >&5 -$as_echo "$sizeof_voidp" >&6; } - if test "x$sizeof_voidp" = "x8"; then - CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_64" - elif test "x$sizeof_voidp" = "x4"; then - CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_32" - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Unsupported architecture See \`config.log' for more details" "$LINENO" 5; } - fi fi # Check for zlib have_zlib=no -# Check for optional zlib include path -if test -n "$zlib_include_path" ; then - CPPFLAGS="-I${zlib_include_path} ${CPPFLAGS}" -fi - -# Check for optional zlib lib path -if test -n "$zlib_lib_path" ; then - LIBS="-L${zlib_lib_path} ${LIBS}" -fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inflate" >&5 $as_echo_n "checking for library containing inflate... " >&6; } @@ -4124,7 +4713,7 @@ system but the git2r configuration is unable to find it, you can specify the include and lib path to zlib with: - R CMD INSTALL --configure-args='--with-zlib-include=INCLUDE_PATH --with-zlib-lib=LIB_PATH' git2r + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' --------------------------------------------- See \`config.log' for more details" "$LINENO" 5; } fi @@ -4132,30 +4721,10 @@ # Check for SSL have_ssl=no -# Check for optional libssl include path -if test -n "$libssl_include_path" ; then - CPPFLAGS="-I${libssl_include_path} ${CPPFLAGS}" -fi - -# Check for optional libssl lib path -if test -n "$libssl_lib_path" ; then - LIBS="-L${libssl_lib_path} ${LIBS}" -fi - if test "x${OPENSSL_INCLUDES}" = x; then :; else CPPFLAGS="${CPPFLAGS} -I${OPENSSL_INCLUDES}" fi -# On OS X, add path to libssl in brew -case "${host_os}" in - darwin*) - if test "x${BREW}" = xyes; then - CPPFLAGS="${CPPFLAGS} -I${BREW_DIR}/opt/openssl/include" - LIBS="${LIBS} -L${BREW_DIR}/opt/openssl/lib" - fi - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing EVP_EncryptInit" >&5 $as_echo_n "checking for library containing EVP_EncryptInit... " >&6; } if ${ac_cv_search_EVP_EncryptInit+:} false; then : @@ -4413,129 +4982,20 @@ Please install: libssl-dev (package on e.g. Debian and Ubuntu) openssl-devel (package on e.g. Fedora, CentOS and RHEL) - openssl (Homebrew package on OS X) and try again. If the OpenSSL library is installed on your system but the git2r configuration is unable to find it, you can specify the include and lib path to OpenSSL with: - R CMD INSTALL --configure-args='--with-libssl-include=INCLUDE_PATH --with-libssl-lib=LIB_PATH' git2r + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' --------------------------------------------- See \`config.log' for more details" "$LINENO" 5; } fi # Check for LibSSH2 have_ssh2=no - -# Check for optional libssh2 include path -if test -n "$libssh2_include_path" ; then - CPPFLAGS="-I${libssh2_include_path} ${CPPFLAGS}" -fi - -# Check for optional libssh2 lib path -if test -n "$libssh2_lib_path" ; then - LIBS="-L${libssh2_lib_path} ${LIBS}" -fi - -case "${host_os}" in - darwin*) - # Save flags - oCPPFLAGS="${CPPFLAGS}" - oLIBS="${LIBS}" - - # On OS X, try to find libssh2 in brew - if test "x${BREW}" = xyes; then - CPPFLAGS="${CPPFLAGS} -I${BREW_DIR}/opt/libssh2/include" - LIBS="${LIBS} -L${BREW_DIR}/opt/libssh2/lib" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing libssh2_version" >&5 -$as_echo_n "checking for library containing libssh2_version... " >&6; } -if ${ac_cv_search_libssh2_version+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char libssh2_version (); -int -main () -{ -return libssh2_version (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ssh2; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_libssh2_version=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_libssh2_version+:} false; then : - break -fi -done -if ${ac_cv_search_libssh2_version+:} false; then : - -else - ac_cv_search_libssh2_version=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_libssh2_version" >&5 -$as_echo "$ac_cv_search_libssh2_version" >&6; } -ac_res=$ac_cv_search_libssh2_version -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - have_ssh2=yes -fi - - fi - - if test "x${have_ssh2}" = xno; then - CPPFLAGS="${oCPPFLAGS}" - LIBS="${oLIBS}" - - { $as_echo "$as_me:${as_lineno-$LINENO}: Download and build libssh2" >&5 -$as_echo "$as_me: Download and build libssh2" >&6;} - - mkdir -p libssh2 && \ - curl -fsSL https://www.libssh2.org/download/libssh2-1.8.0.tar.gz | \ - tar xz --strip 1 -C libssh2 - - mkdir -p src/libgit2/deps/libssh2 - LIBSSH2_INST_DIR="${PWD}/src/libgit2/deps/libssh2" - cp -f tools/missing libssh2 - cd libssh2 - ./configure --with-pic --with-openssl --disable-examples-build \ - --disable-shared --enable-static --prefix=$LIBSSH2_INST_DIR \ - CC="${CC}" CFLAGS="${CFLAGS} ${CPICFLAGS} -Wno-deprecated-declarations" \ - CPPFLAGS="${CPPFLAGS}" && make && make install && have_ssh2=yes - cd .. - rm -rf libssh2 - - if test "x${have_ssh2}" = xyes; then - LIBSSH2_CFLAGS="-Ilibgit2/deps/libssh2/include" - LIBSSH2_LIBS="-Llibgit2/deps/libssh2/lib -lssh2" - fi - fi - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing libssh2_version" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing libssh2_version" >&5 $as_echo_n "checking for library containing libssh2_version... " >&6; } if ${ac_cv_search_libssh2_version+:} false; then : $as_echo_n "(cached) " >&6 @@ -4591,8 +5051,6 @@ have_ssh2=yes fi - ;; -esac if test "x${have_ssh2}" = xno; then if test -n "$PKG_CONFIG" ; then @@ -4682,14 +5140,13 @@ To build with SSH support, please install: libssh2-1-dev (package on e.g. Debian and Ubuntu) libssh2-devel (package on e.g. Fedora, CentOS and RHEL) - libssh2 (Homebrew package on OS X) and try again. If the LibSSH2 library is installed on your system but the git2r configuration is unable to find it, you can specify the include and lib path to LibSSH2 with: - R CMD INSTALL --configure-args='--with-libssh2-include=INCLUDE_PATH --with-libssh2-lib=LIB_PATH' git2r + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' ---------------------------------------------" >&5 $as_echo "$as_me: WARNING: --------------------------------------------- @@ -4698,256 +5155,19 @@ for SSH transport. To build with SSH support, please install: - libssh2-1-dev (package on e.g. Debian and Ubuntu) - libssh2-devel (package on e.g. Fedora, CentOS and RHEL) - libssh2 (Homebrew package on OS X) - and try again. - - If the LibSSH2 library is installed on - your system but the git2r configuration - is unable to find it, you can specify - the include and lib path to LibSSH2 with: - R CMD INSTALL --configure-args='--with-libssh2-include=INCLUDE_PATH --with-libssh2-lib=LIB_PATH' git2r - ---------------------------------------------" >&2;} -fi - -# Check for iconv -have_iconv=no -case "${host_os}" in - darwin*) - - if test "X$prefix" = "XNONE"; then - acl_final_prefix="$ac_default_prefix" - else - acl_final_prefix="$prefix" - fi - if test "X$exec_prefix" = "XNONE"; then - acl_final_exec_prefix='${prefix}' - else - acl_final_exec_prefix="$exec_prefix" - fi - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" - prefix="$acl_save_prefix" - - - -# Check whether --with-gnu-ld was given. -if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes -else - with_gnu_ld=no -fi - -# Prepare PATH_SEPARATOR. -# The user is always right. -if test "${PATH_SEPARATOR+set}" != set; then - # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which - # contains only /bin. Note that ksh looks also at the FPATH variable, - # so we have to set that as well for the test. - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ - || PATH_SEPARATOR=';' - } -fi - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 -$as_echo_n "checking for ld used by $CC... " >&6; } - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [\\/]* | ?:[\\/]*) - re_direlt='/[^/][^/]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` - while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do - ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 -$as_echo_n "checking for GNU ld... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 -$as_echo_n "checking for non-GNU ld... " >&6; } -fi -if ${acl_cv_path_LD+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$LD"; then - acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$acl_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - acl_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$acl_cv_path_LD" -v 2>&1 &5 -$as_echo "$LD" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi -test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if ${acl_cv_prog_gnu_ld+:} false; then : - $as_echo_n "(cached) " >&6 -else - # I'd rather use --version here, but apparently some GNU lds only accept -v. -case `$LD -v 2>&1 &5 -$as_echo "$acl_cv_prog_gnu_ld" >&6; } -with_gnu_ld=$acl_cv_prog_gnu_ld - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 -$as_echo_n "checking for shared library run path origin... " >&6; } -if ${acl_cv_rpath+:} false; then : - $as_echo_n "(cached) " >&6 -else - - CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ - ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh - . ./conftest.sh - rm -f ./conftest.sh - acl_cv_rpath=done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 -$as_echo "$acl_cv_rpath" >&6; } - wl="$acl_cv_wl" - acl_libext="$acl_cv_libext" - acl_shlibext="$acl_cv_shlibext" - acl_libname_spec="$acl_cv_libname_spec" - acl_library_names_spec="$acl_cv_library_names_spec" - acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" - acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" - acl_hardcode_direct="$acl_cv_hardcode_direct" - acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" - # Check whether --enable-rpath was given. -if test "${enable_rpath+set}" = set; then : - enableval=$enable_rpath; : -else - enable_rpath=yes -fi - - - - - acl_libdirstem=lib - acl_libdirstem2= - case "$host_os" in - solaris*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 -$as_echo_n "checking for 64-bit host... " >&6; } -if ${gl_cv_solaris_64bit+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#ifdef _LP64 -sixtyfour bits -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "sixtyfour bits" >/dev/null 2>&1; then : - gl_cv_solaris_64bit=yes -else - gl_cv_solaris_64bit=no -fi -rm -f conftest* - - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 -$as_echo "$gl_cv_solaris_64bit" >&6; } - if test $gl_cv_solaris_64bit = yes; then - acl_libdirstem=lib/64 - case "$host_cpu" in - sparc*) acl_libdirstem2=lib/sparcv9 ;; - i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; - esac - fi - ;; - *) - searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` - if test -n "$searchpath"; then - acl_save_IFS="${IFS= }"; IFS=":" - for searchdir in $searchpath; do - if test -d "$searchdir"; then - case "$searchdir" in - */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; - */../ | */.. ) - # Better ignore directories of this form. They are misleading. - ;; - *) searchdir=`cd "$searchdir" && pwd` - case "$searchdir" in - */lib64 ) acl_libdirstem=lib64 ;; - esac ;; - esac - fi - done - IFS="$acl_save_IFS" - fi - ;; - esac - test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + libssh2-1-dev (package on e.g. Debian and Ubuntu) + libssh2-devel (package on e.g. Fedora, CentOS and RHEL) + and try again. + If the LibSSH2 library is installed on + your system but the git2r configuration + is unable to find it, you can specify + the include and lib path to LibSSH2 with: + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' + ---------------------------------------------" >&2;} +fi +# Check for libcurl @@ -4958,1353 +5178,944 @@ - use_additional=yes - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" -# Check whether --with-libiconv-prefix was given. -if test "${with_libiconv_prefix+set}" = set; then : - withval=$with_libiconv_prefix; - if test "X$withval" = "Xno"; then - use_additional=no - else - if test "X$withval" = "X"; then - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval additional_includedir=\"$includedir\" - eval additional_libdir=\"$libdir\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - else - additional_includedir="$withval/include" - additional_libdir="$withval/$acl_libdirstem" - if test "$acl_libdirstem2" != "$acl_libdirstem" \ - && ! test -d "$withval/$acl_libdirstem"; then - additional_libdir="$withval/$acl_libdirstem2" - fi - fi - fi -fi - LIBICONV= - LTLIBICONV= - INCICONV= - LIBICONV_PREFIX= - HAVE_LIBICONV= - rpathdirs= - ltrpathdirs= - names_already_handled= - names_next_round='iconv ' - while test -n "$names_next_round"; do - names_this_round="$names_next_round" - names_next_round= - for name in $names_this_round; do - already_handled= - for n in $names_already_handled; do - if test "$n" = "$name"; then - already_handled=yes - break - fi - done - if test -z "$already_handled"; then - names_already_handled="$names_already_handled $name" - uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` - eval value=\"\$HAVE_LIB$uppername\" - if test -n "$value"; then - if test "$value" = yes; then - eval value=\"\$LIB$uppername\" - test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" - eval value=\"\$LTLIB$uppername\" - test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" - else - : - fi - else - found_dir= - found_la= - found_so= - found_a= - eval libname=\"$acl_libname_spec\" # typically: libname=lib$name - if test -n "$acl_shlibext"; then - shrext=".$acl_shlibext" # typically: shrext=.so - else - shrext= - fi - if test $use_additional = yes; then - dir="$additional_libdir" - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - fi - if test "X$found_dir" = "X"; then - for x in $LDFLAGS $LTLIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - case "$x" in - -L*) - dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$acl_shlibext"; then - if test -f "$dir/$libname$shrext"; then - found_dir="$dir" - found_so="$dir/$libname$shrext" - else - if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then - ver=`(cd "$dir" && \ - for f in "$libname$shrext".*; do echo "$f"; done \ - | sed -e "s,^$libname$shrext\\\\.,," \ - | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ - | sed 1q ) 2>/dev/null` - if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then - found_dir="$dir" - found_so="$dir/$libname$shrext.$ver" - fi - else - eval library_names=\"$acl_library_names_spec\" - for f in $library_names; do - if test -f "$dir/$f"; then - found_dir="$dir" - found_so="$dir/$f" - break - fi - done - fi - fi - fi - if test "X$found_dir" = "X"; then - if test -f "$dir/$libname.$acl_libext"; then - found_dir="$dir" - found_a="$dir/$libname.$acl_libext" - fi - fi - if test "X$found_dir" != "X"; then - if test -f "$dir/$libname.la"; then - found_la="$dir/$libname.la" - fi - fi - ;; - esac - if test "X$found_dir" != "X"; then - break - fi - done - fi - if test "X$found_dir" != "X"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" - if test "X$found_so" != "X"; then - if test "$enable_rpath" = no \ - || test "X$found_dir" = "X/usr/$acl_libdirstem" \ - || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - else - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $found_dir" - fi - if test "$acl_hardcode_direct" = yes; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - else - if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $found_dir" - fi - else - haveit= - for x in $LDFLAGS $LIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$found_dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" - fi - if test "$acl_hardcode_minus_L" != no; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" - else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" - fi - fi - fi - fi - else - if test "X$found_a" != "X"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" - else - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" - fi - fi - additional_includedir= - case "$found_dir" in - */$acl_libdirstem | */$acl_libdirstem/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` - if test "$name" = 'iconv'; then - LIBICONV_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - */$acl_libdirstem2 | */$acl_libdirstem2/) - basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` - if test "$name" = 'iconv'; then - LIBICONV_PREFIX="$basedir" - fi - additional_includedir="$basedir/include" - ;; - esac - if test "X$additional_includedir" != "X"; then - if test "X$additional_includedir" != "X/usr/include"; then - haveit= - if test "X$additional_includedir" = "X/usr/local/include"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - for x in $CPPFLAGS $INCICONV; do - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-I$additional_includedir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_includedir"; then - INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" - fi - fi - fi - fi - fi - if test -n "$found_la"; then - save_libdir="$libdir" - case "$found_la" in - */* | *\\*) . "$found_la" ;; - *) . "./$found_la" ;; - esac - libdir="$save_libdir" - for dep in $dependency_libs; do - case "$dep" in - -L*) - additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` - if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ - && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then - haveit= - if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ - || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then - if test -n "$GCC"; then - case $host_os in - linux* | gnu* | k*bsd*-gnu) haveit=yes;; - esac - fi - fi - if test -z "$haveit"; then - haveit= - for x in $LDFLAGS $LIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" - fi - fi - haveit= - for x in $LDFLAGS $LTLIBICONV; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X-L$additional_libdir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - if test -d "$additional_libdir"; then - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" - fi - fi - fi - fi - ;; - -R*) - dir=`echo "X$dep" | sed -e 's/^X-R//'` - if test "$enable_rpath" != no; then - haveit= - for x in $rpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - rpathdirs="$rpathdirs $dir" - fi - haveit= - for x in $ltrpathdirs; do - if test "X$x" = "X$dir"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - ltrpathdirs="$ltrpathdirs $dir" - fi - fi - ;; - -l*) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` - ;; - *.la) - names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` - ;; - *) - LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" - ;; - esac - done - fi - else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" - fi - fi - fi - done - done - if test "X$rpathdirs" != "X"; then - if test -n "$acl_hardcode_libdir_separator"; then - alldirs= - for found_dir in $rpathdirs; do - alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" - done - acl_save_libdir="$libdir" - libdir="$alldirs" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" - else - for found_dir in $rpathdirs; do - acl_save_libdir="$libdir" - libdir="$found_dir" - eval flag=\"$acl_hardcode_libdir_flag_spec\" - libdir="$acl_save_libdir" - LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" - done - fi - fi - if test "X$ltrpathdirs" != "X"; then - for found_dir in $ltrpathdirs; do - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" - done - fi +# Check whether --with-libcurl was given. +if test "${with_libcurl+set}" = set; then : + withval=$with_libcurl; _libcurl_with=$withval +else + _libcurl_with=yes +fi + if test "$_libcurl_with" != "no" ; then + for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + test -n "$AWK" && break +done + _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[1]+256*A[2]+A[3]; print X;}'" - am_save_CPPFLAGS="$CPPFLAGS" + _libcurl_try_link=yes - for element in $INCICONV; do - haveit= - for x in $CPPFLAGS; do - - acl_save_prefix="$prefix" - prefix="$acl_final_prefix" - acl_save_exec_prefix="$exec_prefix" - exec_prefix="$acl_final_exec_prefix" - eval x=\"$x\" - exec_prefix="$acl_save_exec_prefix" - prefix="$acl_save_prefix" - - if test "X$x" = "X$element"; then - haveit=yes - break - fi - done - if test -z "$haveit"; then - CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" - fi + if test -d "$_libcurl_with" ; then + LIBCURL_CPPFLAGS="-I$withval/include" + _libcurl_ldflags="-L$withval/lib" + # Extract the first word of "curl-config", so it can be a program name with args. +set dummy curl-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path__libcurl_config+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $_libcurl_config in + [\\/]* | ?:[\\/]*) + ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in "$withval/bin" +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done done +IFS=$as_save_IFS - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 -$as_echo_n "checking for iconv... " >&6; } -if ${am_cv_func_iconv+:} false; then : - $as_echo_n "(cached) " >&6 + ;; +esac +fi +_libcurl_config=$ac_cv_path__libcurl_config +if test -n "$_libcurl_config"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5 +$as_echo "$_libcurl_config" >&6; } else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi - am_cv_func_iconv="no, consider installing GNU libiconv" - am_cv_lib_iconv=no - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include + else + # Extract the first word of "curl-config", so it can be a program name with args. +set dummy curl-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path__libcurl_config+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $_libcurl_config in + [\\/]* | ?:[\\/]*) + ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -int -main () -{ -iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - am_cv_func_iconv=yes + ;; +esac +fi +_libcurl_config=$ac_cv_path__libcurl_config +if test -n "$_libcurl_config"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5 +$as_echo "$_libcurl_config" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - if test "$am_cv_func_iconv" != yes; then - am_save_LIBS="$LIBS" - LIBS="$LIBS $LIBICONV" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#include -int -main () -{ -iconv_t cd = iconv_open("",""); - iconv(cd,NULL,NULL,NULL,NULL); - iconv_close(cd); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - am_cv_lib_iconv=yes - am_cv_func_iconv=yes -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - LIBS="$am_save_LIBS" - fi + fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 -$as_echo "$am_cv_func_iconv" >&6; } - if test "$am_cv_func_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 -$as_echo_n "checking for working iconv... " >&6; } -if ${am_cv_func_iconv_works+:} false; then : + if test x$_libcurl_config != "x" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the version of libcurl" >&5 +$as_echo_n "checking for the version of libcurl... " >&6; } +if ${libcurl_cv_lib_curl_version+:} false; then : $as_echo_n "(cached) " >&6 else + libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $2}'` +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_version" >&5 +$as_echo "$libcurl_cv_lib_curl_version" >&6; } - am_save_LIBS="$LIBS" - if test $am_cv_lib_iconv = yes; then - LIBS="$LIBS $LIBICONV" - fi - am_cv_func_iconv_works=no - for ac_iconv_const in '' 'const'; do - if test "$cross_compiling" = yes; then : - case "$host_os" in - aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; - *) am_cv_func_iconv_works="guessing yes" ;; - esac -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include + _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` + _libcurl_wanted=`echo 0 | $_libcurl_version_parse` -#ifndef ICONV_CONST -# define ICONV_CONST $ac_iconv_const -#endif + if test $_libcurl_wanted -gt 0 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcurl >= version " >&5 +$as_echo_n "checking for libcurl >= version ... " >&6; } +if ${libcurl_cv_lib_version_ok+:} false; then : + $as_echo_n "(cached) " >&6 +else -int -main () -{ -int result = 0; - /* Test against AIX 5.1 bug: Failures are not distinguishable from successful - returns. */ - { - iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); - if (cd_utf8_to_88591 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ - char buf[10]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_utf8_to_88591, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 1; - iconv_close (cd_utf8_to_88591); - } - } - /* Test against Solaris 10 bug: Failures are not distinguishable from - successful returns. */ - { - iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); - if (cd_ascii_to_88591 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\263"; - char buf[10]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_ascii_to_88591, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res == 0) - result |= 2; - iconv_close (cd_ascii_to_88591); - } - } - /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\304"; - static char buf[2] = { (char)0xDE, (char)0xAD }; - ICONV_CONST char *inptr = input; - size_t inbytesleft = 1; - char *outptr = buf; - size_t outbytesleft = 1; - size_t res = iconv (cd_88591_to_utf8, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) - result |= 4; - iconv_close (cd_88591_to_utf8); - } - } -#if 0 /* This bug could be worked around by the caller. */ - /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ - { - iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); - if (cd_88591_to_utf8 != (iconv_t)(-1)) - { - static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; - char buf[50]; - ICONV_CONST char *inptr = input; - size_t inbytesleft = strlen (input); - char *outptr = buf; - size_t outbytesleft = sizeof (buf); - size_t res = iconv (cd_88591_to_utf8, - &inptr, &inbytesleft, - &outptr, &outbytesleft); - if ((int)res > 0) - result |= 8; - iconv_close (cd_88591_to_utf8); - } - } -#endif - /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is - provided. */ - if (/* Try standardized names. */ - iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) - /* Try IRIX, OSF/1 names. */ - && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) - /* Try AIX names. */ - && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) - /* Try HP-UX names. */ - && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) - result |= 16; - return result; + if test $_libcurl_version -ge $_libcurl_wanted ; then + libcurl_cv_lib_version_ok=yes + else + libcurl_cv_lib_version_ok=no + fi - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - am_cv_func_iconv_works=yes -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_version_ok" >&5 +$as_echo "$libcurl_cv_lib_version_ok" >&6; } + fi + + if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then + if test x"$LIBCURL_CPPFLAGS" = "x" ; then + LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` + fi + if test x"$LIBCURL" = "x" ; then + LIBCURL=`$_libcurl_config --libs` - test "$am_cv_func_iconv_works" = no || break - done - LIBS="$am_save_LIBS" + # This is so silly, but Apple actually has a bug in their + # curl-config script. Fixed in Tiger, but there are still + # lots of Panther installs around. + case "${host}" in + powerpc-apple-darwin7*) + LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` + ;; + esac + fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 -$as_echo "$am_cv_func_iconv_works" >&6; } - case "$am_cv_func_iconv_works" in - *no) am_func_iconv=no am_cv_lib_iconv=no ;; - *) am_func_iconv=yes ;; - esac - else - am_func_iconv=no am_cv_lib_iconv=no - fi - if test "$am_func_iconv" = yes; then + # All curl-config scripts support --feature + _libcurl_features=`$_libcurl_config --feature` -$as_echo "#define HAVE_ICONV 1" >>confdefs.h + # Is it modern enough to have --protocols? (7.12.4) + if test $_libcurl_version -ge 461828 ; then + _libcurl_protocols=`$_libcurl_config --protocols` + fi + else + _libcurl_try_link=no + fi - fi - if test "$am_cv_lib_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 -$as_echo_n "checking how to link with libiconv... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 -$as_echo "$LIBICONV" >&6; } - else - CPPFLAGS="$am_save_CPPFLAGS" - LIBICONV= - LTLIBICONV= - fi + unset _libcurl_wanted + fi + if test $_libcurl_try_link = yes ; then + # we didn't find curl-config, so let's see if the user-supplied + # link line (or failing that, "-lcurl") is enough. + LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} - if test "$am_cv_func_iconv" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 -$as_echo_n "checking for iconv declaration... " >&6; } - if ${am_cv_proto_iconv+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libcurl is usable" >&5 +$as_echo_n "checking whether libcurl is usable... " >&6; } +if ${libcurl_cv_lib_curl_usable+:} false; then : $as_echo_n "(cached) " >&6 else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); -#else -size_t iconv(); -#endif + _libcurl_save_cppflags=$CPPFLAGS + CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" + _libcurl_save_libs=$LIBS + LIBS="$LIBCURL $LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include int main () { +/* Try and use a few common options to force a failure if we are + missing symbols or can't link. */ +int x; +curl_easy_setopt(NULL,CURLOPT_URL,NULL); +x=CURL_ERROR_SIZE; +x=CURLOPT_WRITEFUNCTION; +x=CURLOPT_WRITEDATA; +x=CURLOPT_ERRORBUFFER; +x=CURLOPT_STDERR; +x=CURLOPT_VERBOSE; +if (x) {;} + ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - am_cv_proto_iconv_arg1="" +if ac_fn_c_try_link "$LINENO"; then : + libcurl_cv_lib_curl_usable=yes else - am_cv_proto_iconv_arg1="const" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" + libcurl_cv_lib_curl_usable=no fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext - am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: - $am_cv_proto_iconv" >&5 -$as_echo " - $am_cv_proto_iconv" >&6; } - -cat >>confdefs.h <<_ACEOF -#define ICONV_CONST $am_cv_proto_iconv_arg1 -_ACEOF - - - fi - - if test "x${am_cv_func_iconv}" = xyes; then - have_iconv=yes - fi - ;; -esac - -# Check for libcurl - - - + CPPFLAGS=$_libcurl_save_cppflags + LIBS=$_libcurl_save_libs + unset _libcurl_save_cppflags + unset _libcurl_save_libs +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_usable" >&5 +$as_echo "$libcurl_cv_lib_curl_usable" >&6; } + if test $libcurl_cv_lib_curl_usable = yes ; then + # Does curl_free() exist in this version of libcurl? + # If not, fake it with free() + _libcurl_save_cppflags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" + _libcurl_save_libs=$LIBS + LIBS="$LIBS $LIBCURL" + ac_fn_c_check_func "$LINENO" "curl_free" "ac_cv_func_curl_free" +if test "x$ac_cv_func_curl_free" = xyes; then : +else +$as_echo "#define curl_free free" >>confdefs.h +fi + CPPFLAGS=$_libcurl_save_cppflags + LIBS=$_libcurl_save_libs + unset _libcurl_save_cppflags + unset _libcurl_save_libs +$as_echo "#define HAVE_LIBCURL 1" >>confdefs.h + for _libcurl_feature in $_libcurl_features ; do + cat >>confdefs.h <<_ACEOF +#define `$as_echo "libcurl_feature_$_libcurl_feature" | $as_tr_cpp` 1 +_ACEOF + eval `$as_echo "libcurl_feature_$_libcurl_feature" | $as_tr_sh`=yes + done + if test "x$_libcurl_protocols" = "x" ; then + # We don't have --protocols, so just assume that all + # protocols are available + _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" + if test x$libcurl_feature_SSL = xyes ; then + _libcurl_protocols="$_libcurl_protocols HTTPS" + # FTPS wasn't standards-compliant until version + # 7.11.0 (0x070b00 == 461568) + if test $_libcurl_version -ge 461568; then + _libcurl_protocols="$_libcurl_protocols FTPS" + fi + fi -# Check whether --with-libcurl was given. -if test "${with_libcurl+set}" = set; then : - withval=$with_libcurl; _libcurl_with=$withval -else - _libcurl_with=yes -fi + # RTSP, IMAP, POP3 and SMTP were added in + # 7.20.0 (0x071400 == 463872) + if test $_libcurl_version -ge 463872; then + _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" + fi + fi + for _libcurl_protocol in $_libcurl_protocols ; do + cat >>confdefs.h <<_ACEOF +#define `$as_echo "libcurl_protocol_$_libcurl_protocol" | $as_tr_cpp` 1 +_ACEOF - if test "$_libcurl_with" != "no" ; then + eval `$as_echo "libcurl_protocol_$_libcurl_protocol" | $as_tr_sh`=yes + done + else + unset LIBCURL + unset LIBCURL_CPPFLAGS + fi + fi - for ac_prog in gawk mawk nawk awk -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_AWK+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AWK"; then - ac_cv_prog_AWK="$AWK" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 + unset _libcurl_try_link + unset _libcurl_version_parse + unset _libcurl_config + unset _libcurl_feature + unset _libcurl_features + unset _libcurl_protocol + unset _libcurl_protocols + unset _libcurl_version + unset _libcurl_ldflags fi -done - done -IFS=$as_save_IFS - -fi -fi -AWK=$ac_cv_prog_AWK -if test -n "$AWK"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 -$as_echo "$AWK" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$AWK" && break -done + if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then + # This is the IF-NO path + have_libcurl=no + else + # This is the IF-YES path + have_libcurl=yes + fi - _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[1]+256*A[2]+A[3]; print X;}'" + unset _libcurl_with - _libcurl_try_link=yes - if test -d "$_libcurl_with" ; then - LIBCURL_CPPFLAGS="-I$withval/include" - _libcurl_ldflags="-L$withval/lib" - # Extract the first word of "curl-config", so it can be a program name with args. -set dummy curl-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path__libcurl_config+:} false; then : +# Configuration specific for solaris +case "${host_os}" in + solaris*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing connect" >&5 +$as_echo_n "checking for library containing connect... " >&6; } +if ${ac_cv_search_connect+:} false; then : $as_echo_n "(cached) " >&6 else - case $_libcurl_config in - [\\/]* | ?:[\\/]*) - ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in "$withval/bin" -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char connect (); +int +main () +{ +return connect (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_connect=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_connect+:} false; then : + break +fi done - done -IFS=$as_save_IFS +if ${ac_cv_search_connect+:} false; then : - ;; -esac -fi -_libcurl_config=$ac_cv_path__libcurl_config -if test -n "$_libcurl_config"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5 -$as_echo "$_libcurl_config" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_search_connect=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_connect" >&5 +$as_echo "$ac_cv_search_connect" >&6; } +ac_res=$ac_cv_search_connect +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +fi - else - # Extract the first word of "curl-config", so it can be a program name with args. -set dummy curl-config; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_path__libcurl_config+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 +$as_echo_n "checking for library containing gethostbyname... " >&6; } +if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else - case $_libcurl_config in - [\\/]* | ?:[\\/]*) - ac_cv_path__libcurl_config="$_libcurl_config" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_path__libcurl_config="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ - ;; -esac +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_gethostbyname=$ac_res fi -_libcurl_config=$ac_cv_path__libcurl_config -if test -n "$_libcurl_config"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_libcurl_config" >&5 -$as_echo "$_libcurl_config" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_gethostbyname+:} false; then : + break fi +done +if ${ac_cv_search_gethostbyname+:} false; then : - - fi - - if test x$_libcurl_config != "x" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the version of libcurl" >&5 -$as_echo_n "checking for the version of libcurl... " >&6; } -if ${libcurl_cv_lib_curl_version+:} false; then : - $as_echo_n "(cached) " >&6 else - libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $2}'` + ac_cv_search_gethostbyname=no fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_version" >&5 -$as_echo "$libcurl_cv_lib_curl_version" >&6; } - - _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` - _libcurl_wanted=`echo 0 | $_libcurl_version_parse` - - if test $_libcurl_wanted -gt 0 ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libcurl >= version " >&5 -$as_echo_n "checking for libcurl >= version ... " >&6; } -if ${libcurl_cv_lib_version_ok+:} false; then : - $as_echo_n "(cached) " >&6 -else - - if test $_libcurl_version -ge $_libcurl_wanted ; then - libcurl_cv_lib_version_ok=yes - else - libcurl_cv_lib_version_ok=no - fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 +$as_echo "$ac_cv_search_gethostbyname" >&6; } +ac_res=$ac_cv_search_gethostbyname +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_version_ok" >&5 -$as_echo "$libcurl_cv_lib_version_ok" >&6; } - fi - if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then - if test x"$LIBCURL_CPPFLAGS" = "x" ; then - LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` - fi - if test x"$LIBCURL" = "x" ; then - LIBCURL=`$_libcurl_config --libs` - # This is so silly, but Apple actually has a bug in their - # curl-config script. Fixed in Tiger, but there are still - # lots of Panther installs around. - case "${host}" in - powerpc-apple-darwin7*) - LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` - ;; - esac - fi + # Include and use regex on solaris + CPPFLAGS="-Ilibgit2/deps/regex ${CPPFLAGS}" + GIT2R_SRC_REGEX=libgit2/deps/regex/regex.o + ;; +esac - # All curl-config scripts support --feature - _libcurl_features=`$_libcurl_config --feature` +# Add include paths for git2r +CPPFLAGS="-I. -Ilibgit2/src -Ilibgit2/include -Ilibgit2/deps/http-parser ${CPPFLAGS}" - # Is it modern enough to have --protocols? (7.12.4) - if test $_libcurl_version -ge 461828 ; then - _libcurl_protocols=`$_libcurl_config --protocols` - fi - else - _libcurl_try_link=no - fi +# Add definitions +CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DGIT_OPENSSL -DGIT_SHA1_OPENSSL -DGIT_HTTPS=1 -DLIBGIT2_NO_FEATURES_H -DR_NO_REMAP -DSTRICT_R_HEADERS" - unset _libcurl_wanted - fi +# Add definition for ssh +if test "x${have_ssh2}" = xyes; then + CPPFLAGS="${CPPFLAGS} -DGIT_SSH" +fi - if test $_libcurl_try_link = yes ; then +# Add definition for curl +if test "x${have_libcurl}" = xyes; then + CPPFLAGS="${CPPFLAGS} -DGIT_CURL" +fi - # we didn't find curl-config, so let's see if the user-supplied - # link line (or failing that, "-lcurl") is enough. - LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} +# Add definition for iconv +if test "x${have_iconv}" = xyes; then + CPPFLAGS="${CPPFLAGS} -DGIT_USE_ICONV" +fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libcurl is usable" >&5 -$as_echo_n "checking whether libcurl is usable... " >&6; } -if ${libcurl_cv_lib_curl_usable+:} false; then : +# Add definitions specific for solaris +case "${host_os}" in + solaris*) + CPPFLAGS="${CPPFLAGS} -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" + ;; +esac + +# Checks for structures +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else - - _libcurl_save_cppflags=$CPPFLAGS - CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" - _libcurl_save_libs=$LIBS - LIBS="$LIBCURL $LIBS" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -int -main () -{ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : -/* Try and use a few common options to force a failure if we are - missing symbols or can't link. */ -int x; -curl_easy_setopt(NULL,CURLOPT_URL,NULL); -x=CURL_ERROR_SIZE; -x=CURLOPT_WRITEFUNCTION; -x=CURLOPT_WRITEDATA; -x=CURLOPT_ERRORBUFFER; -x=CURLOPT_STDERR; -x=CURLOPT_VERBOSE; -if (x) {;} +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext - ; - return 0; -} + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include _ACEOF -if ac_fn_c_try_link "$LINENO"; then : - libcurl_cv_lib_curl_usable=yes +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue else - libcurl_cv_lib_curl_usable=no + # Passes both tests. +ac_preproc_ok=: +break fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - - CPPFLAGS=$_libcurl_save_cppflags - LIBS=$_libcurl_save_libs - unset _libcurl_save_cppflags - unset _libcurl_save_libs +rm -f conftest.err conftest.i conftest.$ac_ext +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libcurl_cv_lib_curl_usable" >&5 -$as_echo "$libcurl_cv_lib_curl_usable" >&6; } - - if test $libcurl_cv_lib_curl_usable = yes ; then - - # Does curl_free() exist in this version of libcurl? - # If not, fake it with free() - - _libcurl_save_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" - _libcurl_save_libs=$LIBS - LIBS="$LIBS $LIBCURL" - ac_fn_c_check_func "$LINENO" "curl_free" "ac_cv_func_curl_free" -if test "x$ac_cv_func_curl_free" = xyes; then : + done + ac_cv_prog_CPP=$CPP +fi + CPP=$ac_cv_prog_CPP else - -$as_echo "#define curl_free free" >>confdefs.h - + ac_cv_prog_CPP=$CPP fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext - CPPFLAGS=$_libcurl_save_cppflags - LIBS=$_libcurl_save_libs - unset _libcurl_save_cppflags - unset _libcurl_save_libs - - -$as_echo "#define HAVE_LIBCURL 1" >>confdefs.h - - - - - for _libcurl_feature in $_libcurl_features ; do - cat >>confdefs.h <<_ACEOF -#define `$as_echo "libcurl_feature_$_libcurl_feature" | $as_tr_cpp` 1 + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include _ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext - eval `$as_echo "libcurl_feature_$_libcurl_feature" | $as_tr_sh`=yes - done +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : - if test "x$_libcurl_protocols" = "x" ; then +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi - # We don't have --protocols, so just assume that all - # protocols are available - _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu - if test x$libcurl_feature_SSL = xyes ; then - _libcurl_protocols="$_libcurl_protocols HTTPS" - # FTPS wasn't standards-compliant until version - # 7.11.0 (0x070b00 == 461568) - if test $_libcurl_version -ge 461568; then - _libcurl_protocols="$_libcurl_protocols FTPS" - fi - fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac - # RTSP, IMAP, POP3 and SMTP were added in - # 7.20.0 (0x071400 == 463872) - if test $_libcurl_version -ge 463872; then - _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" - fi - fi + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi - for _libcurl_protocol in $_libcurl_protocols ; do - cat >>confdefs.h <<_ACEOF -#define `$as_echo "libcurl_protocol_$_libcurl_protocol" | $as_tr_cpp` 1 -_ACEOF +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" - eval `$as_echo "libcurl_protocol_$_libcurl_protocol" | $as_tr_sh`=yes - done - else - unset LIBCURL - unset LIBCURL_CPPFLAGS - fi - fi - unset _libcurl_try_link - unset _libcurl_version_parse - unset _libcurl_config - unset _libcurl_feature - unset _libcurl_features - unset _libcurl_protocol - unset _libcurl_protocols - unset _libcurl_version - unset _libcurl_ldflags - fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac - if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then - # This is the IF-NO path - have_libcurl=no - else - # This is the IF-YES path - have_libcurl=yes + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi +else + ac_cv_path_EGREP=$EGREP +fi - unset _libcurl_with + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" -# Configuration specific for solaris -case "${host_os}" in - solaris*) - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing connect" >&5 -$as_echo_n "checking for library containing connect... " >&6; } -if ${ac_cv_search_connect+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ +#include +#include +#include +#include -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char connect (); int main () { -return connect (); + ; return 0; } _ACEOF -for ac_lib in '' socket; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_connect=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_connect+:} false; then : - break +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no fi -done -if ${ac_cv_search_connect+:} false; then : +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : else - ac_cv_search_connect=no + ac_cv_header_stdc=no fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS +rm -f conftest* + fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_connect" >&5 -$as_echo "$ac_cv_search_connect" >&6; } -ac_res=$ac_cv_search_connect -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no fi +rm -f conftest* - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 -$as_echo_n "checking for library containing gethostbyname... " >&6; } -if ${ac_cv_search_gethostbyname+:} false; then : - $as_echo_n "(cached) " >&6 +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif -char gethostbyname (); + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { -return gethostbyname (); - ; + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; return 0; } _ACEOF -for ac_lib in '' nsl socket; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_gethostbyname=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_gethostbyname+:} false; then : - break -fi -done -if ${ac_cv_search_gethostbyname+:} false; then : +if ac_fn_c_try_run "$LINENO"; then : else - ac_cv_search_gethostbyname=no + ac_cv_header_stdc=no fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 -$as_echo "$ac_cv_search_gethostbyname" >&6; } -ac_res=$ac_cv_search_gethostbyname -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then +$as_echo "#define STDC_HEADERS 1" >>confdefs.h - # Include and use regex on solaris - CPPFLAGS="-Ilibgit2/deps/regex ${CPPFLAGS}" - GIT2R_SRC_REGEX=libgit2/deps/regex/regex.o - ;; -esac - -# Add include paths for git2r -CPPFLAGS="-I. -Ilibgit2/src -Ilibgit2/include -Ilibgit2/deps/http-parser ${CPPFLAGS}" - -# Add definitions -CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DGIT_OPENSSL -DLIBGIT2_NO_FEATURES_H" - -# Specify sha1 implementation -case "${host_os}" in - darwin*) - PKG_CFLAGS="-Wno-deprecated-declarations" - CPPFLAGS="${CPPFLAGS} -DGIT_SHA1_COMMON_CRYPTO" - ;; - *) - CPPFLAGS="${CPPFLAGS} -DGIT_SHA1_OPENSSL" - ;; -esac - -# Add definition for ssh -if test "x${have_ssh2}" = xyes; then - CPPFLAGS="${CPPFLAGS} -DGIT_SSH" fi -# Add definition for curl -if test "x${have_libcurl}" = xyes; then - CPPFLAGS="${CPPFLAGS} -DGIT_CURL" -fi +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF -# Add definition for iconv -if test "x${have_iconv}" = xyes; then - CPPFLAGS="${CPPFLAGS} -DGIT_USE_ICONV" fi -# Add definitions specific for solaris -case "${host_os}" in - solaris*) - CPPFLAGS="${CPPFLAGS} -D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" - ;; -esac +done -# Checks for structures -ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "#ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_SYS_STAT_H - # include - #endif + +ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim" "ac_cv_member_struct_stat_st_mtim" "$ac_includes_default " if test "x$ac_cv_member_struct_stat_st_mtim" = xyes; then : CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIM" fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec" "ac_cv_member_struct_stat_st_mtimespec" "#ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_SYS_STAT_H - # include - #endif +ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec" "ac_cv_member_struct_stat_st_mtimespec" "$ac_includes_default " if test "x$ac_cv_member_struct_stat_st_mtimespec" = xyes; then : CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIMESPEC" fi -ac_fn_c_check_member "$LINENO" "struct stat" "st_mtime_nsec" "ac_cv_member_struct_stat_st_mtime_nsec" "#ifdef HAVE_SYS_STAT_H - # include - #endif +ac_fn_c_check_member "$LINENO" "struct stat" "st_mtime_nsec" "ac_cv_member_struct_stat_st_mtime_nsec" "$ac_includes_default " if test "x$ac_cv_member_struct_stat_st_mtime_nsec" = xyes; then : CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIME_NSEC" @@ -6312,18 +6123,14 @@ if test "x$ac_cv_member_struct_stat_st_mtim" = "xyes"; then - ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim.tv_nsec" "ac_cv_member_struct_stat_st_mtim_tv_nsec" "#ifdef HAVE_SYS_STAT_H - # include - #endif + ac_fn_c_check_member "$LINENO" "struct stat" "st_mtim.tv_nsec" "ac_cv_member_struct_stat_st_mtim_tv_nsec" "$ac_includes_default " if test "x$ac_cv_member_struct_stat_st_mtim_tv_nsec" = xyes; then : CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC" fi elif test "x$ac_cv_member_struct_stat_st_mtimespec" = "xyes"; then - ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec.tv_nsec" "ac_cv_member_struct_stat_st_mtimespec_tv_nsec" "#ifdef HAVE_SYS_STAT_H - # include - #endif + ac_fn_c_check_member "$LINENO" "struct stat" "st_mtimespec.tv_nsec" "ac_cv_member_struct_stat_st_mtimespec_tv_nsec" "$ac_includes_default " if test "x$ac_cv_member_struct_stat_st_mtimespec_tv_nsec" = xyes; then : CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC" @@ -6367,7 +6174,7 @@ PKG_LIBS="${LIBS} ${LIBSSH2_LIBS} ${LIBCURL} ${LIBICONV}" -ac_config_files="$ac_config_files src/Makevars" +ac_config_files="$ac_config_files src/Makevars_libgit2" echo " @@ -7086,6 +6893,7 @@ do case $ac_config_target in "src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;; + "src/Makevars_libgit2") CONFIG_FILES="$CONFIG_FILES src/Makevars_libgit2" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac @@ -7535,3 +7343,8 @@ $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi + +cd src; mv Makevars_libgit2 Makevars + +fi +################# End configuration to build bundled libgit2 ################# diff -Nru r-cran-git2r-0.21.0/configure.ac r-cran-git2r-0.22.1/configure.ac --- r-cran-git2r-0.21.0/configure.ac 2017-12-17 08:10:21.000000000 +0000 +++ r-cran-git2r-0.22.1/configure.ac 2018-07-01 21:27:09.000000000 +0000 @@ -1,5 +1,5 @@ # git2r, R bindings to the libgit2 library. -# Copyright (C) 2013-2017 The git2r contributors +# Copyright (C) 2013-2018 The git2r contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, @@ -24,99 +24,140 @@ # Checks for programs. AC_PROG_CC -## check for brew on OS X +## Check for brew on macOS AC_DEFUN([AC_PROG_BREW], [AC_CHECK_PROG(BREW,brew,yes)]) -case "${host_os}" in - darwin*) - AC_PROG_BREW - if test "x${BREW}" = xyes; then - BREW_DIR=`brew --prefix` - fi - ;; -esac # Check for pkg-config PKG_PROG_PKG_CONFIG -# Optional include and library paths - -# zlib include and library path -AC_ARG_WITH([zlib-include], - AC_HELP_STRING([--with-zlib-include=INCLUDE_PATH], - [the location of the zlib header files]), - [zlib_include_path=$withval]) - -AC_ARG_WITH([zlib-lib], - AC_HELP_STRING([--with-zlib-lib=LIB_PATH], - [the location of the zlib library]), - [zlib_lib_path=$withval]) - -# LibSSH2 include and library path -AC_ARG_WITH([libssh2-include], - AC_HELP_STRING([--with-libssh2-include=INCLUDE_PATH], - [the location of the LibSSH2 header files]), - [libssh2_include_path=$withval]) - -AC_ARG_WITH([libssh2-lib], - AC_HELP_STRING([--with-libssh2-lib=LIB_PATH], - [the location of the LibSSH2 library]), - [libssh2_lib_path=$withval]) - -# libssl include and library path -AC_ARG_WITH([libssl-include], - AC_HELP_STRING([--with-libssl-include=INCLUDE_PATH], - [the location of the libssl header files]), - [libssl_include_path=$withval]) - -AC_ARG_WITH([libssl-lib], - AC_HELP_STRING([--with-libssl-lib=LIB_PATH], - [the location of the libssl library]), - [libssl_lib_path=$withval]) - -# Find the compiler and compiler flags to use +# Check for R : ${R_HOME=`R RHOME`} if test -z "${R_HOME}"; then - echo "could not determine R_HOME" - exit 1 + AC_MSG_FAILURE([Could not determine R_HOME]) fi RBIN="${R_HOME}/bin/R" + +# Library settings +m4_pattern_allow([PKG_CONFIG_NAME]) +m4_pattern_allow([PKG_BREW_NAME]) +PKG_CONFIG_NAME="libgit2" +PKG_BREW_NAME="libgit2" +PKG_LIBS="-lgit2" +PKG_CFLAGS="" + +# Check if building against bundled libgit2 or system libgit2 +USE_BUNDLED_LIBGIT2=yes +if test "x${INCLUDE_DIR}${LIB_DIR}" = x; then + if test [ -n "$PKG_CONFIG" ] ; then + PKGCONFIG_CFLAGS=`"${PKG_CONFIG}" --cflags "${PKG_CONFIG_NAME}"` + PKGCONFIG_LIBS=`"${PKG_CONFIG}" --libs "${PKG_CONFIG_NAME}"` + fi + + # Hack for CRAN server: do not use preinstalled libgit2 + CRAN_server=no + AC_CHECK_FILE([/Builds/CRAN-QA-Simon], [CRAN_server=yes], [ + AC_CHECK_FILE([/Volumes/SSD-Data/Builds], [CRAN_server=yes], [ ])]) + if test "x${CRAN_server}" = xyes; then + unset PKGCONFIG_CFLAGS + unset PKGCONFIG_LIBS + fi + + if test "x${PKGCONFIG_CFLAGS}${PKGCONFIG_LIBS}" = x; then + case "${host_os}" in + darwin*) + AC_PROG_BREW + if test "x${BREW}" = xyes; then + BREWDIR=`brew --prefix` + else + curl -sfL "https://jeroen.github.io/autobrew/${PKG_BREW_NAME}" > autobrew + source autobrew + fi + USE_BUNDLED_LIBGIT2=no + ;; + esac + else + echo "Found pkg-config cflags and libs!" + PKG_CFLAGS="${PKGCONFIG_CFLAGS}" + PKG_LIBS="${PKGCONFIG_LIBS}" + USE_BUNDLED_LIBGIT2=no + fi +else + echo "Found INCLUDE_DIR and/or LIB_DIR!" + PKG_CFLAGS="-I${INCLUDE_DIR} ${PKG_CFLAGS}" + PKG_LIBS="-L${LIB_DIR} ${PKG_LIBS}" + USE_BUNDLED_LIBGIT2=no, +fi + +################# Begin configuration to use system libgit2 ################## +if test "x${USE_BUNDLED_LIBGIT2}" = xno; then + # Find the compiler and compiler flags to use + CC=`"${RBIN}" CMD config CC` + CFLAGS=`"${RBIN}" CMD config CFLAGS` + CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` + + AC_MSG_CHECKING([whether the libgit2 version will work in git2r]) + libgit2_ver_ok=no + ${CC} ${CPPFLAGS} ${PKG_CFLAGS} ${CFLAGS} -E tools/version.c >/dev/null 2>&1 && libgit2_ver_ok=yes + AC_MSG_RESULT([${libgit2_ver_ok}]) + + # For debugging + echo "----- Results of the git2r package configure -----" + echo "" + echo " PKG_CFLAGS: ${PKG_CFLAGS}" + echo " PKG_LIBS: ${PKG_LIBS}" + echo "" + echo "--------------------------------------------------" + + if test "x${libgit2_ver_ok}" = xno; then + AC_MSG_FAILURE([ + --------------------------------------------- + The libgit2 library that is required to build git2r was not found. + + Please install: + libgit2-dev (package on e.g. Debian and Ubuntu) + libgit2-devel (package on e.g. Fedora, CentOS and RHEL) + libgit2 (Homebrew package on macOS) + and try again. + + If the libgit2 library is installed on your system but the git2r configuration is + unable to find it, you can specify the include and lib path to libgit2 with: + R CMD INSTALL git2r --configure-vars='INCLUDE_DIR=path/to/include LIB_DIR=path/to/lib' + ---------------------------------------------]) + fi + + AC_SUBST([PKG_CFLAGS], ["${PKG_CFLAGS}"]) + AC_SUBST([PKG_LIBS], ["${PKG_LIBS}"]) + AC_CONFIG_FILES([src/Makevars]) + + AC_OUTPUT +fi +################# End configuration to use system libgit2 #################### + +################# Begin configuration to build bundled libgit2 ############### +if test "x${USE_BUNDLED_LIBGIT2}" = xyes; then + +AC_MSG_NOTICE([Attempting configuration of bundled libgit2]) + +# Find the compiler and compiler flags to use CC=`"${RBIN}" CMD config CC` CFLAGS=`"${RBIN}" CMD config CFLAGS` CPPFLAGS=`"${RBIN}" CMD config CPPFLAGS` -CPICFLAGS=`"${RBIN}" CMD config CPICFLAGS` -# Determine architecture of the machine -AC_CHECK_SIZEOF([void*]) -if test "x$ac_cv_sizeof_voidp" = "x8"; then +# Use R to determine architecture of the machine +AC_MSG_CHECKING([size of void*]) +sizeof_voidp=`"${RBIN}" --slave --vanilla -e "cat(.Machine\\$sizeof.pointer)"` +AC_MSG_RESULT([$sizeof_voidp]) +if test "x$sizeof_voidp" = "x8"; then CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_64" -elif test "x$ac_cv_sizeof_voidp" = "x4"; then +elif test "x$sizeof_voidp" = "x4"; then CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_32" else - AC_MSG_CHECKING([size of void*]) - sizeof_voidp=`"${RBIN}" --slave -e "cat(.Machine\\$sizeof.pointer)"` - AC_MSG_RESULT([$sizeof_voidp]) - if test "x$sizeof_voidp" = "x8"; then - CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_64" - elif test "x$sizeof_voidp" = "x4"; then - CPPFLAGS="${CPPFLAGS} -DGIT_ARCH_32" - else - AC_MSG_FAILURE([Unsupported architecture]) - fi + AC_MSG_FAILURE([Unsupported architecture]) fi # Check for zlib have_zlib=no -# Check for optional zlib include path -if test [ -n "$zlib_include_path" ] ; then - CPPFLAGS="-I${zlib_include_path} ${CPPFLAGS}" -fi - -# Check for optional zlib lib path -if test [ -n "$zlib_lib_path" ] ; then - LIBS="-L${zlib_lib_path} ${LIBS}" -fi - AC_SEARCH_LIBS([inflate], [z], [have_zlib=yes]) if test "x${have_zlib}" = xno; then @@ -143,37 +184,17 @@ system but the git2r configuration is unable to find it, you can specify the include and lib path to zlib with: - R CMD INSTALL --configure-args='--with-zlib-include=INCLUDE_PATH --with-zlib-lib=LIB_PATH' git2r + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' ---------------------------------------------]) fi # Check for SSL have_ssl=no -# Check for optional libssl include path -if test [ -n "$libssl_include_path" ] ; then - CPPFLAGS="-I${libssl_include_path} ${CPPFLAGS}" -fi - -# Check for optional libssl lib path -if test [ -n "$libssl_lib_path" ] ; then - LIBS="-L${libssl_lib_path} ${LIBS}" -fi - if test "x${OPENSSL_INCLUDES}" = x; then :; else CPPFLAGS="${CPPFLAGS} -I${OPENSSL_INCLUDES}" fi -# On OS X, add path to libssl in brew -case "${host_os}" in - darwin*) - if test "x${BREW}" = xyes; then - CPPFLAGS="${CPPFLAGS} -I${BREW_DIR}/opt/openssl/include" - LIBS="${LIBS} -L${BREW_DIR}/opt/openssl/lib" - fi - ;; -esac - AC_SEARCH_LIBS([EVP_EncryptInit], [crypto], [AC_SEARCH_LIBS([SSL_library_init], [ssl], [have_ssl=yes]) @@ -197,74 +218,19 @@ Please install: libssl-dev (package on e.g. Debian and Ubuntu) openssl-devel (package on e.g. Fedora, CentOS and RHEL) - openssl (Homebrew package on OS X) and try again. If the OpenSSL library is installed on your system but the git2r configuration is unable to find it, you can specify the include and lib path to OpenSSL with: - R CMD INSTALL --configure-args='--with-libssl-include=INCLUDE_PATH --with-libssl-lib=LIB_PATH' git2r + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' ---------------------------------------------]) fi # Check for LibSSH2 have_ssh2=no - -# Check for optional libssh2 include path -if test [ -n "$libssh2_include_path" ] ; then - CPPFLAGS="-I${libssh2_include_path} ${CPPFLAGS}" -fi - -# Check for optional libssh2 lib path -if test [ -n "$libssh2_lib_path" ] ; then - LIBS="-L${libssh2_lib_path} ${LIBS}" -fi - -case "${host_os}" in - darwin*) - # Save flags - oCPPFLAGS="${CPPFLAGS}" - oLIBS="${LIBS}" - - # On OS X, try to find libssh2 in brew - if test "x${BREW}" = xyes; then - CPPFLAGS="${CPPFLAGS} -I${BREW_DIR}/opt/libssh2/include" - LIBS="${LIBS} -L${BREW_DIR}/opt/libssh2/lib" - AC_SEARCH_LIBS([libssh2_version], [ssh2], [have_ssh2=yes]) - fi - - if test "x${have_ssh2}" = xno; then - CPPFLAGS="${oCPPFLAGS}" - LIBS="${oLIBS}" - - AC_MSG_NOTICE([Download and build libssh2]) - - mkdir -p libssh2 && \ - curl -fsSL https://www.libssh2.org/download/libssh2-1.8.0.tar.gz | \ - tar xz --strip 1 -C libssh2 - - mkdir -p src/libgit2/deps/libssh2 - LIBSSH2_INST_DIR="${PWD}/src/libgit2/deps/libssh2" - cp -f tools/missing libssh2 - cd libssh2 - ./configure --with-pic --with-openssl --disable-examples-build \ - --disable-shared --enable-static --prefix=$LIBSSH2_INST_DIR \ - CC="${CC}" CFLAGS="${CFLAGS} ${CPICFLAGS} -Wno-deprecated-declarations" \ - CPPFLAGS="${CPPFLAGS}" && make && make install && have_ssh2=yes - cd .. - rm -rf libssh2 - - if test "x${have_ssh2}" = xyes; then - LIBSSH2_CFLAGS="-Ilibgit2/deps/libssh2/include" - LIBSSH2_LIBS="-Llibgit2/deps/libssh2/lib -lssh2" - fi - fi - ;; - *) - AC_SEARCH_LIBS([libssh2_version], [ssh2], [have_ssh2=yes]) - ;; -esac +AC_SEARCH_LIBS([libssh2_version], [ssh2], [have_ssh2=yes]) if test "x${have_ssh2}" = xno; then if test [ -n "$PKG_CONFIG" ] ; then @@ -285,28 +251,16 @@ To build with SSH support, please install: libssh2-1-dev (package on e.g. Debian and Ubuntu) libssh2-devel (package on e.g. Fedora, CentOS and RHEL) - libssh2 (Homebrew package on OS X) and try again. If the LibSSH2 library is installed on your system but the git2r configuration is unable to find it, you can specify the include and lib path to LibSSH2 with: - R CMD INSTALL --configure-args='--with-libssh2-include=INCLUDE_PATH --with-libssh2-lib=LIB_PATH' git2r + R CMD INSTALL git2r --configure-vars='LIBS=-L/path/to/libs CPPFLAGS=-I/path/to/headers' ---------------------------------------------]) fi -# Check for iconv -have_iconv=no -case "${host_os}" in - darwin*) - AM_ICONV - if test "x${am_cv_func_iconv}" = xyes; then - have_iconv=yes - fi - ;; -esac - # Check for libcurl LIBCURL_CHECK_CONFIG(, , [have_libcurl=yes], [have_libcurl=no]) @@ -326,18 +280,7 @@ CPPFLAGS="-I. -Ilibgit2/src -Ilibgit2/include -Ilibgit2/deps/http-parser ${CPPFLAGS}" # Add definitions -CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DGIT_OPENSSL -DLIBGIT2_NO_FEATURES_H" - -# Specify sha1 implementation -case "${host_os}" in - darwin*) - PKG_CFLAGS="-Wno-deprecated-declarations" - CPPFLAGS="${CPPFLAGS} -DGIT_SHA1_COMMON_CRYPTO" - ;; - *) - CPPFLAGS="${CPPFLAGS} -DGIT_SHA1_OPENSSL" - ;; -esac +CPPFLAGS="${CPPFLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DGIT_OPENSSL -DGIT_SHA1_OPENSSL -DGIT_HTTPS=1 -DLIBGIT2_NO_FEATURES_H -DR_NO_REMAP -DSTRICT_R_HEADERS" # Add definition for ssh if test "x${have_ssh2}" = xyes; then @@ -364,45 +307,24 @@ # Checks for structures AC_CHECK_MEMBER([struct stat.st_mtim], [CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIM"], - [], - [#ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_SYS_STAT_H - # include - #endif]) + [], [AC_INCLUDES_DEFAULT]) AC_CHECK_MEMBER([struct stat.st_mtimespec], [CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIMESPEC"], - [], - [#ifdef HAVE_SYS_TYPES_H - # include - #endif - #ifdef HAVE_SYS_STAT_H - # include - #endif]) + [], [AC_INCLUDES_DEFAULT]) AC_CHECK_MEMBER([struct stat.st_mtime_nsec], [CPPFLAGS="${CPPFLAGS} -DGIT_USE_STAT_MTIME_NSEC"], - [], - [#ifdef HAVE_SYS_STAT_H - # include - #endif]) + [], [AC_INCLUDES_DEFAULT]) if test "x$ac_cv_member_struct_stat_st_mtim" = "xyes"; then AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec], [CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC"], - [], - [#ifdef HAVE_SYS_STAT_H - # include - #endif]) + [], [AC_INCLUDES_DEFAULT]) elif test "x$ac_cv_member_struct_stat_st_mtimespec" = "xyes"; then AC_CHECK_MEMBER([struct stat.st_mtimespec.tv_nsec], [CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC"], - [], - [#ifdef HAVE_SYS_STAT_H - # include - #endif]) + [], [AC_INCLUDES_DEFAULT]) else CPPFLAGS="${CPPFLAGS} -DGIT_USE_NSEC" fi @@ -427,7 +349,7 @@ AC_SUBST([PKG_CPPFLAGS], ["${CPPFLAGS} ${LIBCURL_CPPFLAGS}"]) AC_SUBST([PKG_LIBS], ["${LIBS} ${LIBSSH2_LIBS} ${LIBCURL} ${LIBICONV}"]) -AC_CONFIG_FILES([src/Makevars]) +AC_CONFIG_FILES([src/Makevars_libgit2]) echo " ----- Results of the git2r package configure ----- @@ -439,3 +361,8 @@ " AC_OUTPUT + +cd src; mv Makevars_libgit2 Makevars + +fi +################# End configuration to build bundled libgit2 ################# diff -Nru r-cran-git2r-0.21.0/debian/changelog r-cran-git2r-0.22.1/debian/changelog --- r-cran-git2r-0.21.0/debian/changelog 2018-06-21 05:06:17.000000000 +0000 +++ r-cran-git2r-0.22.1/debian/changelog 2018-07-11 07:06:29.000000000 +0000 @@ -1,3 +1,9 @@ +r-cran-git2r (0.22.1-1) unstable; urgency=medium + + * New upstream version + + -- Andreas Tille Wed, 11 Jul 2018 09:06:29 +0200 + r-cran-git2r (0.21.0-2) unstable; urgency=medium * debhelper 11 diff -Nru r-cran-git2r-0.21.0/debian/control r-cran-git2r-0.22.1/debian/control --- r-cran-git2r-0.21.0/debian/control 2018-06-21 05:06:17.000000000 +0000 +++ r-cran-git2r-0.22.1/debian/control 2018-07-11 07:06:29.000000000 +0000 @@ -7,7 +7,7 @@ dh-r, r-base-dev, libssl-dev -Standards-Version: 4.1.4 +Standards-Version: 4.1.5 Vcs-Browser: https://salsa.debian.org/r-pkg-team/r-cran-git2r Vcs-Git: https://salsa.debian.org/r-pkg-team/r-cran-git2r.git Homepage: https://cran.r-project.org/package=git2r diff -Nru r-cran-git2r-0.21.0/DESCRIPTION r-cran-git2r-0.22.1/DESCRIPTION --- r-cran-git2r-0.21.0/DESCRIPTION 2018-01-04 16:50:12.000000000 +0000 +++ r-cran-git2r-0.22.1/DESCRIPTION 2018-07-10 15:00:03.000000000 +0000 @@ -4,7 +4,7 @@ implementation of the 'Git' core methods. Provides access to 'Git' repositories to extract data and running some basic 'Git' commands. -Version: 0.21.0 +Version: 0.22.1 License: GPL-2 Copyright: See COPYRIGHTS file. URL: https://github.com/ropensci/git2r @@ -12,24 +12,24 @@ Maintainer: Stefan Widgren Author: See AUTHORS file. Imports: graphics, utils -Depends: R (>= 3.1), methods +Depends: R (>= 3.1) Suggests: getPass Type: Package LazyData: true Biarch: true NeedsCompilation: yes -SystemRequirements: zlib headers and library. OpenSSL headers and - library. LibSSH2 (optional on non-Windows) to enable the SSH - transport. -Collate: 'S4_classes.r' 'blame.r' 'blob.r' 'branch.r' - 'bundle_r_package.r' 'checkout.r' 'commit.r' 'config.r' - 'contributions.r' 'credential.r' 'diff.r' 'fetch.r' 'git2r.r' - 'index.r' 'libgit2.r' 'merge.r' 'note.r' 'odb.r' 'plot.r' - 'pull.r' 'punch_card.r' 'refspec.r' 'push.r' 'reference.r' - 'reflog.r' 'remote.r' 'repository.r' 'reset.r' 'revparse.r' - 'signature.r' 'stash.r' 'status.r' 'tag.r' 'time.r' 'tree.r' - 'when.r' +SystemRequirements: libgit2 headers and library. zlib headers and + library. OpenSSL headers and library. LibSSH2 (optional on + non-Windows) to enable the SSH transport. +Collate: 'blame.R' 'blob.R' 'branch.R' 'bundle_r_package.R' + 'checkout.R' 'commit.R' 'config.R' 'contributions.R' + 'credential.R' 'diff.R' 'fetch.R' 'git2r.R' 'index.R' + 'libgit2.R' 'merge.R' 'note.R' 'odb.R' 'plot.R' 'pull.R' + 'punch_card.R' 'push.R' 'reference.R' 'reflog.R' 'refspec.R' + 'remote.R' 'repository.R' 'reset.R' 'revparse.R' 'sha.R' + 'signature.R' 'stash.R' 'status.R' 'tag.R' 'time.R' 'tree.R' + 'when.R' RoxygenNote: 6.0.1 -Packaged: 2018-01-03 21:29:02 UTC; stefan +Packaged: 2018-07-10 13:23:34 UTC; stefan Repository: CRAN -Date/Publication: 2018-01-04 16:50:12 UTC +Date/Publication: 2018-07-10 15:00:02 UTC diff -Nru r-cran-git2r-0.21.0/man/add-methods.Rd r-cran-git2r-0.22.1/man/add-methods.Rd --- r-cran-git2r-0.21.0/man/add-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/add-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/index.r -\docType{methods} -\name{add} -\alias{add} -\alias{add,git_repository,character-method} -\title{Add file(s) to index} -\usage{ -add(repo, path, ...) - -\S4method{add}{git_repository,character}(repo, path, force = FALSE) -} -\arguments{ -\item{repo}{The repository \code{object}.} - -\item{path}{Character vector with file names or shell glob -patterns that will matched against files in the repository's -working directory. Each file that matches will be added to the -index (either updating an existing entry or adding a new entry).} - -\item{...}{Additional arguments to the method} - -\item{force}{Add ignored files. Default is FALSE.} -} -\value{ -invisible(NULL) -} -\description{ -Add file(s) to index -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file -writeLines("a", file.path(path, "a.txt")) - -## Add file to repository and view status -add(repo, "a.txt") -status(repo) - -## Add file with a leading './' when the repository working -## directory is the current working directory -setwd(path) -writeLines("b", file.path(path, "b.txt")) -add(repo, "./b.txt") -status(repo) - -## Add a file in a sub-folder with sub-folder as the working -## directory. Create a file in the root of the repository -## working directory that will remain untracked. -dir.create(file.path(path, "sub_dir")) -setwd("./sub_dir") -writeLines("c", file.path(path, "c.txt")) -writeLines("c", file.path(path, "sub_dir/c.txt")) -add(repo, "c.txt") -status(repo) - -## Add files with glob expansion when the current working -## directory is outside the repository's working directory. -setwd(tempdir()) -dir.create(file.path(path, "glob_dir")) -writeLines("d", file.path(path, "glob_dir/d.txt")) -writeLines("e", file.path(path, "glob_dir/e.txt")) -writeLines("f", file.path(path, "glob_dir/f.txt")) -writeLines("g", file.path(path, "glob_dir/g.md")) -add(repo, "glob_dir/*txt") -status(repo) - -## Add file with glob expansion with a relative path when -## the current working directory is inside the repository's -## working directory. -setwd(path) -add(repo, "./glob_dir/*md") -status(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/add.Rd r-cran-git2r-0.22.1/man/add.Rd --- r-cran-git2r-0.21.0/man/add.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/add.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,79 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/index.R +\name{add} +\alias{add} +\title{Add file(s) to index} +\usage{ +add(repo = ".", path = NULL, force = FALSE) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{path}{Character vector with file names or shell glob +patterns that will matched against files in the repository's +working directory. Each file that matches will be added to the +index (either updating an existing entry or adding a new +entry).} + +\item{force}{Add ignored files. Default is FALSE.} +} +\value{ +invisible(NULL) +} +\description{ +Add file(s) to index +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file +writeLines("a", file.path(path, "a.txt")) + +## Add file to repository and view status +add(repo, "a.txt") +status(repo) + +## Add file with a leading './' when the repository working +## directory is the current working directory +setwd(path) +writeLines("b", file.path(path, "b.txt")) +add(repo, "./b.txt") +status(repo) + +## Add a file in a sub-folder with sub-folder as the working +## directory. Create a file in the root of the repository +## working directory that will remain untracked. +dir.create(file.path(path, "sub_dir")) +setwd("./sub_dir") +writeLines("c", file.path(path, "c.txt")) +writeLines("c", file.path(path, "sub_dir/c.txt")) +add(repo, "c.txt") +status(repo) + +## Add files with glob expansion when the current working +## directory is outside the repository's working directory. +setwd(tempdir()) +dir.create(file.path(path, "glob_dir")) +writeLines("d", file.path(path, "glob_dir/d.txt")) +writeLines("e", file.path(path, "glob_dir/e.txt")) +writeLines("f", file.path(path, "glob_dir/f.txt")) +writeLines("g", file.path(path, "glob_dir/g.md")) +add(repo, "glob_dir/*txt") +status(repo) + +## Add file with glob expansion with a relative path when +## the current working directory is inside the repository's +## working directory. +setwd(path) +add(repo, "./glob_dir/*md") +status(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/add_session_info.Rd r-cran-git2r-0.22.1/man/add_session_info.Rd --- r-cran-git2r-0.21.0/man/add_session_info.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/add_session_info.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\name{add_session_info} -\alias{add_session_info} -\title{Add sessionInfo to message} -\usage{ -add_session_info(message) -} -\arguments{ -\item{message}{The message.} -} -\value{ -message with appended sessionInfo -} -\description{ -Add sessionInfo to message -} -\keyword{internal} diff -Nru r-cran-git2r-0.21.0/man/ahead_behind-methods.Rd r-cran-git2r-0.22.1/man/ahead_behind-methods.Rd --- r-cran-git2r-0.21.0/man/ahead_behind-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/ahead_behind-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{ahead_behind} -\alias{ahead_behind} -\alias{ahead_behind,git_commit,git_commit-method} -\title{Ahead Behind} -\usage{ -ahead_behind(local, upstream) - -\S4method{ahead_behind}{git_commit,git_commit}(local, upstream) -} -\arguments{ -\item{local}{a S4 class git_commit \code{object}.} - -\item{upstream}{a S4 class git_commit \code{object}.} -} -\value{ -An integer vector of length 2 with number of commits that -the upstream commit is ahead and behind the local commit -} -\description{ -Count the number of unique commits between two commit objects. -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit_1 <- commit(repo, "Commit message 1") - -# Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit_2 <- commit(repo, "Commit message 2") - -ahead_behind(commit_1, commit_2) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/ahead_behind.Rd r-cran-git2r-0.22.1/man/ahead_behind.Rd --- r-cran-git2r-0.21.0/man/ahead_behind.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/ahead_behind.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{ahead_behind} +\alias{ahead_behind} +\title{Ahead Behind} +\usage{ +ahead_behind(local = NULL, upstream = NULL) +} +\arguments{ +\item{local}{a git_commit object.} + +\item{upstream}{a git_commit object.} +} +\value{ +An integer vector of length 2 with number of commits that +the upstream commit is ahead and behind the local commit +} +\description{ +Count the number of unique commits between two commit objects. +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit_1 <- commit(repo, "Commit message 1") + +# Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit_2 <- commit(repo, "Commit message 2") + +ahead_behind(commit_1, commit_2) +} +} diff -Nru r-cran-git2r-0.21.0/man/as.data.frame.git_repository.Rd r-cran-git2r-0.22.1/man/as.data.frame.git_repository.Rd --- r-cran-git2r-0.21.0/man/as.data.frame.git_repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/as.data.frame.git_repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,75 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{as.data.frame.git_repository} +\alias{as.data.frame.git_repository} +\title{Coerce Git repository to a \code{data.frame}} +\usage{ +\method{as.data.frame}{git_repository}(x, ...) +} +\arguments{ +\item{x}{The repository \code{object}} + +\item{...}{Additional arguments. Not used.} +} +\value{ +\code{data.frame} +} +\description{ +The commits in the repository are coerced to a \code{data.frame} +} +\details{ +The \code{data.frame} have the following columns: +\describe{ + +\item{sha}{ + The 40 character hexadecimal string of the SHA-1 + } + +\item{summary}{ + the short "summary" of the git commit message. + } + +\item{message}{ + the full message of a commit + } + +\item{author}{ + full name of the author + } + +\item{email}{ + email of the author + } + +\item{when}{ + time when the commit happened + } + +} +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create three files and commit +writeLines("First file", file.path(path, "example-1.txt")) +writeLines("Second file", file.path(path, "example-2.txt")) +writeLines("Third file", file.path(path, "example-3.txt")) +add(repo, "example-1.txt") +commit(repo, "Commit first file") +add(repo, "example-2.txt") +commit(repo, "Commit second file") +add(repo, "example-3.txt") +commit(repo, "Commit third file") + +## Coerce commits to a data.frame +df <- as(repo, "data.frame") +df +} +} diff -Nru r-cran-git2r-0.21.0/man/as.data.frame.git_tree.Rd r-cran-git2r-0.22.1/man/as.data.frame.git_tree.Rd --- r-cran-git2r-0.21.0/man/as.data.frame.git_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/as.data.frame.git_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{as.data.frame.git_tree} +\alias{as.data.frame.git_tree} +\title{Coerce entries in a git_tree to a \code{data.frame}} +\usage{ +\method{as.data.frame}{git_tree}(x, ...) +} +\arguments{ +\item{x}{The tree \code{object}} + +\item{...}{Additional arguments. Not used.} +} +\value{ +\code{data.frame} +} +\description{ +The entries in a tree are coerced to a \code{data.frame} +} +\details{ +The \code{data.frame} have the following columns: +\describe{ + +\item{filemode}{ + The UNIX file attributes of a tree entry + } + +\item{type}{ + String representation of the tree entry type + } + +\item{sha}{ + The sha of a tree entry + } + +\item{name}{ + The filename of a tree entry + } + +} +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +dir.create(file.path(path, "subfolder")) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create three files and commit +writeLines("First file", file.path(path, "example-1.txt")) +writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +writeLines("Third file", file.path(path, "example-3.txt")) +add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +commit(repo, "Commit message") + +## Display tree +tree(last_commit(repo)) + +## Coerce tree to a data.frame +df <- as(tree(last_commit(repo)), "data.frame") +df +} +} diff -Nru r-cran-git2r-0.21.0/man/as.list.git_tree.Rd r-cran-git2r-0.22.1/man/as.list.git_tree.Rd --- r-cran-git2r-0.21.0/man/as.list.git_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/as.list.git_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{as.list.git_tree} +\alias{as.list.git_tree} +\title{Coerce entries in a git_tree to a list of entry objects} +\usage{ +\method{as.list}{git_tree}(x, ...) +} +\arguments{ +\item{x}{The tree \code{object}} + +\item{...}{Unused} +} +\value{ +list of entry objects +} +\description{ +Coerce entries in a git_tree to a list of entry objects +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +dir.create(file.path(path, "subfolder")) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create three files and commit +writeLines("First file", file.path(path, "example-1.txt")) +writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +writeLines("Third file", file.path(path, "example-3.txt")) +add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +commit(repo, "Commit message") + +## Inspect size of each blob in tree +invisible(lapply(as(tree(last_commit(repo)), "list"), + function(obj) { + if (is_blob(obj)) + summary(obj) + NULL + })) +} +} diff -Nru r-cran-git2r-0.21.0/man/blame-methods.Rd r-cran-git2r-0.22.1/man/blame-methods.Rd --- r-cran-git2r-0.21.0/man/blame-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/blame-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blame.r -\docType{methods} -\name{blame} -\alias{blame} -\alias{blame,git_repository,character-method} -\title{Get blame for file} -\usage{ -blame(repo, path) - -\S4method{blame}{git_repository,character}(repo, path) -} -\arguments{ -\item{repo}{The repository} - -\item{path}{Path to the file to consider} -} -\value{ -S4 class git_blame object -} -\description{ -Get blame for file -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a first user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create a second user and change the file -config(repo, user.name="Bob", user.email="bob@example.org") -writeLines(c("Hello world!", "HELLO WORLD!", "HOLA"), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Second commit message") - -## Check blame -blame(repo, "example.txt") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/blame.Rd r-cran-git2r-0.22.1/man/blame.Rd --- r-cran-git2r-0.21.0/man/blame.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/blame.Rd 2018-07-09 19:28:38.000000000 +0000 @@ -0,0 +1,91 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blame.R +\name{blame} +\alias{blame} +\title{Get blame for file} +\usage{ +blame(repo = ".", path = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{path}{Path to the file to consider} +} +\value{ +git_blame object with the following entries: +\describe{ + \item{path}{ + The path to the file of the blame + } + \item{hunks}{ + List of blame hunks + } + \item{repo}{ + The git_repository that contains the file + } +} +\describe{ + \item{lines_in_hunk}{ + The number of lines in this hunk + } + \item{final_commit_id}{ + The sha of the commit where this line was last changed + } + \item{final_start_line_number}{ + The 1-based line number where this hunk begins, in the final + version of the file + } + \item{final_signature}{ + Final committer + } + \item{orig_commit_id}{ + The sha of the commit where this hunk was found. This will usually + be the same as 'final_commit_id'. + } + \item{orig_start_line_number}{ + The 1-based line number where this hunk begins in the file + named by 'orig_path' in the commit specified by 'orig_commit_id'. + } + \item{orig_signature}{ + Origin committer + } + \item{orig_path}{ + The path to the file where this hunk originated, as of the commit + specified by 'orig_commit_id' + } + \item{boundary}{ + TRUE iff the hunk has been tracked to a boundary commit. + } + \item{repo}{ + The \code{git_repository} object that contains the blame hunk + } +} +} +\description{ +Get blame for file +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a first user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Create a second user and change the file +config(repo, user.name="Bob", user.email="bob@example.org") +writeLines(c("Hello world!", "HELLO WORLD!", "HOLA"), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Second commit message") + +## Check blame +blame(repo, "example.txt") +} +} diff -Nru r-cran-git2r-0.21.0/man/blob_create-methods.Rd r-cran-git2r-0.22.1/man/blob_create-methods.Rd --- r-cran-git2r-0.21.0/man/blob_create-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/blob_create-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{blob_create} -\alias{blob_create} -\alias{blob_create,git_repository,character-method} -\title{Create blob from file on disk} -\usage{ -blob_create(repo, path, relative = TRUE) - -\S4method{blob_create}{git_repository,character}(repo, path, relative = TRUE) -} -\arguments{ -\item{repo}{The repository where the blob(s) will be written. Can -be a bare repository.} - -\item{path}{The file(s) from which the blob will be created.} - -\item{relative}{TRUE if the file(s) from which the blob will be -created is relative to the repository's working dir. Default is -TRUE.} -} -\value{ -list of S4 class git_blob \code{objects} -} -\description{ -Read a file from the filesystem and write its content to the -Object Database as a loose blob. The method is vectorized and -accepts a vector of files to create blobs from. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create blobs from files relative to workdir -writeLines("Hello, world!", file.path(path, "example-1.txt")) -writeLines("test content", file.path(path, "example-2.txt")) -blob_list_1 <- blob_create(repo, c("example-1.txt", - "example-2.txt")) - -## Create blobs from files not relative to workdir -temp_file_1 <- tempfile() -temp_file_2 <- tempfile() -writeLines("Hello, world!", temp_file_1) -writeLines("test content", temp_file_2) -blob_list_2 <- blob_create(repo, c(temp_file_1, temp_file_2), relative = FALSE) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/blob_create.Rd r-cran-git2r-0.22.1/man/blob_create.Rd --- r-cran-git2r-0.21.0/man/blob_create.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/blob_create.Rd 2018-07-09 19:28:38.000000000 +0000 @@ -0,0 +1,51 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blob.R +\name{blob_create} +\alias{blob_create} +\title{Create blob from file on disk} +\usage{ +blob_create(repo = ".", path = NULL, relative = TRUE) +} +\arguments{ +\item{repo}{The repository where the blob(s) will be written. Can +be a bare repository. A \code{git_repository} object, or a +path to a repository, or \code{NULL}. If the \code{repo} +argument is \code{NULL}, the repository is searched for with +\code{\link{discover_repository}} in the current working +directory.} + +\item{path}{The file(s) from which the blob will be created.} + +\item{relative}{TRUE if the file(s) from which the blob will be +created is relative to the repository's working dir. Default +is TRUE.} +} +\value{ +list of S3 class git_blob \code{objects} +} +\description{ +Read a file from the filesystem and write its content to the +Object Database as a loose blob. The method is vectorized and +accepts a vector of files to create blobs from. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create blobs from files relative to workdir +writeLines("Hello, world!", file.path(path, "example-1.txt")) +writeLines("test content", file.path(path, "example-2.txt")) +blob_list_1 <- blob_create(repo, c("example-1.txt", + "example-2.txt")) + +## Create blobs from files not relative to workdir +temp_file_1 <- tempfile() +temp_file_2 <- tempfile() +writeLines("Hello, world!", temp_file_1) +writeLines("test content", temp_file_2) +blob_list_2 <- blob_create(repo, c(temp_file_1, temp_file_2), relative = FALSE) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_create-methods.Rd r-cran-git2r-0.22.1/man/branch_create-methods.Rd --- r-cran-git2r-0.21.0/man/branch_create-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_create-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_create} -\alias{branch_create} -\alias{branch_create,git_commit-method} -\title{Create a branch} -\usage{ -branch_create(commit, name, force = FALSE) - -\S4method{branch_create}{git_commit}(commit, name, force = FALSE) -} -\arguments{ -\item{commit}{Commit to which branch should point.} - -\item{name}{Name for the branch} - -\item{force}{Overwrite existing branch. Default = FALSE} -} -\value{ -invisible S4 class git_branch object -} -\description{ -Create a branch -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") - -## Create a branch -branch_1 <- branch_create(commit_1, name = "test-branch") - -## Add one more commit -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "example.txt")) -add(repo, "example.txt") -commit_2 <- commit(repo, "Another commit message") - -## Create a branch with the same name should fail -try(branch_create(commit_2, name = "test-branch"), TRUE) - -## Force it -branch_2 <- branch_create(commit_2, name = "test-branch", force = TRUE) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_create.Rd r-cran-git2r-0.22.1/man/branch_create.Rd --- r-cran-git2r-0.21.0/man/branch_create.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_create.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_create} +\alias{branch_create} +\title{Create a branch} +\usage{ +branch_create(commit = NULL, name = NULL, force = FALSE) +} +\arguments{ +\item{commit}{Commit to which branch should point.} + +\item{name}{Name for the branch} + +\item{force}{Overwrite existing branch. Default = FALSE} +} +\value{ +invisible git_branch object +} +\description{ +Create a branch +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") + +## Create a branch +branch_1 <- branch_create(commit_1, name = "test-branch") + +## Add one more commit +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "example.txt")) +add(repo, "example.txt") +commit_2 <- commit(repo, "Another commit message") + +## Create a branch with the same name should fail +try(branch_create(commit_2, name = "test-branch"), TRUE) + +## Force it +branch_2 <- branch_create(commit_2, name = "test-branch", force = TRUE) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_delete-methods.Rd r-cran-git2r-0.22.1/man/branch_delete-methods.Rd --- r-cran-git2r-0.21.0/man/branch_delete-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_delete-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_delete} -\alias{branch_delete} -\alias{branch_delete,git_branch-method} -\title{Delete a branch} -\usage{ -branch_delete(branch) - -\S4method{branch_delete}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch} -} -\value{ -invisible NULL -} -\description{ -Delete a branch -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") - -## Create a 'dev' branch -dev <- branch_create(commit_1, name = "dev") -branches(repo) - -## Delete 'dev' branch -branch_delete(dev) -branches(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_delete.Rd r-cran-git2r-0.22.1/man/branch_delete.Rd --- r-cran-git2r-0.21.0/man/branch_delete.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_delete.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_delete} +\alias{branch_delete} +\title{Delete a branch} +\usage{ +branch_delete(branch = NULL) +} +\arguments{ +\item{branch}{The branch} +} +\value{ +invisible NULL +} +\description{ +Delete a branch +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") + +## Create a 'dev' branch +dev <- branch_create(commit_1, name = "dev") +branches(repo) + +## Delete 'dev' branch +branch_delete(dev) +branches(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/branches-methods.Rd r-cran-git2r-0.22.1/man/branches-methods.Rd --- r-cran-git2r-0.21.0/man/branches-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branches-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branches} -\alias{branches} -\alias{branches,missing-method} -\alias{branches,git_repository-method} -\title{Branches} -\usage{ -branches(repo, flags = c("all", "local", "remote")) - -\S4method{branches}{missing}(flags) - -\S4method{branches}{git_repository}(repo, flags = c("all", "local", "remote")) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} - -\item{flags}{Filtering flags for the branch listing. Valid values -are 'all', 'local' or 'remote'} -} -\value{ -list of branches in repository -} -\description{ -List branches in repository -} -\examples{ -\dontrun{ -## Initialize repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config first user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## List branches -branches(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branches.Rd r-cran-git2r-0.22.1/man/branches.Rd --- r-cran-git2r-0.21.0/man/branches.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branches.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branches} +\alias{branches} +\title{Branches} +\usage{ +branches(repo = ".", flags = c("all", "local", "remote")) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{flags}{Filtering flags for the branch listing. Valid values +are 'all', 'local' or 'remote'} +} +\value{ +list of branches in repository +} +\description{ +List branches in repository +} +\examples{ +\dontrun{ +## Initialize repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config first user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## List branches +branches(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_get_upstream-methods.Rd r-cran-git2r-0.22.1/man/branch_get_upstream-methods.Rd --- r-cran-git2r-0.21.0/man/branch_get_upstream-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_get_upstream-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_get_upstream} -\alias{branch_get_upstream} -\alias{branch_get_upstream,git_branch-method} -\title{Get remote tracking branch} -\usage{ -branch_get_upstream(branch) - -\S4method{branch_get_upstream}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch} -} -\value{ -S4 class git_branch or NULL if no remote tracking branch. -} -\description{ -Get remote tracking branch, given a local branch. -} -\examples{ -\dontrun{ -## Initialize two temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## Get remote tracking branch -branch_get_upstream(head(repo)) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_get_upstream.Rd r-cran-git2r-0.22.1/man/branch_get_upstream.Rd --- r-cran-git2r-0.21.0/man/branch_get_upstream.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_get_upstream.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_get_upstream} +\alias{branch_get_upstream} +\title{Get remote tracking branch} +\usage{ +branch_get_upstream(branch = NULL) +} +\arguments{ +\item{branch}{The branch} +} +\value{ +\code{git_branch} object or NULL if no remote tracking + branch. +} +\description{ +Get remote tracking branch, given a local branch. +} +\examples{ +\dontrun{ +## Initialize two temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## Get remote tracking branch +branch_get_upstream(repository_head(repo)) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_remote_name-methods.Rd r-cran-git2r-0.22.1/man/branch_remote_name-methods.Rd --- r-cran-git2r-0.21.0/man/branch_remote_name-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_remote_name-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_remote_name} -\alias{branch_remote_name} -\alias{branch_remote_name,git_branch-method} -\title{Remote name of a branch} -\usage{ -branch_remote_name(branch) - -\S4method{branch_remote_name}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch} -} -\value{ -character string with remote name -} -\description{ -The name of remote that the remote tracking branch belongs to -} -\examples{ -\dontrun{ -## Initialize two temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## Get remote name -branch_remote_name(branches(repo)[[2]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_remote_name.Rd r-cran-git2r-0.22.1/man/branch_remote_name.Rd --- r-cran-git2r-0.21.0/man/branch_remote_name.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_remote_name.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_remote_name} +\alias{branch_remote_name} +\title{Remote name of a branch} +\usage{ +branch_remote_name(branch = NULL) +} +\arguments{ +\item{branch}{The branch} +} +\value{ +character string with remote name +} +\description{ +The name of remote that the remote tracking branch belongs to +} +\examples{ +\dontrun{ +## Initialize two temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## Get remote name +branch_remote_name(branches(repo)[[2]]) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_remote_url-methods.Rd r-cran-git2r-0.22.1/man/branch_remote_url-methods.Rd --- r-cran-git2r-0.21.0/man/branch_remote_url-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_remote_url-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_remote_url} -\alias{branch_remote_url} -\alias{branch_remote_url,git_branch-method} -\title{Remote url of a branch} -\usage{ -branch_remote_url(branch) - -\S4method{branch_remote_url}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch} -} -\value{ -character string with remote url -} -\description{ -Remote url of a branch -} -\examples{ -\dontrun{ -## Initialize two temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## Get remote url of tracking branch to branch 'master' -branch_remote_url(branch_get_upstream(head(repo))) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_remote_url.Rd r-cran-git2r-0.22.1/man/branch_remote_url.Rd --- r-cran-git2r-0.21.0/man/branch_remote_url.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_remote_url.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_remote_url} +\alias{branch_remote_url} +\title{Remote url of a branch} +\usage{ +branch_remote_url(branch = NULL) +} +\arguments{ +\item{branch}{The branch} +} +\value{ +character string with remote url +} +\description{ +Remote url of a branch +} +\examples{ +\dontrun{ +## Initialize two temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## Get remote url of tracking branch to branch 'master' +branch_remote_url(branch_get_upstream(repository_head(repo))) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_rename-methods.Rd r-cran-git2r-0.22.1/man/branch_rename-methods.Rd --- r-cran-git2r-0.21.0/man/branch_rename-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_rename-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_rename} -\alias{branch_rename} -\alias{branch_rename,git_branch-method} -\title{Rename a branch} -\usage{ -branch_rename(branch, name, force = FALSE) - -\S4method{branch_rename}{git_branch}(branch, name, force = FALSE) -} -\arguments{ -\item{branch}{Branch to rename} - -\item{name}{The new name for the branch} - -\item{force}{Overwrite existing branch. Default is FALSE} -} -\value{ -invisible renamed S4 class git_branch -} -\description{ -Rename a branch -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Rename 'master' branch to 'dev' -branches(repo) -branch_rename(head(repo), "dev") -branches(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_rename.Rd r-cran-git2r-0.22.1/man/branch_rename.Rd --- r-cran-git2r-0.21.0/man/branch_rename.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_rename.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_rename} +\alias{branch_rename} +\title{Rename a branch} +\usage{ +branch_rename(branch = NULL, name = NULL, force = FALSE) +} +\arguments{ +\item{branch}{Branch to rename} + +\item{name}{The new name for the branch} + +\item{force}{Overwrite existing branch. Default is FALSE} +} +\value{ +invisible renamed \code{git_branch} object +} +\description{ +Rename a branch +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Rename 'master' branch to 'dev' +branches(repo) +branch_rename(repository_head(repo), "dev") +branches(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_set_upstream-methods.Rd r-cran-git2r-0.22.1/man/branch_set_upstream-methods.Rd --- r-cran-git2r-0.21.0/man/branch_set_upstream-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_set_upstream-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_set_upstream} -\alias{branch_set_upstream} -\alias{branch_set_upstream,git_branch-method} -\title{Set remote tracking branch} -\usage{ -branch_set_upstream(branch, name) - -\S4method{branch_set_upstream}{git_branch}(branch, name) -} -\arguments{ -\item{branch}{The branch to configure} - -\item{name}{remote-tracking or local branch to set as -upstream. Pass NULL to unset.} -} -\value{ -invisible NULL -} -\description{ -Set the upstream configuration for a given local branch -} -\examples{ -\dontrun{ -## Initialize two temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## Unset remote remote tracking branch -branch_get_upstream(head(repo)) -branch_set_upstream(head(repo), NULL) -branch_get_upstream(head(repo)) - -## Set remote tracking branch -branch_set_upstream(head(repo), "origin/master") -branch_get_upstream(head(repo)) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_set_upstream.Rd r-cran-git2r-0.22.1/man/branch_set_upstream.Rd --- r-cran-git2r-0.21.0/man/branch_set_upstream.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_set_upstream.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_set_upstream} +\alias{branch_set_upstream} +\title{Set remote tracking branch} +\usage{ +branch_set_upstream(branch = NULL, name) +} +\arguments{ +\item{branch}{The branch to configure} + +\item{name}{remote-tracking or local branch to set as +upstream. Pass NULL to unset.} +} +\value{ +invisible NULL +} +\description{ +Set the upstream configuration for a given local branch +} +\examples{ +\dontrun{ +## Initialize two temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## Unset remote remote tracking branch +branch_get_upstream(repository_head(repo)) +branch_set_upstream(repository_head(repo), NULL) +branch_get_upstream(repository_head(repo)) + +## Set remote tracking branch +branch_set_upstream(repository_head(repo), "origin/master") +branch_get_upstream(repository_head(repo)) +} +} diff -Nru r-cran-git2r-0.21.0/man/branch_target-methods.Rd r-cran-git2r-0.22.1/man/branch_target-methods.Rd --- r-cran-git2r-0.21.0/man/branch_target-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_target-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{branch_target} -\alias{branch_target} -\alias{branch_target,git_branch-method} -\title{Get target (sha) pointed to by a branch} -\usage{ -branch_target(branch) - -\S4method{branch_target}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch} -} -\value{ -sha or NA if not a direct reference -} -\description{ -Get target (sha) pointed to by a branch -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Get target (sha) pointed to by 'master' branch -branch_target(head(repo)) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/branch_target.Rd r-cran-git2r-0.22.1/man/branch_target.Rd --- r-cran-git2r-0.21.0/man/branch_target.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/branch_target.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{branch_target} +\alias{branch_target} +\title{Get target (sha) pointed to by a branch} +\usage{ +branch_target(branch = NULL) +} +\arguments{ +\item{branch}{The branch} +} +\value{ +sha or NA if not a direct reference +} +\description{ +Get target (sha) pointed to by a branch +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Get target (sha) pointed to by 'master' branch +branch_target(repository_head(repo)) +} +} diff -Nru r-cran-git2r-0.21.0/man/bundle_r_package-methods.Rd r-cran-git2r-0.22.1/man/bundle_r_package-methods.Rd --- r-cran-git2r-0.21.0/man/bundle_r_package-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/bundle_r_package-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/bundle_r_package.r -\docType{methods} -\name{bundle_r_package} -\alias{bundle_r_package} -\alias{bundle_r_package,git_repository-method} -\title{Bundle bare repo of package} -\usage{ -bundle_r_package(repo) - -\S4method{bundle_r_package}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository with package to bundle.} -} -\value{ -Invisible bundled S4 \code{\linkS4class{git_repository}} -object -} -\description{ -Clone the package git repository as a bare repository to -\code{pkg/inst/pkg.git} -} -\examples{ -\dontrun{ -## Initialize repository -path <- tempfile() -dir.create(path) -path <- file.path(path, "git2r") -repo <- clone("https://github.com/ropensci/git2r.git", path) - -## Bundle bare repository in package -bundle_r_package(repo) - -## Build and install bundled package -wd <- setwd(dirname(path)) -system(sprintf("R CMD build \%s", path)) -pkg <- list.files(".", pattern = "[.]tar[.]gz$") -system(sprintf("R CMD INSTALL \%s", pkg)) -setwd(wd) - -## Reload package -detach("package:git2r", unload = TRUE) -library(git2r) - -## Summarize last five commits of bundled repo -repo <- repository(system.file("git2r.git", package = "git2r")) -invisible(lapply(commits(repo, n = 5), summary)) - -## Plot content of bundled repo -plot(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/bundle_r_package.Rd r-cran-git2r-0.22.1/man/bundle_r_package.Rd --- r-cran-git2r-0.21.0/man/bundle_r_package.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/bundle_r_package.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bundle_r_package.R +\name{bundle_r_package} +\alias{bundle_r_package} +\title{Bundle bare repo of package} +\usage{ +bundle_r_package(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +Invisible bundled \code{git_repository} object +} +\description{ +Clone the package git repository as a bare repository to +\code{pkg/inst/pkg.git} +} +\examples{ +\dontrun{ +## Initialize repository +path <- tempfile() +dir.create(path) +path <- file.path(path, "git2r") +repo <- clone("https://github.com/ropensci/git2r.git", path) + +## Bundle bare repository in package +bundle_r_package(repo) + +## Build and install bundled package +wd <- setwd(dirname(path)) +system(sprintf("R CMD build \%s", path)) +pkg <- list.files(".", pattern = "[.]tar[.]gz$") +system(sprintf("R CMD INSTALL \%s", pkg)) +setwd(wd) + +## Reload package +detach("package:git2r", unload = TRUE) +library(git2r) + +## Summarize last five commits of bundled repo +repo <- repository(system.file("git2r.git", package = "git2r")) +invisible(lapply(commits(repo, n = 5), summary)) + +## Plot content of bundled repo +plot(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/checkout-methods.Rd r-cran-git2r-0.22.1/man/checkout-methods.Rd --- r-cran-git2r-0.21.0/man/checkout-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/checkout-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/checkout.r -\docType{methods} -\name{checkout} -\alias{checkout} -\alias{checkout,git_repository-method} -\alias{checkout,git_branch-method} -\alias{checkout,git_commit-method} -\alias{checkout,git_tag-method} -\title{Checkout} -\usage{ -checkout(object, ...) - -\S4method{checkout}{git_repository}(object, branch = NULL, create = FALSE, - force = FALSE, path = NULL, ...) - -\S4method{checkout}{git_branch}(object, force = FALSE) - -\S4method{checkout}{git_commit}(object, force = FALSE) - -\S4method{checkout}{git_tag}(object, force = FALSE) -} -\arguments{ -\item{object}{A repository, commit, tag or tree which content will -be used to update the working directory.} - -\item{...}{Additional arguments affecting the checkout} - -\item{branch}{If object is a repository, the name of the branch to -check out. Default is NULL.} - -\item{create}{If object is a repository, then branch is created if -doesn't exist.} - -\item{force}{If TRUE, then make working directory match -target. This will throw away local changes. Default is FALSE.} - -\item{path}{Limit the checkout operation to only certain -paths. This argument is only used if branch is NULL. Default is -NULL.} -} -\value{ -invisible NULL -} -\description{ -Update files in the index and working tree to match the content of -the tree pointed at by the treeish object (commit, tag or tree). -Checkout using the default GIT_CHECKOUT_SAFE_CREATE strategy -(force = FALSE) or GIT_CHECKOUT_FORCE (force = TRUE). -} -\examples{ -\dontrun{ -## Create directories and initialize repositories -path_bare <- tempfile(pattern="git2r-") -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo_1) -dir.create(path_repo_2) -repo_bare <- init(path_bare, bare = TRUE) - -## Clone to repo 1 and config user -repo_1 <- clone(path_bare, path_repo_1) -config(repo_1, user.name="Alice", user.email="alice@example.org") - -## Add changes to repo 1 and push to bare -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path_repo_1, "test.txt")) -add(repo_1, "test.txt") -commit(repo_1, "First commit message") -push(repo_1, "origin", "refs/heads/master") - -## Create and checkout 'dev' branch in repo 1 -checkout(repo_1, "dev", create = TRUE) - -## Add changes to 'dev' branch in repo 1 and push to bare -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path_repo_1, "test.txt")) -add(repo_1, "test.txt") -commit(repo_1, "Second commit message") -push(repo_1, "origin", "refs/heads/dev") - -## Clone to repo 2 -repo_2 <- clone(path_bare, path_repo_2) -config(repo_2, user.name="Bob", user.email="bob@example.org") - -## Read content of 'test.txt' -readLines(file.path(path_repo_2, "test.txt")) - -## Checkout dev branch -checkout(repo_2, "dev") - -## Read content of 'test.txt' -readLines(file.path(path_repo_2, "test.txt")) - -## Edit "test.txt" in repo_2 -writeLines("Hello world!", con = file.path(path_repo_2, "test.txt")) - -## Check status -status(repo_2) - -## Checkout "test.txt" -checkout(repo_2, path = "test.txt") - -## Check status -status(repo_2) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/checkout.Rd r-cran-git2r-0.22.1/man/checkout.Rd --- r-cran-git2r-0.21.0/man/checkout.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/checkout.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,100 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/checkout.R +\name{checkout} +\alias{checkout} +\title{Checkout} +\usage{ +checkout(object = NULL, branch = NULL, create = FALSE, force = FALSE, + path = NULL, ...) +} +\arguments{ +\item{object}{A path to a repository, or a \code{git_repository} +object, or a \code{git_commit} object, or a \code{git_tag} +object, or a \code{git_tree} object.} + +\item{branch}{name of the branch to check out. Only used if object +is a path to a repository or a \code{git_repository} object.} + +\item{create}{create branch if it doesn't exist. Only used if +object is a path to a repository or a \code{git_repository} +object.} + +\item{force}{If \code{TRUE}, then make working directory match +target. This will throw away local changes. Default is +\code{FALSE}.} + +\item{path}{Limit the checkout operation to only certain +paths. This argument is only used if branch is NULL. Default +is \code{NULL}.} + +\item{...}{Additional arguments. Not used.} +} +\value{ +invisible NULL +} +\description{ +Update files in the index and working tree to match the content of +the tree pointed at by the treeish object (commit, tag or tree). +The default checkout strategy (\code{force = FALSE}) will only +make modifications that will not lose changes. Use \code{force = +TRUE} to force working directory to look like index. +} +\examples{ +\dontrun{ +## Create directories and initialize repositories +path_bare <- tempfile(pattern="git2r-") +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo_1) +dir.create(path_repo_2) +repo_bare <- init(path_bare, bare = TRUE) + +## Clone to repo 1 and config user +repo_1 <- clone(path_bare, path_repo_1) +config(repo_1, user.name="Alice", user.email="alice@example.org") + +## Add changes to repo 1 and push to bare +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path_repo_1, "test.txt")) +add(repo_1, "test.txt") +commit(repo_1, "First commit message") +push(repo_1, "origin", "refs/heads/master") + +## Create and checkout 'dev' branch in repo 1 +checkout(repo_1, "dev", create = TRUE) + +## Add changes to 'dev' branch in repo 1 and push to bare +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path_repo_1, "test.txt")) +add(repo_1, "test.txt") +commit(repo_1, "Second commit message") +push(repo_1, "origin", "refs/heads/dev") + +## Clone to repo 2 +repo_2 <- clone(path_bare, path_repo_2) +config(repo_2, user.name="Bob", user.email="bob@example.org") + +## Read content of 'test.txt' +readLines(file.path(path_repo_2, "test.txt")) + +## Checkout dev branch +checkout(repo_2, "dev") + +## Read content of 'test.txt' +readLines(file.path(path_repo_2, "test.txt")) + +## Edit "test.txt" in repo_2 +writeLines("Hello world!", con = file.path(path_repo_2, "test.txt")) + +## Check status +status(repo_2) + +## Checkout "test.txt" +checkout(repo_2, path = "test.txt") + +## Check status +status(repo_2) +} +} diff -Nru r-cran-git2r-0.21.0/man/clone-methods.Rd r-cran-git2r-0.22.1/man/clone-methods.Rd --- r-cran-git2r-0.21.0/man/clone-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/clone-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{clone} -\alias{clone} -\alias{clone,character,character-method} -\title{Clone a remote repository} -\usage{ -clone(url, local_path, bare = FALSE, branch = NULL, checkout = TRUE, - credentials = NULL, progress = TRUE) - -\S4method{clone}{character,character}(url, local_path, bare = FALSE, - branch = NULL, checkout = TRUE, credentials = NULL, progress = TRUE) -} -\arguments{ -\item{url}{The remote repository to clone} - -\item{local_path}{Local directory to clone to.} - -\item{bare}{Create a bare repository. Default is FALSE.} - -\item{branch}{The name of the branch to checkout. Default is NULL -which means to use the remote's default branch.} - -\item{checkout}{Checkout HEAD after the clone is complete. Default is TRUE.} - -\item{credentials}{The credentials for remote repository -access. Default is NULL. To use and query an ssh-agent for the ssh -key credentials, let this parameter be NULL (the default).} - -\item{progress}{Show progress. Default is TRUE.} -} -\value{ -A S4 \code{\linkS4class{git_repository}} object -} -\description{ -Clone a remote repository -} -\examples{ -\dontrun{ -## Initialize repository -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") -dir.create(path_repo_1) -dir.create(path_repo_2) -repo_1 <- init(path_repo_1) - -## Config user and commit a file -config(repo_1, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "First commit message") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Second commit message") - -## Change file again and commit. -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", - "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Third commit message") - -## Clone to second repository -repo_2 <- clone(path_repo_1, path_repo_2) - -## List commits in repositories -commits(repo_1) -commits(repo_2) -} -} -\seealso{ -\code{\linkS4class{cred_user_pass}}, -\code{\linkS4class{cred_ssh_key}} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/clone.Rd r-cran-git2r-0.22.1/man/clone.Rd --- r-cran-git2r-0.21.0/man/clone.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/clone.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,79 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{clone} +\alias{clone} +\title{Clone a remote repository} +\usage{ +clone(url = NULL, local_path = NULL, bare = FALSE, branch = NULL, + checkout = TRUE, credentials = NULL, progress = TRUE) +} +\arguments{ +\item{url}{The remote repository to clone} + +\item{local_path}{Local directory to clone to.} + +\item{bare}{Create a bare repository. Default is FALSE.} + +\item{branch}{The name of the branch to checkout. Default is NULL +which means to use the remote's default branch.} + +\item{checkout}{Checkout HEAD after the clone is complete. Default +is TRUE.} + +\item{credentials}{The credentials for remote repository +access. Default is NULL. To use and query an ssh-agent for the +ssh key credentials, let this parameter be NULL (the default).} + +\item{progress}{Show progress. Default is TRUE.} +} +\value{ +A \code{git_repository} object. +} +\description{ +Clone a remote repository +} +\examples{ +\dontrun{ +## Initialize repository +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") +dir.create(path_repo_1) +dir.create(path_repo_2) +repo_1 <- init(path_repo_1) + +## Config user and commit a file +config(repo_1, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "First commit message") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Second commit message") + +## Change file again and commit. +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Third commit message") + +## Clone to second repository +repo_2 <- clone(path_repo_1, path_repo_2) + +## List commits in repositories +commits(repo_1) +commits(repo_2) +} +} +\seealso{ +\link{repository}, \code{\link{cred_user_pass}}, + \code{\link{cred_ssh_key}} +} diff -Nru r-cran-git2r-0.21.0/man/coerce-git_commit-method.Rd r-cran-git2r-0.22.1/man/coerce-git_commit-method.Rd --- r-cran-git2r-0.21.0/man/coerce-git_commit-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/coerce-git_commit-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{coerce-git_commit-method} -\alias{coerce-git_commit-method} -\alias{coerce,git_commit,data.frame-method} -\title{Coerce a commit to a \code{data.frame}} -\arguments{ -\item{from}{The commit \code{object}} -} -\value{ -\code{data.frame} -} -\description{ -The commit is coerced to a \code{data.frame} -} -\details{ -The \code{data.frame} have the following columns: -\describe{ - -\item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - -\item{summary}{ - the short "summary" of the git commit message. - } - -\item{message}{ - the full message of a commit - } - -\item{author}{ - full name of the author - } - -\item{email}{ - email of the author - } - -\item{when}{ - time when the commit happened - } - -} -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file and commit -writeLines("Example file", file.path(path, "example.txt")) -add(repo, "example.txt") -c1 <- commit(repo, "Commit message") - -## Coerce the commit to a data.frame -df <- as(c1, "data.frame") -df -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/coerce-git_repository-method.Rd r-cran-git2r-0.22.1/man/coerce-git_repository-method.Rd --- r-cran-git2r-0.21.0/man/coerce-git_repository-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/coerce-git_repository-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{coerce-git_repository-method} -\alias{coerce-git_repository-method} -\alias{coerce,git_repository,data.frame-method} -\title{Coerce Git repository to a \code{data.frame}} -\arguments{ -\item{from}{The repository \code{object}} -} -\value{ -\code{data.frame} -} -\description{ -The commits in the repository are coerced to a \code{data.frame} -} -\details{ -The \code{data.frame} have the following columns: -\describe{ - -\item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - -\item{summary}{ - the short "summary" of the git commit message. - } - -\item{message}{ - the full message of a commit - } - -\item{author}{ - full name of the author - } - -\item{email}{ - email of the author - } - -\item{when}{ - time when the commit happened - } - -} -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create three files and commit -writeLines("First file", file.path(path, "example-1.txt")) -writeLines("Second file", file.path(path, "example-2.txt")) -writeLines("Third file", file.path(path, "example-3.txt")) -add(repo, "example-1.txt") -commit(repo, "Commit first file") -add(repo, "example-2.txt") -commit(repo, "Commit second file") -add(repo, "example-3.txt") -commit(repo, "Commit third file") - -## Coerce commits to a data.frame -df <- as(repo, "data.frame") -df -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/coerce-git_tree-data.frame-method.Rd r-cran-git2r-0.22.1/man/coerce-git_tree-data.frame-method.Rd --- r-cran-git2r-0.21.0/man/coerce-git_tree-data.frame-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/coerce-git_tree-data.frame-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{coerce-git_tree-data.frame-method} -\alias{coerce-git_tree-data.frame-method} -\alias{coerce,git_tree,data.frame-method} -\title{Coerce entries in a git_tree to a \code{data.frame}} -\arguments{ -\item{from}{The tree \code{object}} -} -\value{ -\code{data.frame} -} -\description{ -The entries in a tree are coerced to a \code{data.frame} -} -\details{ -The \code{data.frame} have the following columns: -\describe{ - -\item{filemode}{ - The UNIX file attributes of a tree entry - } - -\item{type}{ - String representation of the tree entry type - } - -\item{sha}{ - The sha of a tree entry - } - -\item{name}{ - The filename of a tree entry - } - -} -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -dir.create(file.path(path, "subfolder")) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create three files and commit -writeLines("First file", file.path(path, "example-1.txt")) -writeLines("Second file", file.path(path, "subfolder/example-2.txt")) -writeLines("Third file", file.path(path, "example-3.txt")) -add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) -new_commit <- commit(repo, "Commit message") - -## Coerce tree to a data.frame -df <- as(tree(new_commit), "data.frame") -df -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/coerce-git_tree-list-method.Rd r-cran-git2r-0.22.1/man/coerce-git_tree-list-method.Rd --- r-cran-git2r-0.21.0/man/coerce-git_tree-list-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/coerce-git_tree-list-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{coerce-git_tree-list-method} -\alias{coerce-git_tree-list-method} -\title{Coerce entries in a git_tree to a list of entry objects} -\arguments{ -\item{from}{The tree \code{object}} -} -\value{ -list of entry objects -} -\description{ -Coerce entries in a git_tree to a list of entry objects -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -dir.create(file.path(path, "subfolder")) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create three files and commit -writeLines("First file", file.path(path, "example-1.txt")) -writeLines("Second file", file.path(path, "subfolder/example-2.txt")) -writeLines("Third file", file.path(path, "example-3.txt")) -add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) -new_commit <- commit(repo, "Commit message") - -## Inspect size of each blob in tree -invisible(lapply(as(tree(new_commit), "list"), - function(obj) { - if (is_blob(obj)) - summary(obj) - NULL - })) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/commit-methods.Rd r-cran-git2r-0.22.1/man/commit-methods.Rd --- r-cran-git2r-0.21.0/man/commit-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/commit-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{commit} -\alias{commit} -\alias{commit,git_repository-method} -\title{Commit} -\usage{ -commit(repo, message = NULL, all = FALSE, session = FALSE, - reference = "HEAD", author = default_signature(repo), - committer = default_signature(repo)) - -\S4method{commit}{git_repository}(repo, message = NULL, all = FALSE, - session = FALSE, reference = "HEAD", author = default_signature(repo), - committer = default_signature(repo)) -} -\arguments{ -\item{repo}{The repository \code{object}.} - -\item{message}{The commit message.} - -\item{all}{Stage modified and deleted files. Files not added to -Git are not affected.} - -\item{session}{Add sessionInfo to commit message. Default is -FALSE.} - -\item{reference}{Name of the reference that will be updated to -point to this commit.} - -\item{author}{Signature with author and author time of commit.} - -\item{committer}{Signature with committer and commit time of commit.} -} -\value{ -\code{\linkS4class{git_commit}} object -} -\description{ -Commit -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/commit.Rd r-cran-git2r-0.22.1/man/commit.Rd --- r-cran-git2r-0.21.0/man/commit.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/commit.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,70 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{commit} +\alias{commit} +\title{Commit} +\usage{ +commit(repo = ".", message = NULL, all = FALSE, session = FALSE, + author = NULL, committer = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{message}{The commit message.} + +\item{all}{Stage modified and deleted files. Files not added to +Git are not affected.} + +\item{session}{Add sessionInfo to commit message. Default is +FALSE.} + +\item{author}{Signature with author and author time of commit.} + +\item{committer}{Signature with committer and commit time of +commit.} +} +\value{ +A list of class \code{git_commit} with entries: +\describe{ + \item{sha}{ + The 40 character hexadecimal string of the SHA-1 + } + \item{author}{ + An author signature + } + \item{committer}{ + The committer signature + } + \item{summary}{ + The short "summary" of a git commit message, comprising the first + paragraph of the message with whitespace trimmed and squashed. + } + \item{message}{ + The message of a commit + } + \item{repo}{ + The \code{git_repository} object that contains the commit + } +} +} +\description{ +Commit +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") +} +} diff -Nru r-cran-git2r-0.21.0/man/commits-methods.Rd r-cran-git2r-0.22.1/man/commits-methods.Rd --- r-cran-git2r-0.21.0/man/commits-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/commits-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{commits} -\alias{commits} -\alias{commits,missing-method} -\alias{commits,git_repository-method} -\title{Commits} -\usage{ -commits(repo, ...) - -\S4method{commits}{missing}(topological = TRUE, time = TRUE, - reverse = FALSE, n = NULL, ...) - -\S4method{commits}{git_repository}(repo, topological = TRUE, time = TRUE, - reverse = FALSE, n = NULL, ...) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} - -\item{...}{Additional arguments to commits.} - -\item{topological}{Sort the commits in topological order (parents -before children); can be combined with time sorting. Default is -TRUE.} - -\item{time}{Sort the commits by commit time; Can be combined with -topological sorting. Default is TRUE.} - -\item{reverse}{Sort the commits in reverse order; can be combined -with topological and/or time sorting. Default is FALSE.} - -\item{n}{The upper limit of the number of commits to output. The -defualt is NULL for unlimited number of commits.} -} -\value{ -list of commits in repository -} -\description{ -Commits -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Second commit message") - -## Change file again and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", - "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Third commit message") - -## List commits in repository -commits(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/commits.Rd r-cran-git2r-0.22.1/man/commits.Rd --- r-cran-git2r-0.21.0/man/commits.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/commits.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{commits} +\alias{commits} +\title{Commits} +\usage{ +commits(repo = ".", topological = TRUE, time = TRUE, reverse = FALSE, + n = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{topological}{Sort the commits in topological order (parents +before children); can be combined with time sorting. Default +is TRUE.} + +\item{time}{Sort the commits by commit time; Can be combined with +topological sorting. Default is TRUE.} + +\item{reverse}{Sort the commits in reverse order; can be combined +with topological and/or time sorting. Default is FALSE.} + +\item{n}{The upper limit of the number of commits to output. The +defualt is NULL for unlimited number of commits.} +} +\value{ +list of commits in repository +} +\description{ +Commits +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Second commit message") + +## Change file again and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Third commit message") + +## List commits in repository +commits(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/config.Rd r-cran-git2r-0.22.1/man/config.Rd --- r-cran-git2r-0.21.0/man/config.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/config.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/config.r +% Please edit documentation in R/config.R \name{config} \alias{config} \title{Config} diff -Nru r-cran-git2r-0.21.0/man/content-methods.Rd r-cran-git2r-0.22.1/man/content-methods.Rd --- r-cran-git2r-0.21.0/man/content-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/content-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{content} -\alias{content} -\alias{content,git_blob-method} -\title{Content of blob} -\usage{ -content(blob, split = TRUE) - -\S4method{content}{git_blob}(blob, split = TRUE) -} -\arguments{ -\item{blob}{The blob \code{object}.} - -\item{split}{Split blob content to text lines. Default TRUE.} -} -\value{ -The content of the blob. NA_character_ if the blob is binary. -} -\description{ -Content of blob -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Display content of blob. -content(tree(commits(repo)[[1]])["example.txt"]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/content.Rd r-cran-git2r-0.22.1/man/content.Rd --- r-cran-git2r-0.21.0/man/content.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/content.Rd 2018-07-09 19:28:38.000000000 +0000 @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blob.R +\name{content} +\alias{content} +\title{Content of blob} +\usage{ +content(blob = NULL, split = TRUE) +} +\arguments{ +\item{blob}{The blob object.} + +\item{split}{Split blob content to text lines. Default TRUE.} +} +\value{ +The content of the blob. NA_character_ if the blob is binary. +} +\description{ +Content of blob +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Display content of blob. +content(tree(commits(repo)[[1]])["example.txt"]) +} +} diff -Nru r-cran-git2r-0.21.0/man/contributions-methods.Rd r-cran-git2r-0.22.1/man/contributions-methods.Rd --- r-cran-git2r-0.21.0/man/contributions-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/contributions-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/contributions.r -\docType{methods} -\name{contributions} -\alias{contributions} -\alias{contributions,missing-method} -\alias{contributions,character-method} -\alias{contributions,git_repository-method} -\title{Contributions} -\usage{ -contributions(repo, breaks = c("month", "year", "quarter", "week", "day"), - by = c("commits", "author")) - -\S4method{contributions}{missing}(breaks, by) - -\S4method{contributions}{character}(repo, breaks = c("month", "year", - "quarter", "week", "day"), by = c("commits", "author")) - -\S4method{contributions}{git_repository}(repo, breaks = c("month", "year", - "quarter", "week", "day"), by = c("commits", "author")) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} - -\item{breaks}{Default is \code{month}. Change to year, quarter, -week or day as necessary.} - -\item{by}{Contributions by "commits" or "author". Default is "commits".} -} -\value{ -A \code{data.frame} with contributions. -} -\description{ -See contributions to a Git repo -} -\examples{ -\dontrun{ -## Create directories and initialize repositories -path_bare <- tempfile(pattern="git2r-") -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo_1) -dir.create(path_repo_2) -repo_bare <- init(path_bare, bare = TRUE) - -## Clone to repo 1 and config user -repo_1 <- clone(path_bare, path_repo_1) -config(repo_1, user.name="Alice", user.email="alice@example.org") - -## Add changes to repo 1 and push to bare -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path_repo_1, "test.txt")) -add(repo_1, "test.txt") -commit(repo_1, "First commit message") - -## Add more changes to repo 1 -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path_repo_1, "test.txt")) -add(repo_1, "test.txt") -commit(repo_1, "Second commit message") - -## Push to bare -push(repo_1, "origin", "refs/heads/master") - -## Clone to repo 2 -repo_2 <- clone(path_bare, path_repo_2) -config(repo_2, user.name="Bob", user.email="bob@example.org") - -## Add changes to repo 2 -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", - "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), - con = file.path(path_repo_2, "test.txt")) -add(repo_2, "test.txt") -commit(repo_2, "Third commit message") - -## Push to bare -push(repo_2, "origin", "refs/heads/master") - -## Pull changes to repo 1 -pull(repo_1) - -## View contributions by day -contributions(repo_1) - -## View contributions by author and day -contributions(repo_1, by = "author") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/contributions.Rd r-cran-git2r-0.22.1/man/contributions.Rd --- r-cran-git2r-0.21.0/man/contributions.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/contributions.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,80 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/contributions.R +\name{contributions} +\alias{contributions} +\title{Contributions} +\usage{ +contributions(repo = ".", breaks = c("month", "year", "quarter", "week", + "day"), by = c("commits", "author")) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{breaks}{Default is \code{month}. Change to year, quarter, +week or day as necessary.} + +\item{by}{Contributions by "commits" or "author". Default is "commits".} +} +\value{ +A \code{data.frame} with contributions. +} +\description{ +See contributions to a Git repo +} +\examples{ +\dontrun{ +## Create directories and initialize repositories +path_bare <- tempfile(pattern="git2r-") +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo_1) +dir.create(path_repo_2) +repo_bare <- init(path_bare, bare = TRUE) + +## Clone to repo 1 and config user +repo_1 <- clone(path_bare, path_repo_1) +config(repo_1, user.name="Alice", user.email="alice@example.org") + +## Add changes to repo 1 and push to bare +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path_repo_1, "test.txt")) +add(repo_1, "test.txt") +commit(repo_1, "First commit message") + +## Add more changes to repo 1 +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path_repo_1, "test.txt")) +add(repo_1, "test.txt") +commit(repo_1, "Second commit message") + +## Push to bare +push(repo_1, "origin", "refs/heads/master") + +## Clone to repo 2 +repo_2 <- clone(path_bare, path_repo_2) +config(repo_2, user.name="Bob", user.email="bob@example.org") + +## Add changes to repo 2 +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), + con = file.path(path_repo_2, "test.txt")) +add(repo_2, "test.txt") +commit(repo_2, "Third commit message") + +## Push to bare +push(repo_2, "origin", "refs/heads/master") + +## Pull changes to repo 1 +pull(repo_1) + +## View contributions by day +contributions(repo_1) + +## View contributions by author and day +contributions(repo_1, by = "author") +} +} diff -Nru r-cran-git2r-0.21.0/man/cred_env-class.Rd r-cran-git2r-0.22.1/man/cred_env-class.Rd --- r-cran-git2r-0.21.0/man/cred_env-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_env-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{cred_env-class} -\alias{cred_env-class} -\title{S4 class to handle environmental variables credential -object} -\description{ -Class \code{"cred_env"} -} -\section{Slots}{ - -\describe{ - \item{username}{ - The name of the environmental variable that holds - the username for the authentication. - } - \item{password}{ - The name of the environmental variable that holds - the password for the authentication. - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/cred_env-methods.Rd r-cran-git2r-0.22.1/man/cred_env-methods.Rd --- r-cran-git2r-0.21.0/man/cred_env-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_env-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/credential.r -\docType{methods} -\name{cred_env} -\alias{cred_env} -\alias{cred_env,character,character-method} -\title{Create a new environmental credential object} -\usage{ -cred_env(username, password) - -\S4method{cred_env}{character,character}(username, password) -} -\arguments{ -\item{username}{The name of the environmental variable that holds -the username for the authentication.} - -\item{password}{The name of the environmental variable that holds -the password for the authentication.} -} -\value{ -A S4 \code{cred_env} object -} -\description{ -Environmental variables can be written to the file -\code{.Renviron}. This file is read by \emph{R} during startup, -see \code{\link[base]{Startup}}. -} -\examples{ -\dontrun{ -## Create an environmental credential object for the username and -## password. -cred <- cred_env("NAME_OF_ENV_VARIABLE_WITH_USERNAME", - "NAME_OF_ENV_VARIABLE_WITH_PASSWORD") -repo <- repository("git2r") -push(repo, credentials = cred) -} -} -\seealso{ -Other git credential functions: \code{\link{cred_ssh_key}}, - \code{\link{cred_token}}, \code{\link{cred_user_pass}} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/cred_env.Rd r-cran-git2r-0.22.1/man/cred_env.Rd --- r-cran-git2r-0.21.0/man/cred_env.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_env.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/credential.R +\name{cred_env} +\alias{cred_env} +\title{Create a new environmental credential object} +\usage{ +cred_env(username = NULL, password = NULL) +} +\arguments{ +\item{username}{The name of the environmental variable that holds +the username for the authentication.} + +\item{password}{The name of the environmental variable that holds +the password for the authentication.} +} +\value{ +A list of class \code{cred_env} with entries: +\describe{ + \item{username}{ + The name of the environmental variable that holds + the username for the authentication. + } + \item{password}{ + The name of the environmental variable that holds + the password for the authentication. + } +} +} +\description{ +Environmental variables can be written to the file +\code{.Renviron}. This file is read by \emph{R} during startup, +see \code{\link[base]{Startup}}. +} +\examples{ +\dontrun{ +## Create an environmental credential object for the username and +## password. +cred <- cred_env("NAME_OF_ENV_VARIABLE_WITH_USERNAME", + "NAME_OF_ENV_VARIABLE_WITH_PASSWORD") +repo <- repository("git2r") +push(repo, credentials = cred) +} +} +\seealso{ +Other git credential functions: \code{\link{cred_ssh_key}}, + \code{\link{cred_token}}, \code{\link{cred_user_pass}} +} diff -Nru r-cran-git2r-0.21.0/man/cred_ssh_key-class.Rd r-cran-git2r-0.22.1/man/cred_ssh_key-class.Rd --- r-cran-git2r-0.21.0/man/cred_ssh_key-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_ssh_key-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{cred_ssh_key-class} -\alias{cred_ssh_key-class} -\title{S4 class to handle a passphrase-protected ssh key -credential object} -\description{ -Class \code{"cred_ssh_key"} -} -\section{Slots}{ - -\describe{ - \item{publickey}{ - The path to the public key of the credential - } - \item{privatekey}{ - The path to the private key of the credential - } - \item{passphrase}{ - The passphrase of the credential - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/cred_ssh_key.Rd r-cran-git2r-0.22.1/man/cred_ssh_key.Rd --- r-cran-git2r-0.21.0/man/cred_ssh_key.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_ssh_key.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,27 +1,38 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/credential.r +% Please edit documentation in R/credential.R \name{cred_ssh_key} \alias{cred_ssh_key} \title{Create a new passphrase-protected ssh key credential object} \usage{ -cred_ssh_key(publickey = "~/.ssh/id_rsa.pub", privatekey = "~/.ssh/id_rsa", - passphrase = character(0)) +cred_ssh_key(publickey = ssh_path("id_rsa.pub"), + privatekey = ssh_path("id_rsa"), passphrase = character(0)) } \arguments{ \item{publickey}{The path to the public key of the -credential. Default is \code{'~/.ssh/id_rsa.pub'}} +credential. Default is \code{ssh_path("id_rsa.pub")}} \item{privatekey}{The path to the private key of the -credential. Default is \code{'~/.ssh/id_rsa'}} +credential. Default is \code{ssh_path("id_rsa")}} \item{passphrase}{The passphrase of the credential. Default is -\code{character(0)}. If getPass is installed and private key is -passphrase protected \code{getPass::getPass()} will be called -to allow for interactive and obfuscated interactive input of -the passphrase.} +\code{character(0)}. If getPass is installed and private key +is passphrase protected \code{getPass::getPass()} will be +called to allow for interactive and obfuscated interactive +input of the passphrase.} } \value{ -A S4 \code{cred_ssh_key} object +A list of class \code{cred_ssh_key} with entries: +\describe{ + \item{publickey}{ + The path to the public key of the credential + } + \item{privatekey}{ + The path to the private key of the credential + } + \item{passphrase}{ + The passphrase of the credential + } +} } \description{ Create a new passphrase-protected ssh key credential object @@ -30,7 +41,7 @@ \dontrun{ ## Create a ssh key credential object. It can optionally be ## passphrase-protected -cred <- cred_ssh_key("~/.ssh/id_rsa.pub", "~/.ssh/id_rsa") +cred <- cred_ssh_key(ssh_path("id_rsa.pub"), ssh_path("id_rsa")) repo <- repository("git2r") push(repo, credentials = cred) } diff -Nru r-cran-git2r-0.21.0/man/cred_token-class.Rd r-cran-git2r-0.22.1/man/cred_token-class.Rd --- r-cran-git2r-0.21.0/man/cred_token-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_token-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{cred_token-class} -\alias{cred_token-class} -\title{S4 class to handle a personal access token credential -object} -\description{ -Class \code{"cred_token"} -} -\section{Slots}{ - -\describe{ - \item{token}{ - The name of the environmental variable that holds - the personal access token for the authentication. - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/cred_token.Rd r-cran-git2r-0.22.1/man/cred_token.Rd --- r-cran-git2r-0.21.0/man/cred_token.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_token.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/credential.r +% Please edit documentation in R/credential.R \name{cred_token} \alias{cred_token} \title{Create a new personal access token credential object} @@ -12,7 +12,13 @@ \code{GITHUB_PAT}.} } \value{ -A S4 \code{cred_token} object +A list of class \code{cred_token} with entry: +\describe{ + \item{token}{ + The name of the environmental variable that holds + the personal access token for the authentication. + } +} } \description{ The personal access token is stored in an envrionmental variable. diff -Nru r-cran-git2r-0.21.0/man/cred_user_pass-class.Rd r-cran-git2r-0.22.1/man/cred_user_pass-class.Rd --- r-cran-git2r-0.21.0/man/cred_user_pass-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_user_pass-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{cred_user_pass-class} -\alias{cred_user_pass-class} -\title{S4 class to handle plain-text username and password -credential object} -\description{ -Class \code{"cred_user_pass"} -} -\section{Slots}{ - -\describe{ - \item{username}{ - The username of the credential - } - \item{password}{ - The password of the credential - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/cred_user_pass-methods.Rd r-cran-git2r-0.22.1/man/cred_user_pass-methods.Rd --- r-cran-git2r-0.21.0/man/cred_user_pass-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_user_pass-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/credential.r -\docType{methods} -\name{cred_user_pass} -\alias{cred_user_pass} -\alias{cred_user_pass,character,character-method} -\title{Create a new plain-text username and password credential object} -\usage{ -cred_user_pass(username, password) - -\S4method{cred_user_pass}{character,character}(username, password) -} -\arguments{ -\item{username}{The username of the credential} - -\item{password}{The password of the credential} -} -\value{ -A S4 \code{cred_user_pass} object -} -\description{ -Create a new plain-text username and password credential object -} -\examples{ -\dontrun{ -## Create a plain-text username and password credential object -cred_user_pass("Random Developer", "SecretPassword") -} -} -\seealso{ -Other git credential functions: \code{\link{cred_env}}, - \code{\link{cred_ssh_key}}, \code{\link{cred_token}} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/cred_user_pass.Rd r-cran-git2r-0.22.1/man/cred_user_pass.Rd --- r-cran-git2r-0.21.0/man/cred_user_pass.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/cred_user_pass.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/credential.R +\name{cred_user_pass} +\alias{cred_user_pass} +\title{Create a new plain-text username and password credential object} +\usage{ +cred_user_pass(username = NULL, password = NULL) +} +\arguments{ +\item{username}{The username of the credential} + +\item{password}{The password of the credential} +} +\value{ +A list of class \code{cred_user_pass} with entries: +\describe{ + \item{username}{ + The username of the credential + } + \item{password}{ + The password of the credential + } +} +} +\description{ +Create a new plain-text username and password credential object +} +\examples{ +\dontrun{ +## Create a plain-text username and password credential object +cred_user_pass("Random Developer", "SecretPassword") +} +} +\seealso{ +Other git credential functions: \code{\link{cred_env}}, + \code{\link{cred_ssh_key}}, \code{\link{cred_token}} +} diff -Nru r-cran-git2r-0.21.0/man/default_signature-methods.Rd r-cran-git2r-0.22.1/man/default_signature-methods.Rd --- r-cran-git2r-0.21.0/man/default_signature-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/default_signature-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{default_signature} -\alias{default_signature} -\alias{default_signature,git_repository-method} -\title{Get the signature} -\usage{ -default_signature(repo) - -\S4method{default_signature}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} to check signature} -} -\value{ -S4 class git_signature -} -\description{ -Get the signature according to the repository's configuration -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Get the default signature -default_signature(repo) - -## Change user -config(repo, user.name="Bob", user.email="bob@example.org") - -## Get the default signature -default_signature(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/default_signature.Rd r-cran-git2r-0.22.1/man/default_signature.Rd --- r-cran-git2r-0.21.0/man/default_signature.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/default_signature.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/signature.R +\name{default_signature} +\alias{default_signature} +\title{Get the signature} +\usage{ +default_signature(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +A \code{git_signature} object with entries: +} +\description{ +Get the signature according to the repository's configuration +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Get the default signature +default_signature(repo) + +## Change user +config(repo, user.name="Bob", user.email="bob@example.org") + +## Get the default signature +default_signature(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/descendant_of-methods.Rd r-cran-git2r-0.22.1/man/descendant_of-methods.Rd --- r-cran-git2r-0.21.0/man/descendant_of-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/descendant_of-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{descendant_of} -\alias{descendant_of} -\alias{descendant_of,git_commit,git_commit-method} -\title{Descendant} -\usage{ -descendant_of(commit, ancestor) - -\S4method{descendant_of}{git_commit,git_commit}(commit, ancestor) -} -\arguments{ -\item{commit}{a S4 class git_commit \code{object}.} - -\item{ancestor}{a S4 class git_commit \code{object} to check if -ancestor to \code{commit}.} -} -\value{ -TRUE if commit is descendant of \code{ancestor}, else -FALSE -} -\description{ -Determine if a commit is the descendant of another commit -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit_1 <- commit(repo, "Commit message 1") - -# Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit_2 <- commit(repo, "Commit message 2") - -descendant_of(commit_1, commit_2) -descendant_of(commit_2, commit_1) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/descendant_of.Rd r-cran-git2r-0.22.1/man/descendant_of.Rd --- r-cran-git2r-0.21.0/man/descendant_of.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/descendant_of.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{descendant_of} +\alias{descendant_of} +\title{Descendant} +\usage{ +descendant_of(commit = NULL, ancestor = NULL) +} +\arguments{ +\item{commit}{a git_commit object.} + +\item{ancestor}{a git_commit object to check if ancestor to +\code{commit}.} +} +\value{ +TRUE if \code{commit} is descendant of \code{ancestor}, + else FALSE +} +\description{ +Determine if a commit is the descendant of another commit +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit_1 <- commit(repo, "Commit message 1") + +# Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit_2 <- commit(repo, "Commit message 2") + +descendant_of(commit_1, commit_2) +descendant_of(commit_2, commit_1) +} +} diff -Nru r-cran-git2r-0.21.0/man/diff-methods.Rd r-cran-git2r-0.22.1/man/diff-methods.Rd --- r-cran-git2r-0.21.0/man/diff-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/diff-methods.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,20 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/diff.r -\docType{methods} -\name{diff,git_repository-method} -\alias{diff,git_repository-method} -\alias{diff,git_tree-method} +% Please edit documentation in R/diff.R +\name{diff.git_repository} +\alias{diff.git_repository} +\alias{diff.git_tree} \title{Changes between commits, trees, working tree, etc.} \usage{ -\S4method{diff}{git_repository}(x, index = FALSE, as_char = FALSE, +\method{diff}{git_repository}(x, index = FALSE, as_char = FALSE, filename = NULL, ...) -\S4method{diff}{git_tree}(x, new_tree = NULL, index = FALSE, +\method{diff}{git_tree}(x, new_tree = NULL, index = FALSE, as_char = FALSE, filename = NULL, ...) } \arguments{ -\item{x}{A \code{git_repository} object or the old -\code{git_tree} object to compare to.} +\item{x}{A \code{git_repository} object or the old \code{git_tree} +object to compare to.} \item{index}{\describe{ \item{\emph{When object equals a git_repository}}{ @@ -30,20 +29,19 @@ \item{as_char}{logical: should the result be converted to a character string?. Default is FALSE.} -\item{filename}{If as_char is TRUE, then the diff can be written to -a file with name filename (the file is overwritten if it +\item{filename}{If as_char is TRUE, then the diff can be written +to a file with name filename (the file is overwritten if it exists). Default is NULL.} \item{...}{Additional arguments affecting the diff produced} -\item{new_tree}{The new git_tree object to compare, or NULL. -If NULL, then we use the working directory or the index (see -the \code{index} argument).} +\item{new_tree}{The new git_tree object to compare, or NULL. If +NULL, then we use the working directory or the index (see the +\code{index} argument).} } \value{ -A \code{\linkS4class{git_diff}} object if as_char is -FALSE. If as_char is TRUE and filename is NULL, a character string, -else NULL. +A \code{git_diff} object if as_char is FALSE. If as_char + is TRUE and filename is NULL, a character string, else NULL. } \description{ Changes between commits, trees, working tree, etc. @@ -111,4 +109,3 @@ cat(diff(repo, index=TRUE, as_char=TRUE)) } } -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/discover_repository-methods.Rd r-cran-git2r-0.22.1/man/discover_repository-methods.Rd --- r-cran-git2r-0.21.0/man/discover_repository-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/discover_repository-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{discover_repository} -\alias{discover_repository} -\alias{discover_repository,character,missing-method} -\alias{discover_repository,character,numeric-method} -\title{Find path to repository for any file} -\usage{ -discover_repository(path, ceiling) - -\S4method{discover_repository}{character,missing}(path) - -\S4method{discover_repository}{character,numeric}(path, ceiling) -} -\arguments{ -\item{path}{A character vector specifying the path to a file or folder} - -\item{ceiling}{The defult is to not use the ceiling argument and -start the lookup from path and walk across parent -directories. When ceiling is 0, the lookup is only in path. When -ceiling is 1, the lookup is in both the path and the parent to -path.} -} -\value{ -Character vector with path to repository or NULL if this -cannot be established. -} -\description{ -libgit's git_discover_repository is used to identify the location -of the repository. The path will therefore be terminated by a file -separator. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example-1.txt")) -add(repo, "example-1.txt") -commit(repo, "First commit message") - -## Create a second file. The file is not added for version control -## in the repository. -dir.create(file.path(path, "example")) -file_2 <- file.path(path, "example/example-2.txt") -writeLines("Not under version control", file_2) - -## Find the path to the repository using the path to the second file -discover_repository(file_2) - -## Demonstrate the 'ceiling' argument -wd <- workdir(repo) -dir.create(file.path(wd, "temp")) - -## Lookup repository in 'file.path(wd, "temp")'. Should return NULL -discover_repository(file.path(wd, "temp"), ceiling = 0) - -## Lookup repository in parent to 'file.path(wd, "temp")'. -## Should not return NULL -discover_repository(file.path(wd, "temp"), ceiling = 1) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/discover_repository.Rd r-cran-git2r-0.22.1/man/discover_repository.Rd --- r-cran-git2r-0.21.0/man/discover_repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/discover_repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,61 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{discover_repository} +\alias{discover_repository} +\title{Find path to repository for any file} +\usage{ +discover_repository(path = ".", ceiling = NULL) +} +\arguments{ +\item{path}{A character vector specifying the path to a file or +folder} + +\item{ceiling}{The defult is to not use the ceiling argument and +start the lookup from path and walk across parent +directories. When ceiling is 0, the lookup is only in +path. When ceiling is 1, the lookup is in both the path and +the parent to path.} +} +\value{ +Character vector with path (terminated by a file + separator) to repository or NULL if this cannot be + established. +} +\description{ +Find path to repository for any file +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example-1.txt")) +add(repo, "example-1.txt") +commit(repo, "First commit message") + +## Create a second file. The file is not added for version control +## in the repository. +dir.create(file.path(path, "example")) +file_2 <- file.path(path, "example/example-2.txt") +writeLines("Not under version control", file_2) + +## Find the path to the repository using the path to the second file +discover_repository(file_2) + +## Demonstrate the 'ceiling' argument +wd <- workdir(repo) +dir.create(file.path(wd, "temp")) + +## Lookup repository in 'file.path(wd, "temp")'. Should return NULL +discover_repository(file.path(wd, "temp"), ceiling = 0) + +## Lookup repository in parent to 'file.path(wd, "temp")'. +## Should not return NULL +discover_repository(file.path(wd, "temp"), ceiling = 1) +} +} diff -Nru r-cran-git2r-0.21.0/man/fetch_heads-methods.Rd r-cran-git2r-0.22.1/man/fetch_heads-methods.Rd --- r-cran-git2r-0.21.0/man/fetch_heads-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/fetch_heads-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fetch.r -\docType{methods} -\name{fetch_heads} -\alias{fetch_heads} -\alias{fetch_heads,git_repository-method} -\title{Get updated heads during the last fetch.} -\usage{ -fetch_heads(repo) - -\S4method{fetch_heads}{git_repository}(repo) -} -\arguments{ -\item{repo}{the repository} -} -\value{ -list with the S4 class \code{\linkS4class{git_fetch_head}} -entries. NULL if there is no FETCH_HEAD file. -} -\description{ -Get updated heads during the last fetch. -} -\examples{ -\dontrun{ -## Initialize three temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") - -dir.create(path_bare) -dir.create(path_repo_1) -dir.create(path_repo_2) - -bare_repo <- init(path_bare, bare = TRUE) -repo_1 <- clone(path_bare, path_repo_1) -repo_2 <- clone(path_bare, path_repo_2) - -config(repo_1, user.name="Alice", user.email="alice@example.org") -config(repo_2, user.name="Bob", user.email="bob@example.org") - -## Add changes to repo 1 -writeLines("Lorem ipsum dolor sit amet", - con = file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Commit message") - -## Push changes from repo 1 to origin (bare_repo) -push(repo_1, "origin", "refs/heads/master") - -## Fetch changes from origin (bare_repo) to repo 2 -fetch(repo_2, "origin") - -## List updated heads -fetch_heads(repo_2) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/fetch_heads.Rd r-cran-git2r-0.22.1/man/fetch_heads.Rd --- r-cran-git2r-0.21.0/man/fetch_heads.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/fetch_heads.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fetch.R +\name{fetch_heads} +\alias{fetch_heads} +\title{Get updated heads during the last fetch.} +\usage{ +fetch_heads(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +list with \code{git_fetch_head} entries. NULL if there is + no FETCH_HEAD file. +} +\description{ +Get updated heads during the last fetch. +} +\examples{ +\dontrun{ +## Initialize three temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") + +dir.create(path_bare) +dir.create(path_repo_1) +dir.create(path_repo_2) + +bare_repo <- init(path_bare, bare = TRUE) +repo_1 <- clone(path_bare, path_repo_1) +repo_2 <- clone(path_bare, path_repo_2) + +config(repo_1, user.name="Alice", user.email="alice@example.org") +config(repo_2, user.name="Bob", user.email="bob@example.org") + +## Add changes to repo 1 +writeLines("Lorem ipsum dolor sit amet", + con = file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Commit message") + +## Push changes from repo 1 to origin (bare_repo) +push(repo_1, "origin", "refs/heads/master") + +## Fetch changes from origin (bare_repo) to repo 2 +fetch(repo_2, "origin") + +## List updated heads +fetch_heads(repo_2) +} +} diff -Nru r-cran-git2r-0.21.0/man/fetch-methods.Rd r-cran-git2r-0.22.1/man/fetch-methods.Rd --- r-cran-git2r-0.21.0/man/fetch-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/fetch-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fetch.r -\docType{methods} -\name{fetch} -\alias{fetch} -\alias{fetch,git_repository-method} -\title{Fetch new data and update tips} -\usage{ -fetch(repo, name, credentials = NULL, verbose = TRUE, refspec = NULL) - -\S4method{fetch}{git_repository}(repo, name, credentials = NULL, - verbose = TRUE, refspec = NULL) -} -\arguments{ -\item{repo}{the repository} - -\item{name}{the remote's name} - -\item{credentials}{The credentials for remote repository -access. Default is NULL. To use and query an ssh-agent for the -ssh key credentials, let this parameter be NULL (the default).} - -\item{verbose}{Print information each time a reference is updated -locally. Default is \code{TRUE}.} - -\item{refspec}{The refs to fetch and which local refs to update, -see examples. Pass NULL to use the -\code{remote..fetch} variable. Default is -\code{NULL}.} -} -\value{ -invisible \code{\linkS4class{git_transfer_progress}} - object -} -\description{ -Fetch new data and update tips -} -\examples{ -\dontrun{ -## Initialize three temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") - -dir.create(path_bare) -dir.create(path_repo_1) -dir.create(path_repo_2) - -bare_repo <- init(path_bare, bare = TRUE) -repo_1 <- clone(path_bare, path_repo_1) -repo_2 <- clone(path_bare, path_repo_2) - -config(repo_1, user.name="Alice", user.email="alice@example.org") -config(repo_2, user.name="Bob", user.email="bob@example.org") - -## Add changes to repo 1 -writeLines("Lorem ipsum dolor sit amet", - con = file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Commit message") - -## Push changes from repo 1 to origin (bare_repo) -push(repo_1, "origin", "refs/heads/master") - -## Fetch changes from origin (bare_repo) to repo 2 -fetch(repo_2, "origin") - -## List updated heads -fetch_heads(repo_2) - -## Checking out GitHub pull requests locally -path <- tempfile(pattern="ghit-") -repo <- clone("https://github.com/leeper/ghit", path) -fetch(repo, "origin", refspec = "pull/13/head:refs/heads/BRANCHNAME") -checkout(repo, "BRANCHNAME") -summary(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/fetch.Rd r-cran-git2r-0.22.1/man/fetch.Rd --- r-cran-git2r-0.21.0/man/fetch.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/fetch.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,99 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fetch.R +\name{fetch} +\alias{fetch} +\title{Fetch new data and update tips} +\usage{ +fetch(repo = ".", name = NULL, credentials = NULL, verbose = TRUE, + refspec = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{name}{the remote's name} + +\item{credentials}{The credentials for remote repository +access. Default is NULL. To use and query an ssh-agent for the +ssh key credentials, let this parameter be NULL (the default).} + +\item{verbose}{Print information each time a reference is updated +locally. Default is \code{TRUE}.} + +\item{refspec}{The refs to fetch and which local refs to update, +see examples. Pass NULL to use the +\code{remote..fetch} variable. Default is +\code{NULL}.} +} +\value{ +invisible list of class \code{git_transfer_progress} + with statistics from the fetch operation: +\describe{ + \item{total_objects}{ + Number of objects in the packfile being downloaded + } + \item{indexed_objects}{ + Received objects that have been hashed + } + \item{received_objects}{ + Objects which have been downloaded + } + \item{total_deltas}{ + Total number of deltas in the pack + } + \item{indexed_deltas}{ + Deltas which have been indexed + } + \item{local_objects}{ + Locally-available objects that have been injected in order to + fix a thin pack + } + \item{received_bytes}{ + Size of the packfile received up to now + } +} +} +\description{ +Fetch new data and update tips +} +\examples{ +\dontrun{ +## Initialize three temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") + +dir.create(path_bare) +dir.create(path_repo_1) +dir.create(path_repo_2) + +bare_repo <- init(path_bare, bare = TRUE) +repo_1 <- clone(path_bare, path_repo_1) +repo_2 <- clone(path_bare, path_repo_2) + +config(repo_1, user.name="Alice", user.email="alice@example.org") +config(repo_2, user.name="Bob", user.email="bob@example.org") + +## Add changes to repo 1 +writeLines("Lorem ipsum dolor sit amet", + con = file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Commit message") + +## Push changes from repo 1 to origin (bare_repo) +push(repo_1, "origin", "refs/heads/master") + +## Fetch changes from origin (bare_repo) to repo 2 +fetch(repo_2, "origin") + +## List updated heads +fetch_heads(repo_2) + +## Checking out GitHub pull requests locally +path <- tempfile(pattern="ghit-") +repo <- clone("https://github.com/leeper/ghit", path) +fetch(repo, "origin", refspec = "pull/13/head:refs/heads/BRANCHNAME") +checkout(repo, "BRANCHNAME") +summary(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/get_refspec.Rd r-cran-git2r-0.22.1/man/get_refspec.Rd --- r-cran-git2r-0.21.0/man/get_refspec.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/get_refspec.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/refspec.r -\name{get_refspec} -\alias{get_refspec} -\title{Create push refspec from arguments} -\usage{ -get_refspec(repo = NULL, remote = NULL, spec = NULL, opts = NULL) -} -\arguments{ -\item{repo}{S4 class \code{git_repository}} - -\item{opts}{List with push options. Default is NULL.} - -\item{name}{The remote's name. Default is NULL.} - -\item{refspec}{The refspec to be pushed. Default is NULL.} -} -\value{ -List with remote (character vector) and refspec (character -vector). -} -\description{ -Create push refspec from arguments -} -\keyword{internal} diff -Nru r-cran-git2r-0.21.0/man/git2r.Rd r-cran-git2r-0.22.1/man/git2r.Rd --- r-cran-git2r-0.21.0/man/git2r.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git2r.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/git2r.r +% Please edit documentation in R/git2r.R \docType{package} \name{git2r} \alias{git2r} diff -Nru r-cran-git2r-0.21.0/man/git_blame-class.Rd r-cran-git2r-0.22.1/man/git_blame-class.Rd --- r-cran-git2r-0.21.0/man/git_blame-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_blame-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_blame-class} -\alias{git_blame-class} -\title{S4 class to handle a git blame for a single file} -\description{ -Class \code{"git_blame"} -} -\section{Slots}{ - -\describe{ - \item{path}{ - The path to the file of the blame - } - \item{hunks}{ - List of blame hunks - } - \item{repo}{ - The S4 class git_repository that contains the file - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_blame_hunk-class.Rd r-cran-git2r-0.22.1/man/git_blame_hunk-class.Rd --- r-cran-git2r-0.21.0/man/git_blame_hunk-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_blame_hunk-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_blame_hunk-class} -\alias{git_blame_hunk-class} -\title{S4 class to represent a blame hunk} -\description{ -Class \code{"git_blame_hunk"} -} -\section{Slots}{ - -\describe{ - \item{lines_in_hunk}{ - The number of lines in this hunk - } - \item{final_commit_id}{ - The sha of the commit where this line was last changed - } - \item{final_start_line_number}{ - The 1-based line number where this hunk begins, in the final - version of the file - } - \item{final_signature}{ - Final committer - } - \item{orig_commit_id}{ - The sha of the commit where this hunk was found. This will usually - be the same as 'final_commit_id'. - } - \item{orig_start_line_number}{ - The 1-based line number where this hunk begins in the file - named by 'orig_path' in the commit specified by 'orig_commit_id'. - } - \item{orig_signature}{ - Origin committer - } - \item{orig_path}{ - The path to the file where this hunk originated, as of the commit - specified by 'orig_commit_id' - } - \item{boundary}{ - TRUE iff the hunk has been tracked to a boundary commit. - } - \item{repo}{ - The S4 class git_repository that contains the blame hunk - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_blob-class.Rd r-cran-git2r-0.22.1/man/git_blob-class.Rd --- r-cran-git2r-0.21.0/man/git_blob-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_blob-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_blob-class} -\alias{git_blob-class} -\title{S4 class to handle a git blob} -\description{ -Class \code{"git_blob"} -} -\section{Slots}{ - -\describe{ - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - \item{repo}{ - The S4 class git_repository that contains the blob - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_branch-class.Rd r-cran-git2r-0.22.1/man/git_branch-class.Rd --- r-cran-git2r-0.21.0/man/git_branch-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_branch-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_branch-class} -\alias{git_branch-class} -\title{S4 class to handle a git branch} -\description{ -Class \code{git_branch} -} -\section{Slots}{ - -\describe{ - \item{name}{ - Name of the branch. - } - \item{type}{ - Type of the branch, either 1 (local) or 2 (remote). - } - \item{repo}{ - The S4 class git_repository that contains the branch - } -} -} - -\section{Methods}{ - -\describe{ - \item{is_head}{\code{signature(object = "git_branch")}} - \item{is_local}{\code{signature(object = "git_branch")}} - \item{show}{\code{signature(object = "git_branch")}} -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_commit-class.Rd r-cran-git2r-0.22.1/man/git_commit-class.Rd --- r-cran-git2r-0.21.0/man/git_commit-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_commit-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_commit-class} -\alias{git_commit-class} -\title{S4 class to handle a git commit.} -\description{ -Class \code{"git_commit"} -} -\section{Slots}{ - -\describe{ - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - \item{author}{ - An author signature - } - \item{committer}{ - The committer signature - } - \item{summary}{ - The short "summary" of a git commit message, comprising the first - paragraph of the message with whitespace trimmed and squashed. - } - \item{message}{ - The message of a commit - } - \item{repo}{ - The S4 class git_repository that contains the commit - } -} -} - -\section{Methods}{ - -\describe{ - \item{show}{\code{signature(object = "git_commit")}} -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_config_files.Rd r-cran-git2r-0.22.1/man/git_config_files.Rd --- r-cran-git2r-0.21.0/man/git_config_files.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_config_files.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/config.R +\name{git_config_files} +\alias{git_config_files} +\title{Locate the path to configuration files} +\usage{ +git_config_files(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +a named list with one item per potential configuration + file where \code{NA} means not found. +} +\description{ +Potential configuration files: +\describe{ + \item{system}{ + Locate the path to the system configuration file. If + '/etc/gitconfig' doesn't exist, it will look for + '\%PROGRAMFILES\%'. + } + \item{xdg}{ + Locate the path to the global xdg compatible configuration + file. The xdg compatible configuration file is usually located + in '$HOME/.config/git/config'. This method will try to guess + the full path to that file, if the file exists. + } + \item{global}{ + The user or global configuration file is usually located in + '$HOME/.gitconfig'. This method will try to guess the full + path to that file, if the file exists. + } + \item{local}{ + Locate the path to the repository specific configuration file, + if the file exists. + } +} +} diff -Nru r-cran-git2r-0.21.0/man/git_diff-class.Rd r-cran-git2r-0.22.1/man/git_diff-class.Rd --- r-cran-git2r-0.21.0/man/git_diff-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_diff-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_diff-class} -\alias{git_diff-class} -\title{Git diff} -\description{ -Git diff -} -\section{Slots}{ - -\describe{ - \item{old}{ - Represents the 'from' side of the diff. - } - \item{new}{ - Represents the 'to' side of the diff. - } - \item{files}{ - List of \code{\linkS4class{git_diff_file}} objects. - } -} -} - -\keyword{classes} diff -Nru r-cran-git2r-0.21.0/man/git_diff_file-class.Rd r-cran-git2r-0.22.1/man/git_diff_file-class.Rd --- r-cran-git2r-0.21.0/man/git_diff_file-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_diff_file-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_diff_file-class} -\alias{git_diff_file-class} -\title{Git diff file} -\description{ -Git diff file -} -\section{Slots}{ - -\describe{ - \item{old_file}{ - Filename for old side of diff. - } - \item{new_file}{ - Filename for new side of diff. - } - \item{hunks}{ - List of \code{\linkS4class{git_diff_hunk}} objects. - } -} -} - -\keyword{classes} diff -Nru r-cran-git2r-0.21.0/man/git_diff_hunk-class.Rd r-cran-git2r-0.22.1/man/git_diff_hunk-class.Rd --- r-cran-git2r-0.21.0/man/git_diff_hunk-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_diff_hunk-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_diff_hunk-class} -\alias{git_diff_hunk-class} -\title{Git diff hunk} -\description{ -Git diff hunk -} -\section{Slots}{ - -\describe{ - \item{old_start}{ - Starting line number in old_file. - } - \item{old_lines}{ - Number of lines in old_file. - } - \item{new_start}{ - Starting line number in new_file. - } - \item{new_lines}{ - Number of lines in new_file. - } - \item{header}{ - Header text. - } - \item{lines}{ - List with \code{\linkS4class{git_diff_line}} objects. - } -} -} - -\keyword{classes} diff -Nru r-cran-git2r-0.21.0/man/git_diff_line-class.Rd r-cran-git2r-0.22.1/man/git_diff_line-class.Rd --- r-cran-git2r-0.21.0/man/git_diff_line-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_diff_line-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_diff_line-class} -\alias{git_diff_line-class} -\title{Git diff line} -\description{ -Git diff line -} -\section{Slots}{ - -\describe{ - \item{origin}{ - Line origin constants. - } - \item{old_lineno}{ - Line number in old file or -1 for added line. - } - \item{new_lineno}{ - Line number in new file or -1 for deleted line. - } - \item{num_lines}{ - Number of newline characters in content. - } - \item{content}{ - The diff text. - } -} -} - -\keyword{classes} diff -Nru r-cran-git2r-0.21.0/man/git_fetch_head.Rd r-cran-git2r-0.22.1/man/git_fetch_head.Rd --- r-cran-git2r-0.21.0/man/git_fetch_head.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_fetch_head.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_fetch_head-class} -\alias{git_fetch_head-class} -\title{S4 class to handle a fetch head} -\description{ -Class \code{"git_fetch_head"} -} -\section{Slots}{ - -\describe{ - \item{ref_name}{ - The name of the ref. - } - \item{remote_url}{ - The url of the remote. - } - \item{sha}{ - The SHA-1 of the remote head that were updated during the last - fetch. - } - \item{is_merge}{ - Is head for merge. - } - \item{repo}{ - The S4 class git_repository that contains the fetch head. - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_merge_result.Rd r-cran-git2r-0.22.1/man/git_merge_result.Rd --- r-cran-git2r-0.21.0/man/git_merge_result.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_merge_result.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_merge_result-class} -\alias{git_merge_result-class} -\title{S4 class to handle the merge result} -\description{ -Class \code{"git_merge_result"} -} -\section{Slots}{ - -\describe{ - \item{up_to_date}{ - TRUE if the merge is already up-to-date, else FALSE. - } - \item{fast_forward}{ - TRUE if a fast-forward merge, else FALSE. - } - \item{conflicts}{ - TRUE if the index contain entries representing file conflicts, - else FALSE. - } - \item{sha}{ - If the merge created a merge commit, the sha of the merge - commit. NA if no merge commit created. - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_note-class.Rd r-cran-git2r-0.22.1/man/git_note-class.Rd --- r-cran-git2r-0.21.0/man/git_note-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_note-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_note-class} -\alias{git_note-class} -\title{S4 class to handle a git note} -\description{ -Class \code{git_note} -} -\section{Slots}{ - -\describe{ - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 of the blob - containing the message - } - \item{annotated}{ - The 40 character hexadecimal string of the SHA-1 of the git - object being annotated - } - \item{message}{ - The note message - } - \item{refname}{ - Name of the reference - } - \item{repo}{ - The S4 class git_repository that contains the note - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_reference-class.Rd r-cran-git2r-0.22.1/man/git_reference-class.Rd --- r-cran-git2r-0.21.0/man/git_reference-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_reference-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_reference-class} -\alias{git_reference-class} -\title{S4 class to handle a git reference} -\description{ -Class \code{"git_reference"} -} -\section{Slots}{ - -\describe{ - \item{name}{ - The full name of the reference. - } - \item{type}{ - Type of the reference, either direct (GIT_REF_OID == 1) or - symbolic (GIT_REF_SYMBOLIC == 2) - } - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - \item{target}{ - The full name to the reference pointed to by a - symbolic reference. - } - \item{shorthand}{ - The reference's short name - } -} -} - -\section{Methods}{ - -\describe{ - \item{show}{\code{signature(object = "git_reference")}} -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_reflog_entry-class.Rd r-cran-git2r-0.22.1/man/git_reflog_entry-class.Rd --- r-cran-git2r-0.21.0/man/git_reflog_entry-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_reflog_entry-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_reflog_entry-class} -\alias{git_reflog_entry-class} -\title{S4 class to handle a git reflog entry.} -\description{ -Class \code{"git_reflog_entry"} -} -\section{Slots}{ - -\describe{ - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - \item{message}{ - The log message of the entry - } - \item{index}{ - The index (zero-based) of the entry in the reflog - } - \item{committer}{ - The committer signature - } - \item{refname}{ - Name of the reference - } - \item{repo}{ - The S4 class git_repository that contains the reflog entry - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_repository-class.Rd r-cran-git2r-0.22.1/man/git_repository-class.Rd --- r-cran-git2r-0.21.0/man/git_repository-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_repository-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_repository-class} -\alias{git_repository-class} -\title{S4 class to handle a git repository} -\description{ -Class \code{"git_repository"} -} -\section{Slots}{ - -\describe{ - \item{path}{ - Path to a git repository - } -} -} - -\section{Methods}{ - -\describe{ - \item{is_bare}{\code{signature(object = "git_repository")}} - \item{is_empty}{\code{signature(object = "git_repository")}} -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_signature-class.Rd r-cran-git2r-0.22.1/man/git_signature-class.Rd --- r-cran-git2r-0.21.0/man/git_signature-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_signature-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_signature-class} -\alias{git_signature-class} -\title{S4 class to handle a git signature} -\description{ -Class \code{"git_signature"} -} -\section{Slots}{ - -\describe{ - \item{name}{ - The full name of the author. - } - \item{email}{ - Email of the author. - } - \item{when}{ - Time when the action happened. - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_stash-class.Rd r-cran-git2r-0.22.1/man/git_stash-class.Rd --- r-cran-git2r-0.21.0/man/git_stash-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_stash-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_stash-class} -\alias{git_stash-class} -\title{S4 class to handle a git stash} -\description{ -Class \code{"git_stash"} -} -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_tag-class.Rd r-cran-git2r-0.22.1/man/git_tag-class.Rd --- r-cran-git2r-0.21.0/man/git_tag-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_tag-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_tag-class} -\alias{git_tag-class} -\title{S4 class to handle a git tag} -\description{ -Class \code{"git_tag"} -} -\section{Slots}{ - -\describe{ - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - \item{message}{ - The message of the tag - } - \item{name}{ - The name of the tag - } - \item{tagger}{ - The tagger (author) of the tag - } - \item{target}{ - The target of the tag - } - \item{repo}{ - The S4 class git_repository that contains the tag - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_time-class.Rd r-cran-git2r-0.22.1/man/git_time-class.Rd --- r-cran-git2r-0.21.0/man/git_time-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_time-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_time-class} -\alias{git_time-class} -\alias{coerce,git_time,character-method} -\title{S4 class to handle a git time in a signature} -\description{ -Class \code{"git_time"} -} -\section{Slots}{ - -\describe{ - \item{time}{ - Time in seconds from epoch - } - \item{offset}{ - Timezone offset, in minutes - } -} -} - -\section{Methods}{ - -\describe{ - \item{show}{\code{signature(object = "git_time")}} -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_transfer_progress-class.Rd r-cran-git2r-0.22.1/man/git_transfer_progress-class.Rd --- r-cran-git2r-0.21.0/man/git_transfer_progress-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_transfer_progress-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_transfer_progress-class} -\alias{git_transfer_progress-class} -\title{Class \code{"git_transfer_progress"}} -\description{ -Statistics from the fetch operation. -} -\section{Slots}{ - -\describe{ - \item{total_objects}{ - Number of objects in the packfile being downloaded - } - \item{indexed_objects}{ - Received objects that have been hashed - } - \item{received_objects}{ - Objects which have been downloaded - } - \item{total_deltas}{ - Total number of deltas in the pack - } - \item{indexed_deltas}{ - Deltas which have been indexed - } - \item{local_objects}{ - Locally-available objects that have been injected in order to - fix a thin pack - } - \item{received_bytes}{ - Size of the packfile received up to now - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/git_tree-class.Rd r-cran-git2r-0.22.1/man/git_tree-class.Rd --- r-cran-git2r-0.21.0/man/git_tree-class.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/git_tree-class.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/S4_classes.r -\docType{class} -\name{git_tree-class} -\alias{git_tree-class} -\title{S4 class to handle a git tree} -\description{ -Class \code{"git_tree"} -} -\section{Slots}{ - -\describe{ - \item{sha}{ - The 40 character hexadecimal string of the SHA-1 - } - \item{filemode}{ - The UNIX file attributes of a tree entry - } - \item{type}{ - String representation of the tree entry type - } - \item{id}{ - The sha id of a tree entry - } - \item{name}{ - The filename of a tree entry - } - \item{repo}{ - The S4 class git_repository that contains the commit - } -} -} - -\keyword{classes} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/hashfile-methods.Rd r-cran-git2r-0.22.1/man/hashfile-methods.Rd --- r-cran-git2r-0.21.0/man/hashfile-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/hashfile-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{hashfile} -\alias{hashfile} -\alias{hashfile,character-method} -\title{Determine the sha from a blob in a file} -\usage{ -hashfile(path) - -\S4method{hashfile}{character}(path) -} -\arguments{ -\item{path}{The path vector with files to hash.} -} -\value{ -A vector with the sha for each file in path. -} -\description{ -The blob is not written to the object database. -} -\examples{ -\dontrun{ -## Create a file. NOTE: The line endings from writeLines gives -## LF (line feed) on Unix/Linux and CRLF (carriage return, line feed) -## on Windows. The example use writeChar to have more control. -path <- tempfile() -f <- file(path, "wb") -writeChar("Hello, world!\\n", f, eos = NULL) -close(f) - -## Generate hash -hashfile(path) -identical(hashfile(path), hash("Hello, world!\\n")) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/hashfile.Rd r-cran-git2r-0.22.1/man/hashfile.Rd --- r-cran-git2r-0.21.0/man/hashfile.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/hashfile.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blob.R +\name{hashfile} +\alias{hashfile} +\title{Determine the sha from a blob in a file} +\usage{ +hashfile(path = NULL) +} +\arguments{ +\item{path}{The path vector with files to hash.} +} +\value{ +A vector with the sha for each file in path. +} +\description{ +The blob is not written to the object database. +} +\examples{ +\dontrun{ +## Create a file. NOTE: The line endings from writeLines gives +## LF (line feed) on Unix/Linux and CRLF (carriage return, line feed) +## on Windows. The example use writeChar to have more control. +path <- tempfile() +f <- file(path, "wb") +writeChar("Hello, world!\\n", f, eos = NULL) +close(f) + +## Generate hash +hashfile(path) +identical(hashfile(path), hash("Hello, world!\\n")) +} +} diff -Nru r-cran-git2r-0.21.0/man/hash-methods.Rd r-cran-git2r-0.22.1/man/hash-methods.Rd --- r-cran-git2r-0.21.0/man/hash-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/hash-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{hash} -\alias{hash} -\alias{hash,character-method} -\title{Determine the sha from a blob string} -\usage{ -hash(data) - -\S4method{hash}{character}(data) -} -\arguments{ -\item{data}{The string vector to hash.} -} -\value{ -A string vector with the sha for each string in data. -} -\description{ -The blob is not written to the object database. -} -\examples{ -\dontrun{ -identical(hash(c("Hello, world!\\n", - "test content\\n")), - c("af5626b4a114abcb82d63db7c8082c3c4756e51b", - "d670460b4b4aece5915caf5c68d12f560a9fe3e4")) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/hash.Rd r-cran-git2r-0.22.1/man/hash.Rd --- r-cran-git2r-0.21.0/man/hash.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/hash.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blob.R +\name{hash} +\alias{hash} +\title{Determine the sha from a blob string} +\usage{ +hash(data = NULL) +} +\arguments{ +\item{data}{The string vector to hash.} +} +\value{ +A string vector with the sha for each string in data. +} +\description{ +The blob is not written to the object database. +} +\examples{ +\dontrun{ +identical(hash(c("Hello, world!\\n", + "test content\\n")), + c("af5626b4a114abcb82d63db7c8082c3c4756e51b", + "d670460b4b4aece5915caf5c68d12f560a9fe3e4")) +} +} diff -Nru r-cran-git2r-0.21.0/man/head.git_repository.Rd r-cran-git2r-0.22.1/man/head.git_repository.Rd --- r-cran-git2r-0.21.0/man/head.git_repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/head.git_repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{head.git_repository} +\alias{head.git_repository} +\title{Get HEAD for a repository} +\usage{ +\method{head}{git_repository}(x, ...) +} +\arguments{ +\item{x}{The repository \code{x} to check head} + +\item{...}{Additional arguments. Unused.} +} +\value{ +NULL if unborn branch or not found. A git_branch if not a + detached head. A git_commit if detached head +} +\description{ +Get HEAD for a repository +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Commit message") + +## Get HEAD of repository +head(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/head-methods.Rd r-cran-git2r-0.22.1/man/head-methods.Rd --- r-cran-git2r-0.21.0/man/head-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/head-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{head,git_repository-method} -\alias{head,git_repository-method} -\title{Get HEAD for a repository} -\usage{ -\S4method{head}{git_repository}(x) -} -\arguments{ -\item{x}{The repository \code{x} to check head} -} -\value{ -NULL if unborn branch or not found. S4 class git_branch if -not a detached head. S4 class git_commit if detached head -} -\description{ -Get HEAD for a repository -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Commit message") - -## Get HEAD of repository -head(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/index_remove_bypath-methods.Rd r-cran-git2r-0.22.1/man/index_remove_bypath-methods.Rd --- r-cran-git2r-0.21.0/man/index_remove_bypath-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/index_remove_bypath-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/index.r -\docType{methods} -\name{index_remove_bypath} -\alias{index_remove_bypath} -\alias{index_remove_bypath,git_repository,character-method} -\title{Remove an index entry corresponding to a file on disk} -\usage{ -index_remove_bypath(repo, path) - -\S4method{index_remove_bypath}{git_repository,character}(repo, path) -} -\arguments{ -\item{repo}{The repository \code{object}.} - -\item{path}{character vector with filenames to remove. The path -must be relative to the repository's working folder. It may -exist. If this file currently is the result of a merge -conflict, this file will no longer be marked as -conflicting. The data about the conflict will be moved to the -"resolve undo" (REUC) section.} -} -\value{ -invisible(NULL) -} -\description{ -Remove an index entry corresponding to a file on disk -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file -writeLines("Hello world!", file.path(path, "file-to-remove.txt")) - -## Add file to repository -add(repo, "file-to-remove.txt") - -## View status of repository -status(repo) - -## Remove file -index_remove_bypath(repo, "file-to-remove.txt") - -## View status of repository -status(repo) -} - -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/index_remove_bypath.Rd r-cran-git2r-0.22.1/man/index_remove_bypath.Rd --- r-cran-git2r-0.21.0/man/index_remove_bypath.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/index_remove_bypath.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,51 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/index.R +\name{index_remove_bypath} +\alias{index_remove_bypath} +\title{Remove an index entry corresponding to a file on disk} +\usage{ +index_remove_bypath(repo = ".", path = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{path}{character vector with filenames to remove. The path +must be relative to the repository's working folder. It may +exist. If this file currently is the result of a merge +conflict, this file will no longer be marked as +conflicting. The data about the conflict will be moved to the +"resolve undo" (REUC) section.} +} +\value{ +invisible(NULL) +} +\description{ +Remove an index entry corresponding to a file on disk +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file +writeLines("Hello world!", file.path(path, "file-to-remove.txt")) + +## Add file to repository +add(repo, "file-to-remove.txt") + +## View status of repository +status(repo) + +## Remove file +index_remove_bypath(repo, "file-to-remove.txt") + +## View status of repository +status(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/init-methods.Rd r-cran-git2r-0.22.1/man/init-methods.Rd --- r-cran-git2r-0.21.0/man/init-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/init-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{init} -\alias{init} -\alias{init,character-method} -\title{Init a repository} -\usage{ -init(path, bare = FALSE) - -\S4method{init}{character}(path, bare = FALSE) -} -\arguments{ -\item{path}{A path to where to init a git repository} - -\item{bare}{If TRUE, a Git repository without a working directory -is created at the pointed path. If FALSE, provided path will be -considered as the working directory into which the .git directory -will be created.} -} -\value{ -A S4 \code{\linkS4class{git_repository}} object -} -\description{ -Init a repository -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -is_bare(repo) - -## Initialize a bare repository -path_bare <- tempfile(pattern="git2r-") -dir.create(path_bare) -repo_bare <- init(path_bare, bare = TRUE) -is_bare(repo_bare) -} -} -\seealso{ -\link{repository} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/init.Rd r-cran-git2r-0.22.1/man/init.Rd --- r-cran-git2r-0.21.0/man/init.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/init.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{init} +\alias{init} +\title{Init a repository} +\usage{ +init(path = ".", bare = FALSE) +} +\arguments{ +\item{path}{A path to where to init a git repository} + +\item{bare}{If TRUE, a Git repository without a working directory +is created at the pointed path. If FALSE, provided path will +be considered as the working directory into which the .git +directory will be created.} +} +\value{ +A \code{git_repository} object +} +\description{ +Init a repository +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +is_bare(repo) + +## Initialize a bare repository +path_bare <- tempfile(pattern="git2r-") +dir.create(path_bare) +repo_bare <- init(path_bare, bare = TRUE) +is_bare(repo_bare) +} +} +\seealso{ +\link{repository} +} diff -Nru r-cran-git2r-0.21.0/man/in_repository-methods.Rd r-cran-git2r-0.22.1/man/in_repository-methods.Rd --- r-cran-git2r-0.21.0/man/in_repository-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/in_repository-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{in_repository} -\alias{in_repository} -\alias{in_repository,missing-method} -\alias{in_repository,character-method} -\title{Determine if a directory is in a git repository} -\usage{ -in_repository(path) - -\S4method{in_repository}{missing}() - -\S4method{in_repository}{character}(path) -} -\arguments{ -\item{path}{The path to the directory. The working directory is -used if path is missing.} -} -\value{ -TRUE if directory is in a git repository else FALSE -} -\description{ -The lookup start from path and walk across parent directories if -nothing has been found. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Check if path is in a git repository -in_repository(path) - -## Check if working directory is in a git repository -setwd(path) -in_repository() -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/in_repository.Rd r-cran-git2r-0.22.1/man/in_repository.Rd --- r-cran-git2r-0.21.0/man/in_repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/in_repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{in_repository} +\alias{in_repository} +\title{Determine if a directory is in a git repository} +\usage{ +in_repository(path = ".") +} +\arguments{ +\item{path}{The path to the directory.} +} +\value{ +TRUE if directory is in a git repository else FALSE +} +\description{ +The lookup start from path and walk across parent directories if +nothing has been found. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Check if path is in a git repository +in_repository(path) + +## Check if working directory is in a git repository +setwd(path) +in_repository() +} +} diff -Nru r-cran-git2r-0.21.0/man/is_bare-methods.Rd r-cran-git2r-0.22.1/man/is_bare-methods.Rd --- r-cran-git2r-0.21.0/man/is_bare-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_bare-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{is_bare} -\alias{is_bare} -\alias{is_bare,git_repository-method} -\alias{is_bare,missing-method} -\title{Check if repository is bare} -\usage{ -is_bare(repo) - -\S4method{is_bare}{git_repository}(repo) - -\S4method{is_bare}{missing}() -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}} to check if it's bare. If the -\code{repo} argument is missing, the repository is searched for -with \code{\link{discover_repository}} in the current working -directory.} -} -\value{ -TRUE if bare repository, else FALSE -} -\description{ -Check if repository is bare -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -is_bare(repo) - -## Initialize a bare repository -path_bare <- tempfile(pattern="git2r-") -dir.create(path_bare) -repo_bare <- init(path_bare, bare = TRUE) -is_bare(repo_bare) -} -} -\seealso{ -\link{init} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_bare.Rd r-cran-git2r-0.22.1/man/is_bare.Rd --- r-cran-git2r-0.21.0/man/is_bare.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_bare.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{is_bare} +\alias{is_bare} +\title{Check if repository is bare} +\usage{ +is_bare(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +\code{TRUE} if bare repository, else \code{FALSE} +} +\description{ +Check if repository is bare +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +is_bare(repo) + +## Initialize a bare repository +path_bare <- tempfile(pattern="git2r-") +dir.create(path_bare) +repo_bare <- init(path_bare, bare = TRUE) +is_bare(repo_bare) +} +} +\seealso{ +\link{init} +} diff -Nru r-cran-git2r-0.21.0/man/is_binary-methods.Rd r-cran-git2r-0.22.1/man/is_binary-methods.Rd --- r-cran-git2r-0.21.0/man/is_binary-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_binary-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{is_binary} -\alias{is_binary} -\alias{is_binary,git_blob-method} -\title{Is blob binary} -\usage{ -is_binary(blob) - -\S4method{is_binary}{git_blob}(blob) -} -\arguments{ -\item{blob}{The blob \code{object}.} -} -\value{ -TRUE if binary data, FALSE if not. -} -\description{ -Is blob binary -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") - -## Check if binary -b_text <- tree(commit_1)["example.txt"] -is_binary(b_text) - -## Commit plot file (binary) -x <- 1:100 -y <- x^2 -png(file.path(path, "plot.png")) -plot(y ~ x, type = "l") -dev.off() -add(repo, "plot.png") -commit_2 <- commit(repo, "Second commit message") - -## Check if binary -b_png <- tree(commit_2)["plot.png"] -is_binary(b_png) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_binary.Rd r-cran-git2r-0.22.1/man/is_binary.Rd --- r-cran-git2r-0.21.0/man/is_binary.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_binary.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blob.R +\name{is_binary} +\alias{is_binary} +\title{Is blob binary} +\usage{ +is_binary(blob = NULL) +} +\arguments{ +\item{blob}{The blob \code{object}.} +} +\value{ +TRUE if binary data, FALSE if not. +} +\description{ +Is blob binary +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Commit a text file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") + +## Check if binary +b_text <- tree(commit_1)["example.txt"] +is_binary(b_text) + +## Commit plot file (binary) +x <- 1:100 +y <- x^2 +png(file.path(path, "plot.png")) +plot(y ~ x, type = "l") +dev.off() +add(repo, "plot.png") +commit_2 <- commit(repo, "Second commit message") + +## Check if binary +b_png <- tree(commit_2)["plot.png"] +is_binary(b_png) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_blob.Rd r-cran-git2r-0.22.1/man/is_blob.Rd --- r-cran-git2r-0.21.0/man/is_blob.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_blob.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,19 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r +% Please edit documentation in R/blob.R \name{is_blob} \alias{is_blob} -\title{Check if object is S4 class git_blob} +\title{Check if object is S3 class git_blob} \usage{ is_blob(object) } \arguments{ -\item{object}{Check if object is S4 class git_blob} +\item{object}{Check if object is S3 class git_blob} } \value{ -TRUE if object is S4 class git_blob, else FALSE +TRUE if object is S3 class git_blob, else FALSE } \description{ -Check if object is S4 class git_blob +Check if object is S3 class git_blob } \examples{ \dontrun{ @@ -36,4 +36,3 @@ is_blob(blob_1) } } -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_branch.Rd r-cran-git2r-0.22.1/man/is_branch.Rd --- r-cran-git2r-0.21.0/man/is_branch.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_branch.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,19 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r +% Please edit documentation in R/branch.R \name{is_branch} \alias{is_branch} -\title{Check if object is S4 class git_branch} +\title{Check if object is \code{git_branch}} \usage{ is_branch(object) } \arguments{ -\item{object}{Check if object is S4 class git_branch} +\item{object}{Check if object is of class \code{git_branch}} } \value{ -TRUE if object is S4 class git_branch, else FALSE +TRUE if object is class \code{git_branch}, else FALSE } \description{ -Check if object is S4 class git_branch +Check if object is \code{git_branch} } \examples{ \dontrun{ @@ -36,4 +36,3 @@ is_branch(branch) } } -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_commit.Rd r-cran-git2r-0.22.1/man/is_commit.Rd --- r-cran-git2r-0.21.0/man/is_commit.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_commit.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,19 +1,19 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r +% Please edit documentation in R/commit.R \name{is_commit} \alias{is_commit} -\title{Check if object is S4 class git_commit} +\title{Check if object is a git_commit object} \usage{ is_commit(object) } \arguments{ -\item{object}{Check if object is S4 class git_commit} +\item{object}{Check if object is a git_commit object} } \value{ -TRUE if object is S4 class git_commit, else FALSE +TRUE if object is a git_commit, else FALSE } \description{ -Check if object is S4 class git_commit +Check if object is a git_commit object } \examples{ \dontrun{ @@ -34,4 +34,3 @@ is_commit(commit_1) } } -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_detached-methods.Rd r-cran-git2r-0.22.1/man/is_detached-methods.Rd --- r-cran-git2r-0.21.0/man/is_detached-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_detached-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{is_detached} -\alias{is_detached} -\alias{is_detached,missing-method} -\alias{is_detached,git_repository-method} -\title{Check if HEAD of repository is detached} -\usage{ -is_detached(repo) - -\S4method{is_detached}{missing}() - -\S4method{is_detached}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -TRUE if repository HEAD is detached, else FALSE -} -\description{ -Check if HEAD of repository is detached -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "Commit message 1") - -## Change file, add and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Commit message 2") - -## HEAD of repository is not detached -is_detached(repo) - -## Checkout first commit -checkout(commit_1) - -## HEAD of repository is detached -is_detached(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_detached.Rd r-cran-git2r-0.22.1/man/is_detached.Rd --- r-cran-git2r-0.21.0/man/is_detached.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_detached.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{is_detached} +\alias{is_detached} +\title{Check if HEAD of repository is detached} +\usage{ +is_detached(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +\code{TRUE} if repository HEAD is detached, else + \code{FALSE}. +} +\description{ +Check if HEAD of repository is detached +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "Commit message 1") + +## Change file, add and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Commit message 2") + +## HEAD of repository is not detached +is_detached(repo) + +## Checkout first commit +checkout(commit_1) + +## HEAD of repository is detached +is_detached(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_empty-methods.Rd r-cran-git2r-0.22.1/man/is_empty-methods.Rd --- r-cran-git2r-0.21.0/man/is_empty-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_empty-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{is_empty} -\alias{is_empty} -\alias{is_empty,missing-method} -\alias{is_empty,git_repository-method} -\title{Check if repository is empty} -\usage{ -is_empty(repo) - -\S4method{is_empty}{missing}() - -\S4method{is_empty}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}} to check if it's empty. If the -\code{repo} argument is missing, the repository is searched for -with \code{\link{discover_repository}} in the current working -directory.} -} -\value{ -TRUE if empty else FALSE -} -\description{ -Check if repository is empty -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Check if it's an empty repository -is_empty(repo) - -## Commit a file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Check if it's an empty repository -is_empty(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_empty.Rd r-cran-git2r-0.22.1/man/is_empty.Rd --- r-cran-git2r-0.21.0/man/is_empty.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_empty.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{is_empty} +\alias{is_empty} +\title{Check if repository is empty} +\usage{ +is_empty(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +\code{TRUE} if repository is empty else \code{FALSE}. +} +\description{ +Check if repository is empty +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Check if it's an empty repository +is_empty(repo) + +## Commit a file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Check if it's an empty repository +is_empty(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_head-methods.Rd r-cran-git2r-0.22.1/man/is_head-methods.Rd --- r-cran-git2r-0.21.0/man/is_head-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_head-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{is_head} -\alias{is_head} -\alias{is_head,git_branch-method} -\title{Check if branch is head} -\usage{ -is_head(branch) - -\S4method{is_head}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch \code{object} to check if it's head} -} -\value{ -TRUE if branch is head, else FALSE -} -\description{ -Check if branch is head -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## List branches -branches(repo) - -## Check that 'master' is_head -master <- branches(repo)[[1]] -is_head(master) - -## Create and checkout 'dev' branch -checkout(repo, "dev", create = TRUE) - -## List branches -branches(repo) - -## Check that 'master' is no longer head -is_head(master) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_head.Rd r-cran-git2r-0.22.1/man/is_head.Rd --- r-cran-git2r-0.21.0/man/is_head.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_head.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{is_head} +\alias{is_head} +\title{Check if branch is head} +\usage{ +is_head(branch = NULL) +} +\arguments{ +\item{branch}{The branch \code{object} to check if it's head.} +} +\value{ +\code{TRUE} if branch is head, else \code{FALSE}. +} +\description{ +Check if branch is head +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## List branches +branches(repo) + +## Check that 'master' is_head +master <- branches(repo)[[1]] +is_head(master) + +## Create and checkout 'dev' branch +checkout(repo, "dev", create = TRUE) + +## List branches +branches(repo) + +## Check that 'master' is no longer head +is_head(master) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_local-methods.Rd r-cran-git2r-0.22.1/man/is_local-methods.Rd --- r-cran-git2r-0.21.0/man/is_local-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_local-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{is_local} -\alias{is_local} -\alias{is_local,git_branch-method} -\title{Check if branch is local} -\usage{ -is_local(branch) - -\S4method{is_local}{git_branch}(branch) -} -\arguments{ -\item{branch}{The branch \code{object} to check if it's local} -} -\value{ -TRUE if branch is local, else FALSE -} -\description{ -Check if branch is local -} -\examples{ -\dontrun{ -## Initialize repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config first user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## List branches -branches(repo) - -## Check if first branch is_local -is_local(branches(repo)[[1]]) - -## Check if second branch is_local -is_local(branches(repo)[[2]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_local.Rd r-cran-git2r-0.22.1/man/is_local.Rd --- r-cran-git2r-0.21.0/man/is_local.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_local.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/branch.R +\name{is_local} +\alias{is_local} +\title{Check if branch is local} +\usage{ +is_local(branch) +} +\arguments{ +\item{branch}{The branch \code{object} to check if it's local} +} +\value{ +\code{TRUE} if branch is local, else \code{FALSE}. +} +\description{ +Check if branch is local +} +\examples{ +\dontrun{ +## Initialize repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config first user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## List branches +branches(repo) + +## Check if first branch is_local +is_local(branches(repo)[[1]]) + +## Check if second branch is_local +is_local(branches(repo)[[2]]) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_merge-methods.Rd r-cran-git2r-0.22.1/man/is_merge-methods.Rd --- r-cran-git2r-0.21.0/man/is_merge-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_merge-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{is_merge} -\alias{is_merge} -\alias{is_merge,git_commit-method} -\title{Is merge} -\usage{ -is_merge(commit) - -\S4method{is_merge}{git_commit}(commit) -} -\arguments{ -\item{commit}{a S4 class git_commit \code{object}.} -} -\value{ -TRUE if commit has more than one parent, else FALSE -} -\description{ -Determine if a commit is a merge commit, i.e. has more than one -parent. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines(c("First line in file 1.", "Second line in file 1."), - file.path(path, "example-1.txt")) -add(repo, "example-1.txt") -commit(repo, "First commit message") - -## Create and add one more file -writeLines(c("First line in file 2.", "Second line in file 2."), - file.path(path, "example-2.txt")) -add(repo, "example-2.txt") -commit(repo, "Second commit message") - -## Create a new branch 'fix' -checkout(repo, "fix", create = TRUE) - -## Update 'example-1.txt' (swap words in first line) and commit -writeLines(c("line First in file 1.", "Second line in file 1."), - file.path(path, "example-1.txt")) -add(repo, "example-1.txt") -commit(repo, "Third commit message") - -checkout(repo, "master") - -## Update 'example-2.txt' (swap words in second line) and commit -writeLines(c("First line in file 2.", "line Second in file 2."), - file.path(path, "example-2.txt")) -add(repo, "example-2.txt") -commit(repo, "Fourth commit message") - -## Merge 'fix' -merge(repo, "fix") - -## Display parents of last commit -parents(lookup(repo, branch_target(head(repo)))) - -## Check that last commit is a merge -is_merge(lookup(repo, branch_target(head(repo)))) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_merge.Rd r-cran-git2r-0.22.1/man/is_merge.Rd --- r-cran-git2r-0.21.0/man/is_merge.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_merge.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{is_merge} +\alias{is_merge} +\title{Is merge} +\usage{ +is_merge(commit = NULL) +} +\arguments{ +\item{commit}{a git_commit object.} +} +\value{ +TRUE if commit has more than one parent, else FALSE +} +\description{ +Determine if a commit is a merge commit, i.e. has more than one +parent. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines(c("First line in file 1.", "Second line in file 1."), + file.path(path, "example-1.txt")) +add(repo, "example-1.txt") +commit(repo, "First commit message") + +## Create and add one more file +writeLines(c("First line in file 2.", "Second line in file 2."), + file.path(path, "example-2.txt")) +add(repo, "example-2.txt") +commit(repo, "Second commit message") + +## Create a new branch 'fix' +checkout(repo, "fix", create = TRUE) + +## Update 'example-1.txt' (swap words in first line) and commit +writeLines(c("line First in file 1.", "Second line in file 1."), + file.path(path, "example-1.txt")) +add(repo, "example-1.txt") +commit(repo, "Third commit message") + +checkout(repo, "master") + +## Update 'example-2.txt' (swap words in second line) and commit +writeLines(c("First line in file 2.", "line Second in file 2."), + file.path(path, "example-2.txt")) +add(repo, "example-2.txt") +commit(repo, "Fourth commit message") + +## Merge 'fix' +merge(repo, "fix") + +## Display parents of last commit +parents(lookup(repo, branch_target(repository_head(repo)))) + +## Check that last commit is a merge +is_merge(lookup(repo, branch_target(repository_head(repo)))) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_shallow-methods.Rd r-cran-git2r-0.22.1/man/is_shallow-methods.Rd --- r-cran-git2r-0.21.0/man/is_shallow-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_shallow-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{is_shallow} -\alias{is_shallow} -\alias{is_shallow,missing-method} -\alias{is_shallow,git_repository-method} -\title{Determine if the repository was a shallow clone} -\usage{ -is_shallow(repo) - -\S4method{is_shallow}{missing}() - -\S4method{is_shallow}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -TRUE if shallow clone, else FALSE -} -\description{ -Determine if the repository was a shallow clone -} -\examples{ -\dontrun{ -## Initialize repository -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") -dir.create(path_repo_1) -dir.create(path_repo_2) -repo_1 <- init(path_repo_1) - -## Config user and commit a file -config(repo_1, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "First commit message") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Second commit message") - -## Change file again and commit. -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", - "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Third commit message") - -## Clone to second repository -repo_2 <- clone(path_repo_1, path_repo_2) - -## Check if it's a shallow clone -is_shallow(repo_2) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/is_shallow.Rd r-cran-git2r-0.22.1/man/is_shallow.Rd --- r-cran-git2r-0.21.0/man/is_shallow.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_shallow.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,58 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{is_shallow} +\alias{is_shallow} +\title{Determine if the repository is a shallow clone} +\usage{ +is_shallow(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +\code{TRUE} if shallow clone, else \code{FALSE} +} +\description{ +Determine if the repository is a shallow clone +} +\examples{ +\dontrun{ +## Initialize repository +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") +dir.create(path_repo_1) +dir.create(path_repo_2) +repo_1 <- init(path_repo_1) + +## Config user and commit a file +config(repo_1, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "First commit message") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Second commit message") + +## Change file again and commit. +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Third commit message") + +## Clone to second repository +repo_2 <- clone(path_repo_1, path_repo_2) + +## Check if it's a shallow clone +is_shallow(repo_2) +} +} diff -Nru r-cran-git2r-0.21.0/man/is_tree.Rd r-cran-git2r-0.22.1/man/is_tree.Rd --- r-cran-git2r-0.21.0/man/is_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/is_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{is_tree} +\alias{is_tree} +\title{Check if object is S3 class git_tree} +\usage{ +is_tree(object) +} +\arguments{ +\item{object}{Check if object is S3 class git_tree} +} +\value{ +TRUE if object is S3 class git_tree, else FALSE +} +\description{ +Check if object is S3 class git_tree +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Commit a text file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") +tree_1 <- tree(commit_1) + +## Check if tree +is_tree(commit_1) +is_tree(tree_1) +} +} +\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/last_commit.Rd r-cran-git2r-0.22.1/man/last_commit.Rd --- r-cran-git2r-0.21.0/man/last_commit.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/last_commit.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{last_commit} +\alias{last_commit} +\title{Last commit} +\usage{ +last_commit(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\description{ +Get last commit in the current branch. +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Get last commit +last_commit(repo) +last_commit(path) + +## Coerce the last commit to a data.frame +as.data.frame(last_commit(path), "data.frame") + +## Summary of last commit in repository +summary(last_commit(repo)) +} +} diff -Nru r-cran-git2r-0.21.0/man/length-git_blob-method.Rd r-cran-git2r-0.22.1/man/length-git_blob-method.Rd --- r-cran-git2r-0.21.0/man/length-git_blob-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/length-git_blob-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{length,git_blob-method} -\alias{length,git_blob-method} -\title{Size in bytes of the contents of a blob} -\usage{ -\S4method{length}{git_blob}(x) -} -\arguments{ -\item{x}{The blob \code{object}} -} -\value{ -a non-negative integer -} -\description{ -Size in bytes of the contents of a blob -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") -blob_1 <- tree(commit_1)["example.txt"] - -## Get length in size of bytes of the content of the blob -length(blob_1) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/length.git_blob.Rd r-cran-git2r-0.22.1/man/length.git_blob.Rd --- r-cran-git2r-0.21.0/man/length.git_blob.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/length.git_blob.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/blob.R +\name{length.git_blob} +\alias{length.git_blob} +\title{Size in bytes of the contents of a blob} +\usage{ +\method{length}{git_blob}(x) +} +\arguments{ +\item{x}{The blob \code{object}} +} +\value{ +a non-negative integer +} +\description{ +Size in bytes of the contents of a blob +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Commit a text file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") +blob_1 <- tree(commit_1)["example.txt"] + +## Get length in size of bytes of the content of the blob +length(blob_1) +} +} diff -Nru r-cran-git2r-0.21.0/man/length-git_diff-method.Rd r-cran-git2r-0.22.1/man/length-git_diff-method.Rd --- r-cran-git2r-0.21.0/man/length-git_diff-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/length-git_diff-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/diff.r -\docType{methods} -\name{length,git_diff-method} -\alias{length,git_diff-method} -\title{Number of files in git_diff object} -\usage{ -\S4method{length}{git_diff}(x) -} -\arguments{ -\item{x}{The git_diff \code{object}} -} -\value{ -a non-negative integer -} -\description{ -Number of files in git_diff object -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/length.git_diff.Rd r-cran-git2r-0.22.1/man/length.git_diff.Rd --- r-cran-git2r-0.21.0/man/length.git_diff.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/length.git_diff.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/diff.R +\name{length.git_diff} +\alias{length.git_diff} +\title{Number of files in git_diff object} +\usage{ +\method{length}{git_diff}(x) +} +\arguments{ +\item{x}{The git_diff \code{object}} +} +\value{ +a non-negative integer +} +\description{ +Number of files in git_diff object +} diff -Nru r-cran-git2r-0.21.0/man/length-git_tree-method.Rd r-cran-git2r-0.22.1/man/length-git_tree-method.Rd --- r-cran-git2r-0.21.0/man/length-git_tree-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/length-git_tree-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{length,git_tree-method} -\alias{length,git_tree-method} -\title{Number of entries in tree} -\usage{ -\S4method{length}{git_tree}(x) -} -\arguments{ -\item{x}{The tree \code{object}} -} -\value{ -a non-negative integer or double (which will be rounded -down) -} -\description{ -Number of entries in tree -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/length.git_tree.Rd r-cran-git2r-0.22.1/man/length.git_tree.Rd --- r-cran-git2r-0.21.0/man/length.git_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/length.git_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{length.git_tree} +\alias{length.git_tree} +\title{Number of entries in tree} +\usage{ +\method{length}{git_tree}(x) +} +\arguments{ +\item{x}{The tree \code{object}} +} +\value{ +a non-negative integer or double (which will be rounded +down) +} +\description{ +Number of entries in tree +} diff -Nru r-cran-git2r-0.21.0/man/libgit2_features.Rd r-cran-git2r-0.22.1/man/libgit2_features.Rd --- r-cran-git2r-0.21.0/man/libgit2_features.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/libgit2_features.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/libgit2.r +% Please edit documentation in R/libgit2.R \name{libgit2_features} \alias{libgit2_features} \title{Compile time options for libgit2.} diff -Nru r-cran-git2r-0.21.0/man/libgit2_sha.Rd r-cran-git2r-0.22.1/man/libgit2_sha.Rd --- r-cran-git2r-0.21.0/man/libgit2_sha.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/libgit2_sha.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/libgit2.r -\name{libgit2_sha} -\alias{libgit2_sha} -\title{SHA of the libgit2 library} -\usage{ -libgit2_sha() -} -\value{ -The 40 character hexadecimal string of the SHA-1 -} -\description{ -SHA of the libgit2 library that the bundled source code is based -on -} -\examples{ -libgit2_sha() -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/libgit2_version.Rd r-cran-git2r-0.22.1/man/libgit2_version.Rd --- r-cran-git2r-0.21.0/man/libgit2_version.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/libgit2_version.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/libgit2.r +% Please edit documentation in R/libgit2.R \name{libgit2_version} \alias{libgit2_version} \title{Version of the libgit2 library} diff -Nru r-cran-git2r-0.21.0/man/lookup-methods.Rd r-cran-git2r-0.22.1/man/lookup-methods.Rd --- r-cran-git2r-0.21.0/man/lookup-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/lookup-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{lookup} -\alias{lookup} -\alias{lookup,git_repository,character-method} -\title{Lookup} -\usage{ -lookup(repo, sha) - -\S4method{lookup}{git_repository,character}(repo, sha) -} -\arguments{ -\item{repo}{The repository.} - -\item{sha}{The identity of the object to lookup. Must be 4 to 40 -characters long.} -} -\value{ -a \code{git_blob} or \code{git_commit} or \code{git_tag} -or \code{git_tree} object -} -\description{ -Lookup one object in a repository. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") - -## Create tag -tag(repo, "Tagname", "Tag message") - -## First, get SHAs to lookup in the repository -sha_commit <- commit_1@sha -sha_tree <- tree(commit_1)@sha -sha_blob <- tree(commit_1)["example.txt"]@sha -sha_tag <- tags(repo)[[1]]@sha - -## SHAs -sha_commit -sha_tree -sha_blob -sha_tag - -## Lookup objects -lookup(repo, sha_commit) -lookup(repo, sha_tree) -lookup(repo, sha_blob) -lookup(repo, sha_tag) - -## Lookup objects, using only the first seven characters -lookup(repo, substr(sha_commit, 1, 7)) -lookup(repo, substr(sha_tree, 1, 7)) -lookup(repo, substr(sha_blob, 1, 7)) -lookup(repo, substr(sha_tag, 1, 7)) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/lookup.Rd r-cran-git2r-0.22.1/man/lookup.Rd --- r-cran-git2r-0.21.0/man/lookup.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/lookup.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{lookup} +\alias{lookup} +\title{Lookup} +\usage{ +lookup(repo = ".", sha = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{sha}{The identity of the object to lookup. Must be 4 to 40 +characters long.} +} +\value{ +a \code{git_blob} or \code{git_commit} or \code{git_tag} +or \code{git_tree} object +} +\description{ +Lookup one object in a repository. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") + +## Create tag +tag(repo, "Tagname", "Tag message") + +## First, get SHAs to lookup in the repository +sha_commit <- commit_1@sha +sha_tree <- tree(commit_1)@sha +sha_blob <- tree(commit_1)["example.txt"]$sha +sha_tag <- tags(repo)[[1]]@sha + +## SHAs +sha_commit +sha_tree +sha_blob +sha_tag + +## Lookup objects +lookup(repo, sha_commit) +lookup(repo, sha_tree) +lookup(repo, sha_blob) +lookup(repo, sha_tag) + +## Lookup objects, using only the first seven characters +lookup(repo, substr(sha_commit, 1, 7)) +lookup(repo, substr(sha_tree, 1, 7)) +lookup(repo, substr(sha_blob, 1, 7)) +lookup(repo, substr(sha_tag, 1, 7)) +} +} diff -Nru r-cran-git2r-0.21.0/man/lookup_repository.Rd r-cran-git2r-0.22.1/man/lookup_repository.Rd --- r-cran-git2r-0.21.0/man/lookup_repository.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/lookup_repository.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\name{lookup_repository} -\alias{lookup_repository} -\title{Lookup repository for methods with missing repo argument} -\usage{ -lookup_repository() -} -\value{ -S4 class git_repository -} -\description{ -Lookup repository for methods with missing repo argument -} -\keyword{internal} diff -Nru r-cran-git2r-0.21.0/man/ls_tree.Rd r-cran-git2r-0.22.1/man/ls_tree.Rd --- r-cran-git2r-0.21.0/man/ls_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/ls_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{ls_tree} +\alias{ls_tree} +\title{List the contents of a tree object} +\usage{ +ls_tree(tree = NULL, repo = ".", recursive = TRUE) +} +\arguments{ +\item{tree}{default (\code{NULL}) is the tree of the last commit +in \code{repo}. Can also be a \code{git_tree} object or a +character that identifies a tree in the repository (see +\sQuote{Examples}).} + +\item{repo}{never used if \code{tree} is a \code{git_tree} +object. A \code{git_repository} object, or a path (default = +'.') to a repository.} + +\item{recursive}{default is to recurse into sub-trees.} +} +\value{ +A data.frame with the following columns: \describe{ + \item{mode}{UNIX file attribute of the tree entry} + \item{type}{type of object} \item{sha}{sha of the object} + \item{path}{path relative to the root tree} + \item{name}{filename of the tree entry} \item{len}{object size + of blob (file) entries. NA for other objects.} } +} +\description{ +Traverse the entries in a tree and its subtrees. Akin to the 'git +ls-tree' command. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +dir.create(file.path(path, "subfolder")) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create three files and commit +writeLines("First file", file.path(path, "example-1.txt")) +writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +writeLines("Third file", file.path(path, "example-3.txt")) +add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +commit(repo, "Commit message") + +## Traverse tree entries and its subtrees. +## Various approaches that give identical result. +ls_tree(tree = tree(last_commit(path))) +ls_tree(tree = tree(last_commit(repo))) +ls_tree(repo = path) +ls_tree(repo = repo) + +## Skip content in subfolder +ls_tree(repo = repo, recursive = FALSE) + +## Start in subfolder +ls_tree(tree = "HEAD:subfolder", repo = repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/merge_base-methods.Rd r-cran-git2r-0.22.1/man/merge_base-methods.Rd --- r-cran-git2r-0.21.0/man/merge_base-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/merge_base-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/merge.r -\docType{methods} -\name{merge_base} -\alias{merge_base} -\alias{merge_base,git_commit,git_commit-method} -\title{Find a merge base between two commits} -\usage{ -merge_base(one, two) - -\S4method{merge_base}{git_commit,git_commit}(one, two) -} -\arguments{ -\item{one}{One of the commits} - -\item{two}{The other commit} -} -\value{ -S4 class git_commit -} -\description{ -Find a merge base between two commits -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Master branch", file.path(path, "master_branch.txt")) -add(repo, "master_branch.txt") -commit_1 <- commit(repo, "Commit message 1") - -## Create first branch, checkout, add file and commit -branch_1 <- branch_create(commit_1, "branch_1") -checkout(branch_1) -writeLines("Branch 1", file.path(path, "branch_1.txt")) -add(repo, "branch_1.txt") -commit_2 <- commit(repo, "Commit message branch_1") - -## Create second branch, checkout, add file and commit -branch_2 <- branch_create(commit_1, "branch_2") -checkout(branch_2) -writeLines("Branch 2", file.path(path, "branch_2.txt")) -add(repo, "branch_2.txt") -commit_3 <- commit(repo, "Commit message branch_2") - -## Check that merge base equals commit_1 -stopifnot(identical(merge_base(commit_2, commit_3), commit_1)) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/merge_base.Rd r-cran-git2r-0.22.1/man/merge_base.Rd --- r-cran-git2r-0.21.0/man/merge_base.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/merge_base.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/merge.R +\name{merge_base} +\alias{merge_base} +\title{Find a merge base between two commits} +\usage{ +merge_base(one = NULL, two = NULL) +} +\arguments{ +\item{one}{One of the commits} + +\item{two}{The other commit} +} +\value{ +git_commit +} +\description{ +Find a merge base between two commits +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Master branch", file.path(path, "master_branch.txt")) +add(repo, "master_branch.txt") +commit_1 <- commit(repo, "Commit message 1") + +## Create first branch, checkout, add file and commit +branch_1 <- branch_create(commit_1, "branch_1") +checkout(branch_1) +writeLines("Branch 1", file.path(path, "branch_1.txt")) +add(repo, "branch_1.txt") +commit_2 <- commit(repo, "Commit message branch_1") + +## Create second branch, checkout, add file and commit +branch_2 <- branch_create(commit_1, "branch_2") +checkout(branch_2) +writeLines("Branch 2", file.path(path, "branch_2.txt")) +add(repo, "branch_2.txt") +commit_3 <- commit(repo, "Commit message branch_2") + +## Check that merge base equals commit_1 +stopifnot(identical(merge_base(commit_2, commit_3), commit_1)) +} +} diff -Nru r-cran-git2r-0.21.0/man/merge_branch.Rd r-cran-git2r-0.22.1/man/merge_branch.Rd --- r-cran-git2r-0.21.0/man/merge_branch.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/merge_branch.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/merge.r -\name{merge_branch} -\alias{merge_branch} -\title{Merge branch into HEAD} -\usage{ -merge_branch(branch, commit_on_success, merger) -} -\arguments{ -\item{branch}{The branch} - -\item{commit_on_success}{If there are no conflicts written to the -index, the merge commit will be committed.} - -\item{merger}{Who made the merge.} -} -\value{ -A \code{\linkS4class{git_merge_result}} object. -} -\description{ -Merge branch into HEAD -} -\keyword{internal} diff -Nru r-cran-git2r-0.21.0/man/merge-methods.Rd r-cran-git2r-0.22.1/man/merge-methods.Rd --- r-cran-git2r-0.21.0/man/merge-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/merge-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/merge.r -\docType{methods} -\name{merge,git_repository,character-method} -\alias{merge,git_repository,character-method} -\alias{merge,git_branch,missing-method} -\title{Merge a branch into HEAD} -\usage{ -\S4method{merge}{git_repository,character}(x, y, ..., - commit_on_success = TRUE, merger = default_signature(x)) - -\S4method{merge}{git_branch,missing}(x, ..., commit_on_success = TRUE, - merger = default_signature(x@repo)) -} -\arguments{ -\item{x}{A \code{\linkS4class{git_branch}} or -\code{\linkS4class{git_repository}} object.} - -\item{y}{If \code{x} is a \code{\linkS4class{git_repository}}, the -name of the branch to merge into HEAD. Not used if \code{x} is a -\code{\linkS4class{git_branch}}.} - -\item{...}{Additional arguments affecting the merge} - -\item{commit_on_success}{If there are no conflicts written to the -index, the merge commit will be committed. Default is TRUE.} - -\item{merger}{Who made the merge.} -} -\value{ -A \code{\linkS4class{git_merge_result}} object. -} -\description{ -Merge a branch into HEAD -} -\examples{ -\dontrun{ -## Create a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email = "alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit_1 <- commit(repo, "Commit message 1") - -## Create first branch, checkout, add file and commit -checkout(repo, "branch1", create = TRUE) -writeLines("Branch 1", file.path(path, "branch-1.txt")) -add(repo, "branch-1.txt") -commit(repo, "Commit message branch 1") - -## Create second branch, checkout, add file and commit -b_2 <- branch_create(commit_1, "branch2") -checkout(b_2) -writeLines("Branch 2", file.path(path, "branch-2.txt")) -add(repo, "branch-2.txt") -commit(repo, "Commit message branch 2") - -## Make a change to 'test.txt' -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Second commit message branch 2") - -## Checkout master -checkout(repo, "master", force = TRUE) - -## Merge branch 1 -merge(repo, "branch1") - -## Merge branch 2 -merge(repo, "branch2") - -## Create third branch, checkout, change file and commit -checkout(repo, "branch3", create=TRUE) -writeLines(c("Lorem ipsum dolor amet sit, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Commit message branch 3") - -## Checkout master and create a change that creates a merge conflict -checkout(repo, "master", force=TRUE) -writeLines(c("Lorem ipsum dolor sit amet, adipisicing consectetur elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Some commit message branch 1") - -## Merge branch 3 -merge(repo, "branch3") - -## Check status; Expect to have one unstaged unmerged conflict. -status(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/merge_named_branch.Rd r-cran-git2r-0.22.1/man/merge_named_branch.Rd --- r-cran-git2r-0.21.0/man/merge_named_branch.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/merge_named_branch.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/merge.r -\name{merge_named_branch} -\alias{merge_named_branch} -\title{Merge named branch into HEAD} -\usage{ -merge_named_branch(repo, branch, commit_on_success, merger) -} -\arguments{ -\item{repo}{The repository} - -\item{branch}{Name of branch} - -\item{commit_on_success}{If there are no conflicts written to the -index, the merge commit will be committed.} - -\item{merger}{Who made the merge.} -} -\value{ -A \code{\linkS4class{git_merge_result}} object. -} -\description{ -Merge named branch into HEAD -} -\keyword{internal} diff -Nru r-cran-git2r-0.21.0/man/merge.Rd r-cran-git2r-0.22.1/man/merge.Rd --- r-cran-git2r-0.21.0/man/merge.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/merge.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,125 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/merge.R +\name{merge.git_branch} +\alias{merge.git_branch} +\alias{merge.git_repository} +\alias{merge.character} +\title{Merge a branch into HEAD} +\usage{ +\method{merge}{git_branch}(x, y = NULL, commit_on_success = TRUE, + merger = NULL, fail = FALSE, ...) + +\method{merge}{git_repository}(x, y = NULL, commit_on_success = TRUE, + merger = NULL, fail = FALSE, ...) + +\method{merge}{character}(x = ".", y = NULL, commit_on_success = TRUE, + merger = NULL, fail = FALSE, ...) +} +\arguments{ +\item{x}{A path (default '.') to a repository, or a +\code{git_repository} object, or a \code{git_branch}.} + +\item{y}{If \code{x} is a \code{git_repository}, the name of the +branch to merge into HEAD. Not used if \code{x} is a +\code{git_branch}.} + +\item{commit_on_success}{If there are no conflicts written to the +index, the merge commit will be committed. Default is TRUE.} + +\item{merger}{Who made the merge. The default (\code{NULL}) is to +use \code{default_signature} for the repository.} + +\item{fail}{If a conflict occurs, exit immediately instead of +attempting to continue resolving conflicts. Default is +\code{FALSE}.} + +\item{...}{Additional arguments (unused).} +} +\value{ +A list of class \code{git_merge_result} with entries: +\describe{ + \item{up_to_date}{ + TRUE if the merge is already up-to-date, else FALSE. + } + \item{fast_forward}{ + TRUE if a fast-forward merge, else FALSE. + } + \item{conflicts}{ + TRUE if the index contain entries representing file conflicts, + else FALSE. + } + \item{sha}{ + If the merge created a merge commit, the sha of the merge + commit. NA if no merge commit created. + } +} +} +\description{ +Merge a branch into HEAD +} +\examples{ +\dontrun{ +## Create a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email = "alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit_1 <- commit(repo, "Commit message 1") + +## Create first branch, checkout, add file and commit +checkout(repo, "branch1", create = TRUE) +writeLines("Branch 1", file.path(path, "branch-1.txt")) +add(repo, "branch-1.txt") +commit(repo, "Commit message branch 1") + +## Create second branch, checkout, add file and commit +b_2 <- branch_create(commit_1, "branch2") +checkout(b_2) +writeLines("Branch 2", file.path(path, "branch-2.txt")) +add(repo, "branch-2.txt") +commit(repo, "Commit message branch 2") + +## Make a change to 'test.txt' +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Second commit message branch 2") + +## Checkout master +checkout(repo, "master", force = TRUE) + +## Merge branch 1 +merge(repo, "branch1") + +## Merge branch 2 +merge(repo, "branch2") + +## Create third branch, checkout, change file and commit +checkout(repo, "branch3", create=TRUE) +writeLines(c("Lorem ipsum dolor amet sit, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Commit message branch 3") + +## Checkout master and create a change that creates a merge conflict +checkout(repo, "master", force=TRUE) +writeLines(c("Lorem ipsum dolor sit amet, adipisicing consectetur elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Some commit message branch 1") + +## Merge branch 3 +merge(repo, "branch3") + +## Check status; Expect to have one unstaged unmerged conflict. +status(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/note_create-methods.Rd r-cran-git2r-0.22.1/man/note_create-methods.Rd --- r-cran-git2r-0.21.0/man/note_create-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/note_create-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/note.r -\docType{methods} -\name{note_create} -\alias{note_create} -\alias{note_create,git_blob-method} -\alias{note_create,git_commit-method} -\alias{note_create,git_tree-method} -\title{Add note for a object} -\usage{ -note_create(object, message, ref = note_default_ref(object@repo), - author = default_signature(object@repo), - committer = default_signature(object@repo), force = FALSE) - -\S4method{note_create}{git_blob}(object, message, - ref = note_default_ref(object@repo), - author = default_signature(object@repo), - committer = default_signature(object@repo), force = FALSE) - -\S4method{note_create}{git_commit}(object, message, - ref = note_default_ref(object@repo), - author = default_signature(object@repo), - committer = default_signature(object@repo), force = FALSE) - -\S4method{note_create}{git_tree}(object, message, - ref = note_default_ref(object@repo), - author = default_signature(object@repo), - committer = default_signature(object@repo), force = FALSE) -} -\arguments{ -\item{object}{The object to annotate} - -\item{message}{Content of the note to add} - -\item{ref}{Canonical name of the reference to use. Default is -\code{note_default_ref}.} - -\item{author}{Signature of the notes note author} - -\item{committer}{Signature of the notes note committer} - -\item{force}{Overwrite existing note. Default is FALSE} -} -\value{ -S4 class git_note -} -\description{ -Add note for a object -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "Commit message 1") - -## Create another commit -writeLines(c("Hello world!", - "HELLO WORLD!"), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit_2 <- commit(repo, "Commit message 2") - -## Check that notes is an empty list -notes(repo) - -## Create note in default namespace -note_create(commit_1, "Note-1") - -## Create note in named (review) namespace -note_create(commit_1, "Note-2", ref="refs/notes/review") -note_create(commit_2, "Note-3", ref="review") - -## Create note on blob and tree -note_create(tree(commit_1), "Note-4") -note_create(tree(commit_1)["example.txt"], "Note-5") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/note_create.Rd r-cran-git2r-0.22.1/man/note_create.Rd --- r-cran-git2r-0.21.0/man/note_create.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/note_create.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/note.R +\name{note_create} +\alias{note_create} +\title{Add note for a object} +\usage{ +note_create(object = NULL, message = NULL, ref = NULL, author = NULL, + committer = NULL, force = FALSE) +} +\arguments{ +\item{object}{The object to annotate (git_blob, git_commit or +git_tree).} + +\item{message}{Content of the note to add} + +\item{ref}{Canonical name of the reference to use. Default is +\code{note_default_ref}.} + +\item{author}{Signature of the notes note author} + +\item{committer}{Signature of the notes note committer} + +\item{force}{Overwrite existing note. Default is FALSE} +} +\value{ +git_note +} +\description{ +Add note for a object +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "Commit message 1") + +## Create another commit +writeLines(c("Hello world!", + "HELLO WORLD!"), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit_2 <- commit(repo, "Commit message 2") + +## Check that notes is an empty list +notes(repo) + +## Create note in default namespace +note_create(commit_1, "Note-1") + +## Create note in named (review) namespace +note_create(commit_1, "Note-2", ref="refs/notes/review") +note_create(commit_2, "Note-3", ref="review") + +## Create note on blob and tree +note_create(tree(commit_1), "Note-4") +note_create(tree(commit_1)["example.txt"], "Note-5") +} +} diff -Nru r-cran-git2r-0.21.0/man/note_default_ref-methods.Rd r-cran-git2r-0.22.1/man/note_default_ref-methods.Rd --- r-cran-git2r-0.21.0/man/note_default_ref-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/note_default_ref-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/note.r -\docType{methods} -\name{note_default_ref} -\alias{note_default_ref} -\alias{note_default_ref,git_repository-method} -\title{Default notes reference} -\usage{ -note_default_ref(repo) - -\S4method{note_default_ref}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository} -} -\value{ -Character vector of length one with name of default notes -reference -} -\description{ -Get the default notes reference for a repository -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## View default notes reference -note_default_ref(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/note_default_ref.Rd r-cran-git2r-0.22.1/man/note_default_ref.Rd --- r-cran-git2r-0.21.0/man/note_default_ref.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/note_default_ref.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/note.R +\name{note_default_ref} +\alias{note_default_ref} +\title{Default notes reference} +\usage{ +note_default_ref(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +Character vector of length one with name of default notes + reference +} +\description{ +Get the default notes reference for a repository +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## View default notes reference +note_default_ref(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/note_remove-methods.Rd r-cran-git2r-0.22.1/man/note_remove-methods.Rd --- r-cran-git2r-0.21.0/man/note_remove-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/note_remove-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/note.r -\docType{methods} -\name{note_remove} -\alias{note_remove} -\alias{note_remove,git_note-method} -\title{Remove the note for an object} -\usage{ -note_remove(note, author = default_signature(note@repo), - committer = default_signature(note@repo)) - -\S4method{note_remove}{git_note}(note, author = default_signature(note@repo), - committer = default_signature(note@repo)) -} -\arguments{ -\item{note}{The note to remove} - -\item{author}{Signature of the notes commit author.} - -\item{committer}{Signature of the notes commit committer.} -} -\value{ -invisible NULL -} -\description{ -Remove the note for an object -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "Commit message 1") - - -## Create note in default namespace -note_1 <- note_create(commit_1, "Note-1") - -## Create note in named (review) namespace -note_2 <- note_create(commit_1, "Note-2", ref="refs/notes/review") - -## List notes in default namespace -notes(repo) - -## List notes in 'review' namespace -notes(repo, "review") - -## Remove notes -note_remove(note_1) -note_remove(note_2) - -## List notes in default namespace -notes(repo) - -## List notes in 'review' namespace -notes(repo, "review") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/note_remove.Rd r-cran-git2r-0.22.1/man/note_remove.Rd --- r-cran-git2r-0.21.0/man/note_remove.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/note_remove.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,58 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/note.R +\name{note_remove} +\alias{note_remove} +\title{Remove the note for an object} +\usage{ +note_remove(note = NULL, author = NULL, committer = NULL) +} +\arguments{ +\item{note}{The note to remove} + +\item{author}{Signature of the notes commit author.} + +\item{committer}{Signature of the notes commit committer.} +} +\value{ +invisible NULL +} +\description{ +Remove the note for an object +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "Commit message 1") + + +## Create note in default namespace +note_1 <- note_create(commit_1, "Note-1") + +## Create note in named (review) namespace +note_2 <- note_create(commit_1, "Note-2", ref="refs/notes/review") + +## List notes in default namespace +notes(repo) + +## List notes in 'review' namespace +notes(repo, "review") + +## Remove notes +note_remove(note_1) +note_remove(note_2) + +## List notes in default namespace +notes(repo) + +## List notes in 'review' namespace +notes(repo, "review") +} +} diff -Nru r-cran-git2r-0.21.0/man/notes-methods.Rd r-cran-git2r-0.22.1/man/notes-methods.Rd --- r-cran-git2r-0.21.0/man/notes-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/notes-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/note.r -\docType{methods} -\name{notes} -\alias{notes} -\alias{notes,git_repository-method} -\title{List notes} -\usage{ -notes(repo, ref = note_default_ref(repo)) - -\S4method{notes}{git_repository}(repo, ref = note_default_ref(repo)) -} -\arguments{ -\item{repo}{The repository} - -\item{ref}{Reference to read from. Default is -"refs/notes/commits".} -} -\value{ -list with S4 class git_note objects -} -\description{ -List all the notes within a specified namespace. -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "Commit message 1") - -## Create another commit -writeLines(c("Hello world!", - "HELLO WORLD!"), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit_2 <- commit(repo, "Commit message 2") - -## Create note in default namespace -note_create(commit_1, "Note-1") -note_create(commit_1, "Note-2", force = TRUE) - -## Create note in named (review) namespace -note_create(commit_1, "Note-3", ref="refs/notes/review") -note_create(commit_2, "Note-4", ref="review") - -## Create note on blob and tree -note_create(tree(commit_1), "Note-5") -note_create(tree(commit_1)["example.txt"], "Note-6") - -## List notes in default namespace -notes(repo) - -## List notes in 'review' namespace -notes(repo, "review") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/notes.Rd r-cran-git2r-0.22.1/man/notes.Rd --- r-cran-git2r-0.21.0/man/notes.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/notes.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,60 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/note.R +\name{notes} +\alias{notes} +\title{List notes} +\usage{ +notes(repo = ".", ref = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{ref}{Reference to read from. Default (ref = NULL) is to call +\code{note_default_ref}.} +} +\value{ +list with git_note objects +} +\description{ +List all the notes within a specified namespace. +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "Commit message 1") + +## Create another commit +writeLines(c("Hello world!", + "HELLO WORLD!"), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit_2 <- commit(repo, "Commit message 2") + +## Create note in default namespace +note_create(commit_1, "Note-1") +note_create(commit_1, "Note-2", force = TRUE) + +## Create note in named (review) namespace +note_create(commit_1, "Note-3", ref="refs/notes/review") +note_create(commit_2, "Note-4", ref="review") + +## Create note on blob and tree +note_create(tree(commit_1), "Note-5") +note_create(tree(commit_1)["example.txt"], "Note-6") + +## List notes in default namespace +notes(repo) + +## List notes in 'review' namespace +notes(repo, "review") +} +} diff -Nru r-cran-git2r-0.21.0/man/odb_blobs-methods.Rd r-cran-git2r-0.22.1/man/odb_blobs-methods.Rd --- r-cran-git2r-0.21.0/man/odb_blobs-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/odb_blobs-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/odb.r -\docType{methods} -\name{odb_blobs} -\alias{odb_blobs} -\alias{odb_blobs,missing-method} -\alias{odb_blobs,git_repository-method} -\title{Blobs in the object database} -\usage{ -odb_blobs(repo) - -\S4method{odb_blobs}{missing}() - -\S4method{odb_blobs}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository} -} -\value{ -A data.frame with the following columns: -\describe{ - \item{sha}{The sha of the blob} - \item{path}{The path to the blob from the tree and sub-trees} - \item{name}{The name of the blob from the tree that contains the blob} - \item{len}{The length of the blob} - \item{commit}{The sha of the commit} - \item{author}{The author of the commit} - \item{when}{The timestamp of the author signature in the commit} -} -} -\description{ -List all blobs reachable from the commits in the object -database. For each commit, list blob's in the commit tree and -sub-trees. -} -\note{ -A blob sha can have several entries -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Commit message 1") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Commit message 2") - -## Commit same content under different name in a sub-directory -dir.create(file.path(path, "sub-directory")) -file.copy(file.path(path, "test.txt"), file.path(path, "sub-directory", "copy.txt")) -add(repo, "sub-directory/copy.txt") -commit(repo, "Commit message 3") - -## List blobs -odb_blobs(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/odb_blobs.Rd r-cran-git2r-0.22.1/man/odb_blobs.Rd --- r-cran-git2r-0.21.0/man/odb_blobs.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/odb_blobs.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/odb.R +\name{odb_blobs} +\alias{odb_blobs} +\title{Blobs in the object database} +\usage{ +odb_blobs(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +A data.frame with the following columns: +\describe{ + \item{sha}{The sha of the blob} + \item{path}{The path to the blob from the tree and sub-trees} + \item{name}{The name of the blob from the tree that contains the blob} + \item{len}{The length of the blob} + \item{commit}{The sha of the commit} + \item{author}{The author of the commit} + \item{when}{The timestamp of the author signature in the commit} +} +} +\description{ +List all blobs reachable from the commits in the object +database. For each commit, list blob's in the commit tree and +sub-trees. +} +\note{ +A blob sha can have several entries +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Commit message 1") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Commit message 2") + +## Commit same content under different name in a sub-directory +dir.create(file.path(path, "sub-directory")) +file.copy(file.path(path, "test.txt"), file.path(path, "sub-directory", "copy.txt")) +add(repo, "sub-directory/copy.txt") +commit(repo, "Commit message 3") + +## List blobs +odb_blobs(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/odb_objects-methods.Rd r-cran-git2r-0.22.1/man/odb_objects-methods.Rd --- r-cran-git2r-0.21.0/man/odb_objects-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/odb_objects-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/odb.r -\docType{methods} -\name{odb_objects} -\alias{odb_objects} -\alias{odb_objects,missing-method} -\alias{odb_objects,git_repository-method} -\title{List all objects available in the database} -\usage{ -odb_objects(repo) - -\S4method{odb_objects}{missing}() - -\S4method{odb_objects}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository} -} -\value{ -A data.frame with the following columns: -\describe{ - \item{sha}{The sha of the object} - \item{type}{The type of the object} - \item{len}{The length of the object} -} -} -\description{ -List all objects available in the database -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Commit message 1") - -## Create tag -tag(repo, "Tagname", "Tag message") - -## List objects in repository -odb_objects(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/odb_objects.Rd r-cran-git2r-0.22.1/man/odb_objects.Rd --- r-cran-git2r-0.21.0/man/odb_objects.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/odb_objects.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/odb.R +\name{odb_objects} +\alias{odb_objects} +\title{List all objects available in the database} +\usage{ +odb_objects(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +A data.frame with the following columns: +\describe{ + \item{sha}{The sha of the object} + \item{type}{The type of the object} + \item{len}{The length of the object} +} +} +\description{ +List all objects available in the database +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Commit message 1") + +## Create tag +tag(repo, "Tagname", "Tag message") + +## List objects in repository +odb_objects(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/parents-methods.Rd r-cran-git2r-0.22.1/man/parents-methods.Rd --- r-cran-git2r-0.21.0/man/parents-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/parents-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{parents} -\alias{parents} -\alias{parents,git_commit-method} -\title{Parents} -\usage{ -parents(object) - -\S4method{parents}{git_commit}(object) -} -\arguments{ -\item{object}{a S4 class git_commit \code{object}.} -} -\value{ -list of S4 git_commit objects -} -\description{ -Get parents of a commit. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("First line.", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") - -## commit_1 has no parents -parents(commit_1) - -## Update 'example.txt' and commit -writeLines(c("First line.", "Second line."), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit_2 <- commit(repo, "Second commit message") - -## commit_2 has commit_1 as parent -parents(commit_2) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/parents.Rd r-cran-git2r-0.22.1/man/parents.Rd --- r-cran-git2r-0.21.0/man/parents.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/parents.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/commit.R +\name{parents} +\alias{parents} +\title{Parents} +\usage{ +parents(object = NULL) +} +\arguments{ +\item{object}{a git_commit object.} +} +\value{ +list of git_commit objects +} +\description{ +Get parents of a commit. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("First line.", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit_1 <- commit(repo, "First commit message") + +## commit_1 has no parents +parents(commit_1) + +## Update 'example.txt' and commit +writeLines(c("First line.", "Second line."), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit_2 <- commit(repo, "Second commit message") + +## commit_2 has commit_1 as parent +parents(commit_2) +} +} diff -Nru r-cran-git2r-0.21.0/man/plot.git_repository.Rd r-cran-git2r-0.22.1/man/plot.git_repository.Rd --- r-cran-git2r-0.21.0/man/plot.git_repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/plot.git_repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{plot.git_repository} +\alias{plot.git_repository} +\title{Plot commits over time} +\usage{ +\method{plot}{git_repository}(x, breaks = c("month", "year", "quarter", + "week", "day"), main = NULL, ...) +} +\arguments{ +\item{x}{The repository to plot} + +\item{breaks}{Default is \code{month}. Change to year, quarter, +week or day as necessary.} + +\item{main}{Default title for the plot is "Commits on repo:" and +repository workdir basename. Supply a new title if you desire one.} + +\item{...}{Additional arguments affecting the plot} +} +\description{ +Plot commits over time +} +\examples{ +\dontrun{ +## Initialize repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- clone("https://github.com/ropensci/git2r.git", path) + +## Plot commits +plot(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/plot-methods.Rd r-cran-git2r-0.22.1/man/plot-methods.Rd --- r-cran-git2r-0.21.0/man/plot-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/plot-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.r -\docType{methods} -\name{plot,git_repository-method} -\alias{plot,git_repository-method} -\alias{plot} -\title{Plot commits over time} -\usage{ -\S4method{plot}{git_repository}(x, breaks = c("month", "year", "quarter", - "week", "day"), main = NULL, ...) -} -\arguments{ -\item{x}{The repository to plot} - -\item{breaks}{Default is \code{month}. Change to year, quarter, -week or day as necessary.} - -\item{main}{Default title for the plot is "Commits on repo:" and -repository workdir basename. Supply a new title if you desire one.} - -\item{...}{Additional arguments affecting the plot} -} -\description{ -Plot commits over time -} -\examples{ -\dontrun{ -## Initialize repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- clone("https://github.com/ropensci/git2r.git", path) - -## Plot commits -plot(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/print.git_reflog_entry.Rd r-cran-git2r-0.22.1/man/print.git_reflog_entry.Rd --- r-cran-git2r-0.21.0/man/print.git_reflog_entry.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/print.git_reflog_entry.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reflog.R +\name{print.git_reflog_entry} +\alias{print.git_reflog_entry} +\title{Print a reflog entry} +\usage{ +\method{print}{git_reflog_entry}(x, ...) +} +\arguments{ +\item{x}{The reflog entry} + +\item{...}{Unused} +} +\value{ +None (invisible 'NULL'). +} +\description{ +Print a reflog entry +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## View repository HEAD reflog +reflog(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/pull-methods.Rd r-cran-git2r-0.22.1/man/pull-methods.Rd --- r-cran-git2r-0.21.0/man/pull-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/pull-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/pull.r -\docType{methods} -\name{pull} -\alias{pull} -\alias{pull,git_repository-method} -\title{Pull} -\usage{ -pull(repo, credentials = NULL, merger = default_signature(repo)) - -\S4method{pull}{git_repository}(repo, credentials = NULL, - merger = default_signature(repo)) -} -\arguments{ -\item{repo}{the repository} - -\item{credentials}{The credentials for remote repository -access. Default is NULL. To use and query an ssh-agent for the ssh -key credentials, let this parameter be NULL (the default).} - -\item{merger}{Who made the merge, if the merge is non-fast forward -merge that creates a merge commit.} -} -\value{ -invisible(NULL) -} -\description{ -Pull -} -\examples{ -\dontrun{ -## Initialize repositories -path_bare <- tempfile(pattern="git2r-") -path_repo_1 <- tempfile(pattern="git2r-") -path_repo_2 <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo_1) -dir.create(path_repo_2) -repo_bare <- init(path_bare, bare = TRUE) -repo_1 <- clone(path_bare, path_repo_1) - -## Config first user and commit a file -config(repo_1, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "First commit message") - -## Push commits from first repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo_1, "origin", "refs/heads/master") - -## Clone to second repository -repo_2 <- clone(path_bare, path_repo_2) -config(repo_2, user.name="Bob", user.email="bob@example.org") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path_repo_1, "example.txt")) -add(repo_1, "example.txt") -commit(repo_1, "Second commit message") - -## Push commits from first repository to bare repository -push(repo_1) - -## Pull changes to repo_2 -pull(repo_2) - -## Change file again and commit. This time in repository 2 -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", - "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), - file.path(path_repo_2, "example.txt")) -add(repo_2, "example.txt") -commit(repo_2, "Third commit message") - -## Push commits from second repository to bare repository -push(repo_2) - -## Pull changes to repo_1 -pull(repo_1) - -## List commits in repositories -commits(repo_1) -commits(repo_2) -commits(repo_bare) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/pull.Rd r-cran-git2r-0.22.1/man/pull.Rd --- r-cran-git2r-0.21.0/man/pull.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/pull.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,105 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pull.R +\name{pull} +\alias{pull} +\title{Pull} +\usage{ +pull(repo = ".", credentials = NULL, merger = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{credentials}{The credentials for remote repository +access. Default is NULL. To use and query an ssh-agent for the +ssh key credentials, let this parameter be NULL (the default).} + +\item{merger}{Who made the merge, if the merge is non-fast forward +merge that creates a merge commit. The +\code{default_signature} for \code{repo} is used if this +parameter is \code{NULL}.} +} +\value{ +A list of class \code{git_merge_result} with entries: +\describe{ + \item{up_to_date}{ + TRUE if the merge is already up-to-date, else FALSE. + } + \item{fast_forward}{ + TRUE if a fast-forward merge, else FALSE. + } + \item{conflicts}{ + TRUE if the index contain entries representing file conflicts, + else FALSE. + } + \item{sha}{ + If the merge created a merge commit, the sha of the merge + commit. NA if no merge commit created. + } +} +} +\description{ +Pull +} +\examples{ +\dontrun{ +## Initialize repositories +path_bare <- tempfile(pattern="git2r-") +path_repo_1 <- tempfile(pattern="git2r-") +path_repo_2 <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo_1) +dir.create(path_repo_2) +repo_bare <- init(path_bare, bare = TRUE) +repo_1 <- clone(path_bare, path_repo_1) + +## Config first user and commit a file +config(repo_1, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "First commit message") + +## Push commits from first repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo_1, "origin", "refs/heads/master") + +## Clone to second repository +repo_2 <- clone(path_bare, path_repo_2) +config(repo_2, user.name="Bob", user.email="bob@example.org") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path_repo_1, "example.txt")) +add(repo_1, "example.txt") +commit(repo_1, "Second commit message") + +## Push commits from first repository to bare repository +push(repo_1) + +## Pull changes to repo_2 +pull(repo_2) + +## Change file again and commit. This time in repository 2 +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), + file.path(path_repo_2, "example.txt")) +add(repo_2, "example.txt") +commit(repo_2, "Third commit message") + +## Push commits from second repository to bare repository +push(repo_2) + +## Pull changes to repo_1 +pull(repo_1) + +## List commits in repositories +commits(repo_1) +commits(repo_2) +commits(repo_bare) +} +} diff -Nru r-cran-git2r-0.21.0/man/punch_card-methods.Rd r-cran-git2r-0.22.1/man/punch_card-methods.Rd --- r-cran-git2r-0.21.0/man/punch_card-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/punch_card-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/punch_card.r -\docType{methods} -\name{punch_card} -\alias{punch_card} -\alias{punch_card,git_repository-method} -\title{Punch card} -\usage{ -punch_card(repo, main = NULL, ...) - -\S4method{punch_card}{git_repository}(repo, main = NULL, ...) -} -\arguments{ -\item{repo}{The repository} - -\item{main}{Default title for the plot is "Punch card on repo:" -and repository workdir basename. Supply a new title if you desire -one.} - -\item{...}{Additional arguments affecting the plot} -} -\value{ -invisible NULL -} -\description{ -Punch card -} -\examples{ -\dontrun{ -## Initialize repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- clone("https://github.com/ropensci/git2r.git", path) - -## Plot -punch_card(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/punch_card.Rd r-cran-git2r-0.22.1/man/punch_card.Rd --- r-cran-git2r-0.21.0/man/punch_card.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/punch_card.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/punch_card.R +\name{punch_card} +\alias{punch_card} +\title{Punch card} +\usage{ +punch_card(repo = ".", main = NULL, ...) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{main}{Default title for the plot is "Punch card on repo:" +and repository workdir basename. Supply a new title if you +desire one.} + +\item{...}{Additional arguments affecting the plot} +} +\value{ +invisible NULL +} +\description{ +Punch card +} +\examples{ +\dontrun{ +## Initialize repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- clone("https://github.com/ropensci/git2r.git", path) + +## Plot +punch_card(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/push-methods.Rd r-cran-git2r-0.22.1/man/push-methods.Rd --- r-cran-git2r-0.21.0/man/push-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/push-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/push.r -\docType{methods} -\name{push} -\alias{push} -\alias{push,git_branch-method} -\alias{push,git_repository-method} -\title{Push} -\usage{ -push(object, ...) - -\S4method{push}{git_branch}(object, force = FALSE, credentials = NULL) - -\S4method{push}{git_repository}(object, name = NULL, refspec = NULL, - force = FALSE, credentials = NULL) -} -\arguments{ -\item{object}{S4 class \code{git_repository} or \code{git_branch}.} - -\item{...}{Additional arguments affecting the push.} - -\item{force}{Force your local revision to the remote repo. Use it -with care. Default is FALSE.} - -\item{credentials}{The credentials for remote repository -access. Default is NULL. To use and query an ssh-agent for the ssh -key credentials, let this parameter be NULL (the default).} - -\item{name}{The remote's name. Default is NULL.} - -\item{refspec}{The refspec to be pushed. Default is NULL.} -} -\value{ -invisible(NULL) -} -\description{ -Push -} -\examples{ -\dontrun{ -## Initialize two temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "Second commit message") - -## Push commits from repository to bare repository -push(repo) - -## List commits in repository and bare repository -commits(repo) -commits(repo_bare) -} -} -\seealso{ -\code{\linkS4class{cred_user_pass}}, -\code{\linkS4class{cred_ssh_key}} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/push.Rd r-cran-git2r-0.22.1/man/push.Rd --- r-cran-git2r-0.21.0/man/push.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/push.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,71 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/push.R +\name{push} +\alias{push} +\title{Push} +\usage{ +push(object = ".", name = NULL, refspec = NULL, force = FALSE, + credentials = NULL) +} +\arguments{ +\item{object}{path to repository, or a \code{git_repository} or +\code{git_branch}.} + +\item{name}{The remote's name. Default is NULL.} + +\item{refspec}{The refspec to be pushed. Default is NULL.} + +\item{force}{Force your local revision to the remote repo. Use it +with care. Default is FALSE.} + +\item{credentials}{The credentials for remote repository +access. Default is NULL. To use and query an ssh-agent for the +ssh key credentials, let this parameter be NULL (the default).} +} +\value{ +invisible(NULL) +} +\description{ +Push +} +\examples{ +\dontrun{ +## Initialize two temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "Second commit message") + +## Push commits from repository to bare repository +push(repo) + +## List commits in repository and bare repository +commits(repo) +commits(repo_bare) +} +} +\seealso{ +\code{\link{cred_user_pass}}, \code{\link{cred_ssh_key}} +} diff -Nru r-cran-git2r-0.21.0/man/reexports.Rd r-cran-git2r-0.22.1/man/reexports.Rd --- r-cran-git2r-0.21.0/man/reexports.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/reexports.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/diff.R, R/merge.R, R/repository.R, R/tree.R +\docType{import} +\name{reexports} +\alias{reexports} +\alias{diff} +\alias{reexports} +\alias{merge} +\alias{reexports} +\alias{head} +\alias{reexports} +\alias{as.data.frame} +\title{Objects exported from other packages} +\keyword{internal} +\description{ +These objects are imported from other packages. Follow the links +below to see their documentation. + +\describe{ + \item{base}{\code{\link[base]{diff}}, \code{\link[base]{merge}}, \code{\link[base]{as.data.frame}}} + + \item{utils}{\code{\link[utils]{head}}} +}} + diff -Nru r-cran-git2r-0.21.0/man/references-methods.Rd r-cran-git2r-0.22.1/man/references-methods.Rd --- r-cran-git2r-0.21.0/man/references-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/references-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reference.r -\docType{methods} -\name{references} -\alias{references} -\alias{references,missing-method} -\alias{references,git_repository-method} -\title{Get all references that can be found in a repository.} -\usage{ -references(repo) - -\S4method{references}{missing}() - -\S4method{references}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -Character vector with references -} -\description{ -Get all references that can be found in a repository. -} -\examples{ -\dontrun{ -## Initialize two temporary repositories -path_bare <- tempfile(pattern="git2r-") -path_repo <- tempfile(pattern="git2r-") -dir.create(path_bare) -dir.create(path_repo) -repo_bare <- init(path_bare, bare = TRUE) -repo <- clone(path_bare, path_repo) - -## Config user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path_repo, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Push commits from repository to bare repository -## Adds an upstream tracking branch to branch 'master' -push(repo, "origin", "refs/heads/master") - -## Add tag to HEAD -tag(repo, "v1.0", "First version") - -## Create a note -note_create(commits(repo)[[1]], "My note") - -## List all references in repository -references(repo) -} - -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/references.Rd r-cran-git2r-0.22.1/man/references.Rd --- r-cran-git2r-0.21.0/man/references.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/references.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reference.R +\name{references} +\alias{references} +\title{Get all references that can be found in a repository.} +\usage{ +references(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +Character vector with references +} +\description{ +Get all references that can be found in a repository. +} +\examples{ +\dontrun{ +## Initialize two temporary repositories +path_bare <- tempfile(pattern="git2r-") +path_repo <- tempfile(pattern="git2r-") +dir.create(path_bare) +dir.create(path_repo) +repo_bare <- init(path_bare, bare = TRUE) +repo <- clone(path_bare, path_repo) + +## Config user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path_repo, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Push commits from repository to bare repository +## Adds an upstream tracking branch to branch 'master' +push(repo, "origin", "refs/heads/master") + +## Add tag to HEAD +tag(repo, "v1.0", "First version") + +## Create a note +note_create(commits(repo)[[1]], "My note") + +## List all references in repository +references(repo) +} + +} diff -Nru r-cran-git2r-0.21.0/man/reflog-methods.Rd r-cran-git2r-0.22.1/man/reflog-methods.Rd --- r-cran-git2r-0.21.0/man/reflog-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/reflog-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reflog.r -\docType{methods} -\name{reflog} -\alias{reflog} -\alias{reflog,git_repository,missing-method} -\alias{reflog,git_repository,character-method} -\title{List and view reflog information} -\usage{ -reflog(repo, refname) - -\S4method{reflog}{git_repository,missing}(repo) - -\S4method{reflog}{git_repository,character}(repo, refname) -} -\arguments{ -\item{repo}{S4 class git_repository \code{object}.} - -\item{refname}{The name of the reference to list. 'HEAD' by -default.} -} -\value{ -S3 class \code{git_reflog} with git_reflog_entry objects. -} -\description{ -List and view reflog information -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Second commit message") - -## Change file again and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", - "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Third commit message") - -## View reflog -reflog(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/reflog.Rd r-cran-git2r-0.22.1/man/reflog.Rd --- r-cran-git2r-0.21.0/man/reflog.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/reflog.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,56 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reflog.R +\name{reflog} +\alias{reflog} +\title{List and view reflog information} +\usage{ +reflog(repo = ".", refname = "HEAD") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{refname}{The name of the reference to list. 'HEAD' by +default.} +} +\value{ +S3 class \code{git_reflog} with git_reflog_entry objects. +} +\description{ +List and view reflog information +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Write to a file and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Second commit message") + +## Change file again and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), + file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Third commit message") + +## View reflog +reflog(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/remote_add-methods.Rd r-cran-git2r-0.22.1/man/remote_add-methods.Rd --- r-cran-git2r-0.21.0/man/remote_add-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_add-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remote_add} -\alias{remote_add} -\alias{remote_add,git_repository,character,character-method} -\title{Add a remote to a repo} -\usage{ -remote_add(repo, name, url) - -\S4method{remote_add}{git_repository,character,character}(repo, name, url) -} -\arguments{ -\item{repo}{The repository to add the remote to} - -\item{name}{Short name of the remote repository} - -\item{url}{URL of the remote repository} -} -\value{ -NULL, invisibly -} -\description{ -Add a remote to a repo -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Add a remote -remote_add(repo, "playground", "https://example.org/git2r/playground") -remotes(repo) -remote_url(repo, "playground") - -## Rename a remote -remote_rename(repo, "playground", "foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Remove a remote -remote_remove(repo, "foobar") -remotes(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remote_add.Rd r-cran-git2r-0.22.1/man/remote_add.Rd --- r-cran-git2r-0.21.0/man/remote_add.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_add.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remote_add} +\alias{remote_add} +\title{Add a remote to a repo} +\usage{ +remote_add(repo = ".", name = NULL, url = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{name}{Short name of the remote repository} + +\item{url}{URL of the remote repository} +} +\value{ +NULL, invisibly +} +\description{ +Add a remote to a repo +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Add a remote +remote_add(repo, "playground", "https://example.org/git2r/playground") +remotes(repo) +remote_url(repo, "playground") + +## Rename a remote +remote_rename(repo, "playground", "foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Set remote url +remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Remove a remote +remote_remove(repo, "foobar") +remotes(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/remote_ls-methods.Rd r-cran-git2r-0.22.1/man/remote_ls-methods.Rd --- r-cran-git2r-0.21.0/man/remote_ls-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_ls-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remote_ls} -\alias{remote_ls} -\alias{remote_ls,character-method} -\title{List references in a remote repository} -\usage{ -remote_ls(name, repo = NULL, credentials = NULL) - -\S4method{remote_ls}{character}(name, repo = NULL, credentials = NULL) -} -\arguments{ -\item{name}{Character vector with the "remote" repository URL to query or -the name of the remote if a \code{repo} argument is given.} - -\item{repo}{an optional repository object used if remotes are -specified by name.} - -\item{credentials}{The credentials for remote repository -access. Default is NULL. To use and query an ssh-agent for the ssh -key credentials, let this parameter be NULL (the default).} -} -\value{ -Character vector for each reference with the associated commit IDs. -} -\description{ -Displays references available in a remote repository along with the -associated commit IDs. Akin to the 'git ls-remote' command. -} -\examples{ -\dontrun{ -remote_ls("https://github.com/ropensci/git2r") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remote_ls.Rd r-cran-git2r-0.22.1/man/remote_ls.Rd --- r-cran-git2r-0.21.0/man/remote_ls.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_ls.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remote_ls} +\alias{remote_ls} +\title{List references in a remote repository} +\usage{ +remote_ls(name = NULL, repo = NULL, credentials = NULL) +} +\arguments{ +\item{name}{Character vector with the "remote" repository URL to +query or the name of the remote if a \code{repo} argument is +given.} + +\item{repo}{an optional repository object used if remotes are +specified by name.} + +\item{credentials}{The credentials for remote repository +access. Default is NULL. To use and query an ssh-agent for the +ssh key credentials, let this parameter be NULL (the default).} +} +\value{ +Character vector for each reference with the associated + commit IDs. +} +\description{ +Displays references available in a remote repository along with +the associated commit IDs. Akin to the 'git ls-remote' command. +} +\examples{ +\dontrun{ +remote_ls("https://github.com/ropensci/git2r") +} +} diff -Nru r-cran-git2r-0.21.0/man/remote_remove-methods.Rd r-cran-git2r-0.22.1/man/remote_remove-methods.Rd --- r-cran-git2r-0.21.0/man/remote_remove-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_remove-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remote_remove} -\alias{remote_remove} -\alias{remote_remove,git_repository,character-method} -\title{Remove a remote} -\usage{ -remote_remove(repo, name) - -\S4method{remote_remove}{git_repository,character}(repo, name) -} -\arguments{ -\item{repo}{The repository to work on} - -\item{name}{The name of the remote to remove} -} -\value{ -NULL, invisibly -} -\description{ -All remote-tracking branches and configuration settings for the -remote will be removed. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Add a remote -remote_add(repo, "playground", "https://example.org/git2r/playground") -remotes(repo) -remote_url(repo, "playground") - -## Rename a remote -remote_rename(repo, "playground", "foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Remove a remote -remote_remove(repo, "foobar") -remotes(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remote_remove.Rd r-cran-git2r-0.22.1/man/remote_remove.Rd --- r-cran-git2r-0.21.0/man/remote_remove.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_remove.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remote_remove} +\alias{remote_remove} +\title{Remove a remote} +\usage{ +remote_remove(repo = ".", name = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{name}{The name of the remote to remove} +} +\value{ +NULL, invisibly +} +\description{ +All remote-tracking branches and configuration settings for the +remote will be removed. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Add a remote +remote_add(repo, "playground", "https://example.org/git2r/playground") +remotes(repo) +remote_url(repo, "playground") + +## Rename a remote +remote_rename(repo, "playground", "foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Set remote url +remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Remove a remote +remote_remove(repo, "foobar") +remotes(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/remote_rename-methods.Rd r-cran-git2r-0.22.1/man/remote_rename-methods.Rd --- r-cran-git2r-0.21.0/man/remote_rename-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_rename-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remote_rename} -\alias{remote_rename} -\alias{remote_rename,git_repository,character,character-method} -\title{Rename a remote} -\usage{ -remote_rename(repo, oldname, newname) - -\S4method{remote_rename}{git_repository,character,character}(repo, oldname, - newname) -} -\arguments{ -\item{repo}{The repository in which the remote should be renamed.} - -\item{oldname}{Old name of the remote} - -\item{newname}{New name of the remote} -} -\value{ -NULL, invisibly -} -\description{ -Rename a remote -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Add a remote -remote_add(repo, "playground", "https://example.org/git2r/playground") -remotes(repo) -remote_url(repo, "playground") - -## Rename a remote -remote_rename(repo, "playground", "foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Remove a remote -remote_remove(repo, "foobar") -remotes(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remote_rename.Rd r-cran-git2r-0.22.1/man/remote_rename.Rd --- r-cran-git2r-0.21.0/man/remote_rename.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_rename.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remote_rename} +\alias{remote_rename} +\title{Rename a remote} +\usage{ +remote_rename(repo = ".", oldname = NULL, newname = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{oldname}{Old name of the remote} + +\item{newname}{New name of the remote} +} +\value{ +NULL, invisibly +} +\description{ +Rename a remote +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Add a remote +remote_add(repo, "playground", "https://example.org/git2r/playground") +remotes(repo) +remote_url(repo, "playground") + +## Rename a remote +remote_rename(repo, "playground", "foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Set remote url +remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Remove a remote +remote_remove(repo, "foobar") +remotes(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/remote_set_url-methods.Rd r-cran-git2r-0.22.1/man/remote_set_url-methods.Rd --- r-cran-git2r-0.21.0/man/remote_set_url-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_set_url-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remote_set_url} -\alias{remote_set_url} -\alias{remote_set_url,git_repository,character,character-method} -\title{Set the remote's url in the configuration} -\usage{ -remote_set_url(repo, name, url) - -\S4method{remote_set_url}{git_repository,character,character}(repo, name, url) -} -\arguments{ -\item{repo}{The repository in which to perform the change} - -\item{name}{The name of the remote} - -\item{url}{The \code{url} to set} -} -\value{ -NULL, invisibly -} -\description{ -This assumes the common case of a single-url remote and will -otherwise raise an error. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Add a remote -remote_add(repo, "playground", "https://example.org/git2r/playground") -remotes(repo) -remote_url(repo, "playground") - -## Rename a remote -remote_rename(repo, "playground", "foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Set remote url -remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Remove a remote -remote_remove(repo, "foobar") -remotes(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remote_set_url.Rd r-cran-git2r-0.22.1/man/remote_set_url.Rd --- r-cran-git2r-0.21.0/man/remote_set_url.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_set_url.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,56 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remote_set_url} +\alias{remote_set_url} +\title{Set the remote's url in the configuration} +\usage{ +remote_set_url(repo = ".", name = NULL, url = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{name}{The name of the remote} + +\item{url}{The \code{url} to set} +} +\value{ +NULL, invisibly +} +\description{ +This assumes the common case of a single-url remote and will +otherwise raise an error. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Add a remote +remote_add(repo, "playground", "https://example.org/git2r/playground") +remotes(repo) +remote_url(repo, "playground") + +## Rename a remote +remote_rename(repo, "playground", "foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Set remote url +remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Remove a remote +remote_remove(repo, "foobar") +remotes(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/remotes-methods.Rd r-cran-git2r-0.22.1/man/remotes-methods.Rd --- r-cran-git2r-0.21.0/man/remotes-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remotes-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remotes} -\alias{remotes} -\alias{remotes,missing-method} -\alias{remotes,git_repository-method} -\title{Get the configured remotes for a repo} -\usage{ -remotes(repo) - -\S4method{remotes}{missing}() - -\S4method{remotes}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -Character vector with remotes -} -\description{ -Get the configured remotes for a repo -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Add a remote -remote_add(repo, "playground", "https://example.org/git2r/playground") -remotes(repo) -remote_url(repo, "playground") - -## Rename a remote -remote_rename(repo, "playground", "foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Remove a remote -remote_remove(repo, "foobar") -remotes(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remotes.Rd r-cran-git2r-0.22.1/man/remotes.Rd --- r-cran-git2r-0.21.0/man/remotes.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remotes.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,51 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remotes} +\alias{remotes} +\title{Get the configured remotes for a repo} +\usage{ +remotes(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +Character vector with remotes +} +\description{ +Get the configured remotes for a repo +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Add a remote +remote_add(repo, "playground", "https://example.org/git2r/playground") +remotes(repo) +remote_url(repo, "playground") + +## Rename a remote +remote_rename(repo, "playground", "foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Set remote url +remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Remove a remote +remote_remove(repo, "foobar") +remotes(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/remote_url-methods.Rd r-cran-git2r-0.22.1/man/remote_url-methods.Rd --- r-cran-git2r-0.21.0/man/remote_url-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_url-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/remote.r -\docType{methods} -\name{remote_url} -\alias{remote_url} -\alias{remote_url,git_repository-method} -\title{Get the remote url for remotes in a repo} -\usage{ -remote_url(repo, remote = remotes(repo)) - -\S4method{remote_url}{git_repository}(repo, remote = remotes(repo)) -} -\arguments{ -\item{repo}{The repository to get remote urls from} - -\item{remote}{Character vector with the remotes to get the url -from. Default is the remotes of the repository.} -} -\value{ -Character vector with remote_url for each of the remote -} -\description{ -Get the remote url for remotes in a repo -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Add a remote -remote_add(repo, "playground", "https://example.org/git2r/playground") -remotes(repo) -remote_url(repo, "playground") - -## Rename a remote -remote_rename(repo, "playground", "foobar") -remotes(repo) -remote_url(repo, "foobar") - -## Remove a remote -remote_remove(repo, "foobar") -remotes(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/remote_url.Rd r-cran-git2r-0.22.1/man/remote_url.Rd --- r-cran-git2r-0.21.0/man/remote_url.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/remote_url.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/remote.R +\name{remote_url} +\alias{remote_url} +\title{Get the remote url for remotes in a repo} +\usage{ +remote_url(repo = ".", remote = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{remote}{Character vector with the remotes to get the url +from. Default is the remotes of the repository.} +} +\value{ +Character vector with remote_url for each of the remote +} +\description{ +Get the remote url for remotes in a repo +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Add a remote +remote_add(repo, "playground", "https://example.org/git2r/playground") +remotes(repo) +remote_url(repo, "playground") + +## Rename a remote +remote_rename(repo, "playground", "foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Set remote url +remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") +remotes(repo) +remote_url(repo, "foobar") + +## Remove a remote +remote_remove(repo, "foobar") +remotes(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/repository_head.Rd r-cran-git2r-0.22.1/man/repository_head.Rd --- r-cran-git2r-0.21.0/man/repository_head.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/repository_head.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{repository_head} +\alias{repository_head} +\title{Get HEAD for a repository} +\usage{ +repository_head(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +NULL if unborn branch or not found. A git_branch if not a + detached head. A git_commit if detached head +} +\description{ +Get HEAD for a repository +} +\examples{ +\dontrun{ +## Create and initialize a repository in a temporary directory +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "Commit message") + +## Get HEAD of repository +repository_head(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/repository-methods.Rd r-cran-git2r-0.22.1/man/repository-methods.Rd --- r-cran-git2r-0.21.0/man/repository-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/repository-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{repository} -\alias{repository} -\alias{repository,missing-method} -\alias{repository,character-method} -\title{Open a repository} -\usage{ -repository(path, ...) - -\S4method{repository}{missing}() - -\S4method{repository}{character}(path, discover = FALSE, ...) -} -\arguments{ -\item{path}{A path to an existing local git repository} - -\item{...}{Additional arguments to \code{repository} method.} - -\item{discover}{Discover repository from path. Default is FALSE.} -} -\value{ -A S4 \code{\linkS4class{git_repository}} object -} -\description{ -Open a repository -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "test-1.txt")) -add(repo, 'test-1.txt') -commit_1 <- commit(repo, "Commit message") - -## Make one more commit -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) -add(repo, 'test-1.txt') -commit(repo, "Next commit message") - -## Create one more file -writeLines("Hello world!", file.path(path, "test-2.txt")) - -## Brief summary of repository -repo - -## Summary of repository -summary(repo) - -## Workdir of repository -workdir(repo) - -## Check if repository is bare -is_bare(repo) - -## Check if repository is empty -is_empty(repo) - -## Check if repository is a shallow clone -is_shallow(repo) - -## List all references in repository -references(repo) - -## List all branches in repository -branches(repo) - -## Get HEAD of repository -head(repo) - -## Check if HEAD is head -is_head(head(repo)) - -## Check if HEAD is local -is_local(head(repo)) - -## List all tags in repository -tags(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/repository.Rd r-cran-git2r-0.22.1/man/repository.Rd --- r-cran-git2r-0.21.0/man/repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,84 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{repository} +\alias{repository} +\title{Open a repository} +\usage{ +repository(path = ".", discover = TRUE) +} +\arguments{ +\item{path}{A path to an existing local git repository.} + +\item{discover}{Discover repository from path. Default is TRUE.} +} +\value{ +A \code{git_repository} object with entries: +\describe{ + \item{path}{ + Path to a git repository + } +} +} +\description{ +Open a repository +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "test-1.txt")) +add(repo, 'test-1.txt') +commit_1 <- commit(repo, "Commit message") + +## Make one more commit +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +add(repo, 'test-1.txt') +commit(repo, "Next commit message") + +## Create one more file +writeLines("Hello world!", file.path(path, "test-2.txt")) + +## Brief summary of repository +repo + +## Summary of repository +summary(repo) + +## Workdir of repository +workdir(repo) + +## Check if repository is bare +is_bare(repo) + +## Check if repository is empty +is_empty(repo) + +## Check if repository is a shallow clone +is_shallow(repo) + +## List all references in repository +references(repo) + +## List all branches in repository +branches(repo) + +## Get HEAD of repository +repository_head(repo) + +## Check if HEAD is head +is_head(repository_head(repo)) + +## Check if HEAD is local +is_local(repository_head(repo)) + +## List all tags in repository +tags(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/reset-methods.Rd r-cran-git2r-0.22.1/man/reset-methods.Rd --- r-cran-git2r-0.21.0/man/reset-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/reset-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reset.r -\docType{methods} -\name{reset} -\alias{reset} -\alias{reset,git_commit-method} -\alias{reset,git_repository-method} -\alias{reset,character-method} -\title{Reset current HEAD to the specified state} -\usage{ -reset(object, ...) - -\S4method{reset}{git_commit}(object, reset_type = c("soft", "mixed", "hard")) - -\S4method{reset}{git_repository}(object, path) - -\S4method{reset}{character}(object) -} -\arguments{ -\item{object}{Either a \code{\linkS4class{git_commit}}, a -\code{\linkS4class{git_repository}} or a character vector. If -\code{object} is a \code{git_commit}, HEAD is moved to the -\code{git_commit}. If \code{object} is a -\code{git_repository}, resets the index entries in the -\code{path} argument to their state at HEAD. If \code{object} -is a character vector with paths, resets the index entries in -\code{object} to their state at HEAD if the current working -directory is in a repository.} - -\item{...}{Additional arguments affecting the reset.} - -\item{reset_type}{If object is a 'git_commit', the kind of reset -operation to perform. 'soft' means the HEAD will be moved to -the commit. 'mixed' reset will trigger a 'soft' reset, plus -the index will be replaced with the content of the commit -tree. 'hard' reset will trigger a 'mixed' reset and the -working directory will be replaced with the content of the -index.} - -\item{path}{If object is a 'git_repository', resets the index -entries for all paths to their state at HEAD.} -} -\value{ -invisible NULL -} -\description{ -Reset current HEAD to the specified state -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "test-1.txt")) -add(repo, 'test-1.txt') -commit_1 <- commit(repo, "Commit message") - -## Change and stage the file -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) -add(repo, 'test-1.txt') -status(repo) - -## Unstage file -reset(repo, 'test-1.txt') -status(repo) - -## Make one more commit -add(repo, 'test-1.txt') -commit(repo, "Next commit message") - -## Create one more file -writeLines("Hello world!", file.path(path, "test-2.txt")) - -## 'soft' reset to first commit and check status -reset(commit_1) -status(repo) - -## 'mixed' reset to first commit and check status -commit(repo, "Next commit message") -reset(commit_1, "mixed") -status(repo) - -## 'hard' reset to first commit and check status -add(repo, 'test-1.txt') -commit(repo, "Next commit message") -reset(commit_1, "hard") -status(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/reset.Rd r-cran-git2r-0.22.1/man/reset.Rd --- r-cran-git2r-0.21.0/man/reset.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/reset.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,82 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/reset.R +\name{reset} +\alias{reset} +\title{Reset current HEAD to the specified state} +\usage{ +reset(object, reset_type = c("soft", "mixed", "hard"), path = NULL) +} +\arguments{ +\item{object}{Either a \code{git_commit}, a \code{git_repository} +or a character vector. If \code{object} is a +\code{git_commit}, HEAD is moved to the \code{git_commit}. If +\code{object} is a \code{git_repository}, resets the index +entries in the \code{path} argument to their state at HEAD. If +\code{object} is a character vector with paths, resets the +index entries in \code{object} to their state at HEAD if the +current working directory is in a repository.} + +\item{reset_type}{If object is a 'git_commit', the kind of reset +operation to perform. 'soft' means the HEAD will be moved to +the commit. 'mixed' reset will trigger a 'soft' reset, plus +the index will be replaced with the content of the commit +tree. 'hard' reset will trigger a 'mixed' reset and the +working directory will be replaced with the content of the +index.} + +\item{path}{If object is a 'git_repository', resets the index +entries for all paths to their state at HEAD.} +} +\value{ +invisible NULL +} +\description{ +Reset current HEAD to the specified state +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Hello world!", file.path(path, "test-1.txt")) +add(repo, 'test-1.txt') +commit_1 <- commit(repo, "Commit message") + +## Change and stage the file +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +add(repo, 'test-1.txt') +status(repo) + +## Unstage file +reset(repo, 'test-1.txt') +status(repo) + +## Make one more commit +add(repo, 'test-1.txt') +commit(repo, "Next commit message") + +## Create one more file +writeLines("Hello world!", file.path(path, "test-2.txt")) + +## 'soft' reset to first commit and check status +reset(commit_1) +status(repo) + +## 'mixed' reset to first commit and check status +commit(repo, "Next commit message") +reset(commit_1, "mixed") +status(repo) + +## 'hard' reset to first commit and check status +add(repo, 'test-1.txt') +commit(repo, "Next commit message") +reset(commit_1, "hard") +status(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/revparse_single-methods.Rd r-cran-git2r-0.22.1/man/revparse_single-methods.Rd --- r-cran-git2r-0.21.0/man/revparse_single-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/revparse_single-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/revparse.r -\docType{methods} -\name{revparse_single} -\alias{revparse_single} -\alias{revparse_single,git_repository,character-method} -\title{Revparse} -\usage{ -revparse_single(repo, revision) - -\S4method{revparse_single}{git_repository,character}(repo, revision) -} -\arguments{ -\item{repo}{The repository} - -\item{revision}{The revision string, see -http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions} -} -\value{ -a \code{git_commit} or \code{git_tag} or \code{git_tree} -object -} -\description{ -Find object specified by revision. -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "First commit message") - -# Change file and commit -writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - "eiusmod tempor incididunt ut labore et dolore magna aliqua."), - con = file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Second commit message") - -revparse_single(repo, "HEAD^") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/revparse_single.Rd r-cran-git2r-0.22.1/man/revparse_single.Rd --- r-cran-git2r-0.21.0/man/revparse_single.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/revparse_single.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,49 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/revparse.R +\name{revparse_single} +\alias{revparse_single} +\title{Revparse} +\usage{ +revparse_single(repo = ".", revision = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{revision}{The revision string, see +http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions} +} +\value{ +a \code{git_commit} or \code{git_tag} or \code{git_tree} +object +} +\description{ +Find object specified by revision. +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "First commit message") + +# Change file and commit +writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + "eiusmod tempor incididunt ut labore et dolore magna aliqua."), + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Second commit message") + +revparse_single(repo, "HEAD^") +revparse_single(repo, "HEAD:test.txt") +} +} diff -Nru r-cran-git2r-0.21.0/man/rm_file-methods.Rd r-cran-git2r-0.22.1/man/rm_file-methods.Rd --- r-cran-git2r-0.21.0/man/rm_file-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/rm_file-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/index.r -\docType{methods} -\name{rm_file} -\alias{rm_file} -\alias{rm_file,git_repository,character-method} -\title{Remove files from the working tree and from the index} -\usage{ -rm_file(repo, path) - -\S4method{rm_file}{git_repository,character}(repo, path) -} -\arguments{ -\item{repo}{The repository \code{object}.} - -\item{path}{character vector with filenames to remove. The path -must be relative to the repository's working folder. Only files -known to Git are removed.} -} -\value{ -invisible(NULL) -} -\description{ -Remove files from the working tree and from the index -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file -writeLines("Hello world!", file.path(path, "file-to-remove.txt")) - -## Add file to repository -add(repo, "file-to-remove.txt") -commit(repo, "First commit message") - -## Remove file -rm_file(repo, "file-to-remove.txt") - -## View status of repository -status(repo) -} - -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/rm_file.Rd r-cran-git2r-0.22.1/man/rm_file.Rd --- r-cran-git2r-0.21.0/man/rm_file.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/rm_file.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/index.R +\name{rm_file} +\alias{rm_file} +\title{Remove files from the working tree and from the index} +\usage{ +rm_file(repo = ".", path = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{path}{character vector with filenames to remove. The path +must be relative to the repository's working folder. Only +files known to Git are removed.} +} +\value{ +invisible(NULL) +} +\description{ +Remove files from the working tree and from the index +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file +writeLines("Hello world!", file.path(path, "file-to-remove.txt")) + +## Add file to repository +add(repo, "file-to-remove.txt") +commit(repo, "First commit message") + +## Remove file +rm_file(repo, "file-to-remove.txt") + +## View status of repository +status(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/sha.Rd r-cran-git2r-0.22.1/man/sha.Rd --- r-cran-git2r-0.21.0/man/sha.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/sha.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/sha.R +\name{sha} +\alias{sha} +\alias{sha.git_blob} +\alias{sha.git_branch} +\alias{sha.git_commit} +\alias{sha.git_note} +\alias{sha.git_reflog_entry} +\alias{sha.git_tag} +\alias{sha.git_tree} +\alias{sha.git_fetch_head} +\alias{sha.git_merge_result} +\title{Get the SHA-1 of a git object} +\usage{ +sha(object) + +\method{sha}{git_blob}(object) + +\method{sha}{git_branch}(object) + +\method{sha}{git_commit}(object) + +\method{sha}{git_note}(object) + +\method{sha}{git_reflog_entry}(object) + +\method{sha}{git_tag}(object) + +\method{sha}{git_tree}(object) + +\method{sha}{git_fetch_head}(object) + +\method{sha}{git_merge_result}(object) +} +\arguments{ +\item{object}{a git object to get the SHA-1 from.} +} +\value{ +The 40 character hexadecimal string of the SHA-1. +} +\description{ +Get the 40 character hexadecimal string of the SHA-1. +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file, add and commit +writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", + con = file.path(path, "test.txt")) +add(repo, "test.txt") +commit(repo, "Commit message 1") + +## Get the SHA-1 of the last commit +sha(last_commit(repo)) +} +} diff -Nru r-cran-git2r-0.21.0/man/show-git_blob-method.Rd r-cran-git2r-0.22.1/man/show-git_blob-method.Rd --- r-cran-git2r-0.21.0/man/show-git_blob-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_blob-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{show,git_blob-method} -\alias{show,git_blob-method} -\alias{show,git_blob-methods} -\title{Brief summary of blob} -\usage{ -\S4method{show}{git_blob}(object) -} -\arguments{ -\item{object}{The blob \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of blob -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Brief summary of the blob in the repository -tree(commits(repo)[[1]])["example.txt"] -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_branch-method.Rd r-cran-git2r-0.22.1/man/show-git_branch-method.Rd --- r-cran-git2r-0.21.0/man/show-git_branch-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_branch-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/branch.r -\docType{methods} -\name{show,git_branch-method} -\alias{show,git_branch-method} -\alias{show,git_branch-methods} -\title{Brief summary of branch} -\usage{ -\S4method{show}{git_branch}(object) -} -\arguments{ -\item{object}{The branch \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of branch -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Brief summary of the branch in the repository -branches(repo)[[1]] -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_commit-method.Rd r-cran-git2r-0.22.1/man/show-git_commit-method.Rd --- r-cran-git2r-0.21.0/man/show-git_commit-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_commit-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{show,git_commit-method} -\alias{show,git_commit-method} -\alias{show,git_commit-methods} -\title{Brief summary of commit} -\usage{ -\S4method{show}{git_commit}(object) -} -\arguments{ -\item{object}{The commit \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Displays the first seven characters of the sha, the date and the -summary of the commit message: -\code{[shortened sha] yyyy-mm-dd: summary} -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Brief summary of commit in repository -show(commits(repo)[[1]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_diff-method.Rd r-cran-git2r-0.22.1/man/show-git_diff-method.Rd --- r-cran-git2r-0.21.0/man/show-git_diff-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_diff-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/diff.r -\docType{methods} -\name{show,git_diff-method} -\alias{show,git_diff-method} -\alias{show,git_diff-methods} -\title{Show a diff} -\usage{ -\S4method{show}{git_diff}(object) -} -\arguments{ -\item{object}{The diff \code{object}.} -} -\description{ -Show a diff -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add, commit -writeLines("Hello world!", file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Commit message") - -## Change the file -writeLines(c("Hello again!", "Here is a second line", "And a third"), - file.path(path, "test.txt")) - -## Brief summary of diff between index and workdir -diff(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_merge_result-method.Rd r-cran-git2r-0.22.1/man/show-git_merge_result-method.Rd --- r-cran-git2r-0.21.0/man/show-git_merge_result-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_merge_result-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/merge.r -\docType{methods} -\name{show,git_merge_result-method} -\alias{show,git_merge_result-method} -\alias{show,git_merge_result-methods} -\title{Brief summary of merge result} -\usage{ -\S4method{show}{git_merge_result}(object) -} -\arguments{ -\item{object}{The \code{\linkS4class{git_merge_result}} \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of merge result -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("First line.", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create and checkout a new branch. Update 'example.txt' and commit -checkout(repo, "new_branch", create=TRUE) -writeLines(c("First line.", "Second line."), - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "Second commit message") - -## Checkout 'master' branch -checkout(repo, "master", force = TRUE) - -## Display 'example.txt' -readLines(file.path(path, "example.txt")) - -## Merge and display brief summary of the fast-forward merge -merge(repo, "new_branch") - -## Display 'example.txt' -readLines(file.path(path, "example.txt")) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_note-method.Rd r-cran-git2r-0.22.1/man/show-git_note-method.Rd --- r-cran-git2r-0.21.0/man/show-git_note-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_note-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/note.r -\docType{methods} -\name{show,git_note-method} -\alias{show,git_note-method} -\alias{show,git_note-methods} -\title{Brief summary of note} -\usage{ -\S4method{show}{git_note}(object) -} -\arguments{ -\item{object}{The \linkS4class{git_note} \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of note -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create note -note_create(commits(repo)[[1]], "My note") -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_reference-method.Rd r-cran-git2r-0.22.1/man/show-git_reference-method.Rd --- r-cran-git2r-0.21.0/man/show-git_reference-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_reference-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reference.r -\docType{methods} -\name{show,git_reference-method} -\alias{show,git_reference-method} -\alias{show,git_reference-methods} -\title{Brief summary of reference} -\usage{ -\S4method{show}{git_reference}(object) -} -\arguments{ -\item{object}{The reference \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of reference -} -\examples{ -\dontrun{ -## Create and initialize a repository in a temporary directory -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add and commit -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Brief summary of reference -references(repo)[[1]] -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_reflog_entry-method.Rd r-cran-git2r-0.22.1/man/show-git_reflog_entry-method.Rd --- r-cran-git2r-0.21.0/man/show-git_reflog_entry-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_reflog_entry-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reflog.r -\docType{methods} -\name{show,git_reflog_entry-method} -\alias{show,git_reflog_entry-method} -\alias{show,git_reflog_entry-methods} -\title{Brief summary of a reflog entry} -\usage{ -\S4method{show}{git_reflog_entry}(object) -} -\arguments{ -\item{object}{The reflog entry \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of a reflog entry -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## View repository HEAD reflog -reflog(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_repository-method.Rd r-cran-git2r-0.22.1/man/show-git_repository-method.Rd --- r-cran-git2r-0.21.0/man/show-git_repository-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_repository-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{show,git_repository-method} -\alias{show,git_repository-method} -\alias{show,git_repository-methods} -\title{Brief summary of repository} -\usage{ -\S4method{show}{git_repository}(object) -} -\arguments{ -\item{object}{The repository \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of repository -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) -config(repo, user.name="Alice", user.email="alice@example.org") - -## Brief summary of the repository -repo - -## Create and commit a file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Brief summary of the repository -repo -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_signature-method.Rd r-cran-git2r-0.22.1/man/show-git_signature-method.Rd --- r-cran-git2r-0.21.0/man/show-git_signature-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_signature-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/signature.r -\docType{methods} -\name{show,git_signature-method} -\alias{show,git_signature-method} -\alias{show,git_signature-methods} -\title{Brief summary of signature} -\usage{ -\S4method{show}{git_signature}(object) -} -\arguments{ -\item{object}{The repository \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of signature -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Brief summary of default signature -default_signature(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_stash-method.Rd r-cran-git2r-0.22.1/man/show-git_stash-method.Rd --- r-cran-git2r-0.21.0/man/show-git_stash-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_stash-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stash.r -\docType{methods} -\name{show,git_stash-method} -\alias{show,git_stash-method} -\alias{show,git_stash-methods} -\title{Brief summary of a stash} -\usage{ -\S4method{show}{git_stash}(object) -} -\arguments{ -\item{object}{The stash \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of a stash -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -# Create a file, add and commit -writeLines("Hello world!", file.path(path, "test.txt")) -add(repo, 'test.txt') -commit(repo, "Commit message") - -# Change file -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) - -# Create stash in repository -stash(repo, "Stash message") - -# View brief summary of stash -stash_list(repo)[[1]] -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_tag-method.Rd r-cran-git2r-0.22.1/man/show-git_tag-method.Rd --- r-cran-git2r-0.21.0/man/show-git_tag-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_tag-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tag.r -\docType{methods} -\name{show,git_tag-method} -\alias{show,git_tag-method} -\alias{show,git_tag-methods} -\title{Brief summary of a tag} -\usage{ -\S4method{show}{git_tag}(object) -} -\arguments{ -\item{object}{The tag \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of a tag -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create tag -tag(repo, "Tagname", "Tag message") - -## View brief summary of tag -tags(repo)[[1]] -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_time-method.Rd r-cran-git2r-0.22.1/man/show-git_time-method.Rd --- r-cran-git2r-0.21.0/man/show-git_time-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_time-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/time.r -\docType{methods} -\name{show,git_time-method} -\alias{show,git_time-method} -\alias{show,git_time-methods} -\title{Brief summary of \code{git_time}} -\usage{ -\S4method{show}{git_time}(object) -} -\arguments{ -\item{object}{The time \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of \code{git_time} -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Brief summary of git_time from the default signature -default_signature(repo)@when -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/show-git_tree-method.Rd r-cran-git2r-0.22.1/man/show-git_tree-method.Rd --- r-cran-git2r-0.21.0/man/show-git_tree-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/show-git_tree-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{show,git_tree-method} -\alias{show,git_tree-method} -\alias{show,git_tree-methods} -\title{Brief summary of tree} -\usage{ -\S4method{show}{git_tree}(object) -} -\arguments{ -\item{object}{The tree \code{object}} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Brief summary of tree -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Brief summary of the tree in the repository -tree(commits(repo)[[1]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/ssh_key_needs_passphrase.Rd r-cran-git2r-0.22.1/man/ssh_key_needs_passphrase.Rd --- r-cran-git2r-0.21.0/man/ssh_key_needs_passphrase.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/ssh_key_needs_passphrase.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/credential.r -\name{ssh_key_needs_passphrase} -\alias{ssh_key_needs_passphrase} -\title{Check if private key is passphrase protected} -\usage{ -ssh_key_needs_passphrase(privatekey = "~/.ssh/id_rsa") -} -\arguments{ -\item{privatekey}{The path to the private key of the -credential. Default is \code{'~/.ssh/id_rsa'}} -} -\description{ -Check if private key is passphrase protected -} -\keyword{internal} diff -Nru r-cran-git2r-0.21.0/man/ssh_path.Rd r-cran-git2r-0.22.1/man/ssh_path.Rd --- r-cran-git2r-0.21.0/man/ssh_path.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/ssh_path.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/credential.R +\name{ssh_path} +\alias{ssh_path} +\title{Compose usual path to ssh keys} +\usage{ +ssh_path(file = "") +} +\arguments{ +\item{file}{basename of file for which path is requested} +} +\value{ +Full path to the file +} +\description{ +This function provides a consistent means across OS-types to access the +\code{.ssh} directory. +} +\details{ +On Windows-based systems, +\code{path.expand("~")} returns \code{"C:/Users/username/Documents"}, +whereas the usual path to the \code{.ssh} directory is +\code{"C:/Users/username"}. + +On other operating systems, \code{path.expand("~")} returns the usual path +to the \code{.ssh} directory. + +Calling \code{ssh_path()} with no arguments will return the usual path to +the \code{.ssh} directory. +} +\examples{ +ssh_path() +ssh_path("is_rsa.pub") +} diff -Nru r-cran-git2r-0.21.0/man/ssl_cert_locations.Rd r-cran-git2r-0.22.1/man/ssl_cert_locations.Rd --- r-cran-git2r-0.21.0/man/ssl_cert_locations.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/ssl_cert_locations.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/libgit2.r +% Please edit documentation in R/libgit2.R \name{ssl_cert_locations} \alias{ssl_cert_locations} \title{Set the SSL certificate-authority locations} diff -Nru r-cran-git2r-0.21.0/man/stash_apply.Rd r-cran-git2r-0.22.1/man/stash_apply.Rd --- r-cran-git2r-0.21.0/man/stash_apply.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash_apply.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,75 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stash.R +\name{stash_apply} +\alias{stash_apply} +\title{Apply stash} +\usage{ +stash_apply(object = ".", index = 1) +} +\arguments{ +\item{object}{path to a repository, or a \code{git_repository} +object, or the stash \code{object} to pop. Default is a +\code{path = '.'} to a reposiory.} + +\item{index}{The index to the stash to apply. Only used when +\code{object} is a path to a repository or a +\code{git_repository} object. Default is \code{index = 1}.} +} +\value{ +invisible NULL +} +\description{ +Apply a single stashed state from the stash list. +} +\details{ +If local changes in the working directory conflict with changes in +the stash then an error will be raised. In this case, the index +will always remain unmodified and all files in the working +directory will remain unmodified. However, if you are restoring +untracked files or ignored files and there is a conflict when +applying the modified files, then those files will remain in the +working directory. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +# Create a file, add and commit +writeLines("Hello world!", file.path(path, "test.txt")) +add(repo, 'test.txt') +commit(repo, "Commit message") + +# Change file +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo) + +# Change file +writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo) + +# View stashes +stash_list(repo) + +# Read file +readLines(file.path(path, "test.txt")) + +# Apply latest git_stash object in repository +stash_apply(stash_list(repo)[[1]]) + +# Read file +readLines(file.path(path, "test.txt")) + +# View stashes +stash_list(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/stash_drop-methods.Rd r-cran-git2r-0.22.1/man/stash_drop-methods.Rd --- r-cran-git2r-0.21.0/man/stash_drop-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash_drop-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stash.r -\docType{methods} -\name{stash_drop} -\alias{stash_drop} -\alias{stash_drop,git_repository-method} -\alias{stash_drop,git_stash-method} -\title{Drop stash} -\usage{ -stash_drop(object, ...) - -\S4method{stash_drop}{git_repository}(object, index) - -\S4method{stash_drop}{git_stash}(object) -} -\arguments{ -\item{object}{The stash \code{object} to drop or a zero-based -integer to the stash to drop. The last stash has index 0.} - -\item{...}{Additional arguments affecting the stash_drop} - -\item{index}{Zero based index to the stash to drop. Only used when -\code{object} is a \code{git_repository}.} -} -\value{ -invisible NULL -} -\description{ -Drop stash -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -# Create a file, add and commit -writeLines("Hello world!", file.path(path, "test.txt")) -add(repo, 'test.txt') -commit(repo, "Commit message") - -# Change file -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) - -# Create stash in repository -stash(repo) - -# Change file -writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) - -# Create stash in repository -stash(repo) - -# View stashes -stash_list(repo) - -# Drop git_stash object in repository -stash_drop(stash_list(repo)[[1]]) - -## Drop stash using an index to stash -stash_drop(repo, 0) - -# View stashes -stash_list(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/stash_drop.Rd r-cran-git2r-0.22.1/man/stash_drop.Rd --- r-cran-git2r-0.21.0/man/stash_drop.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash_drop.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,63 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stash.R +\name{stash_drop} +\alias{stash_drop} +\title{Drop stash} +\usage{ +stash_drop(object = ".", index = 1) +} +\arguments{ +\item{object}{path to a repository, or a \code{git_repository} +object, or the stash \code{object} to drop. Default is a +\code{path = '.'} to a reposiory.} + +\item{index}{The index to the stash to drop. Only used when +\code{object} is a path to a repository or a +\code{git_repository} object. Default is \code{index = 1}.} +} +\value{ +invisible NULL +} +\description{ +Drop stash +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +# Create a file, add and commit +writeLines("Hello world!", file.path(path, "test.txt")) +add(repo, 'test.txt') +commit(repo, "Commit message") + +# Change file +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo) + +# Change file +writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo) + +# View stashes +stash_list(repo) + +# Drop git_stash object in repository +stash_drop(stash_list(repo)[[1]]) + +## Drop stash using an index to stash +stash_drop(repo, 1) + +# View stashes +stash_list(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/stash_list-methods.Rd r-cran-git2r-0.22.1/man/stash_list-methods.Rd --- r-cran-git2r-0.21.0/man/stash_list-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash_list-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stash.r -\docType{methods} -\name{stash_list} -\alias{stash_list} -\alias{stash_list,missing-method} -\alias{stash_list,git_repository-method} -\title{List stashes in repository} -\usage{ -stash_list(repo) - -\S4method{stash_list}{missing}() - -\S4method{stash_list}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -list of stashes in repository -} -\description{ -List stashes in repository -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -# Create a file, add and commit -writeLines("Hello world!", file.path(path, "test-1.txt")) -add(repo, 'test-1.txt') -commit(repo, "Commit message") - -# Make one more commit -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) -add(repo, 'test-1.txt') -commit(repo, "Next commit message") - -# Create one more file -writeLines("Hello world!", file.path(path, "test-2.txt")) - -# Check that there are no stashes -stash_list(repo) - -# Stash -stash(repo) - -# Only untracked changes, therefore no stashes -stash_list(repo) - -# Stash and include untracked changes -stash(repo, "Stash message", untracked=TRUE) - -# View stash -stash_list(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/stash_list.Rd r-cran-git2r-0.22.1/man/stash_list.Rd --- r-cran-git2r-0.21.0/man/stash_list.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash_list.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,57 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stash.R +\name{stash_list} +\alias{stash_list} +\title{List stashes in repository} +\usage{ +stash_list(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +list of stashes in repository +} +\description{ +List stashes in repository +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +# Create a file, add and commit +writeLines("Hello world!", file.path(path, "test-1.txt")) +add(repo, 'test-1.txt') +commit(repo, "Commit message") + +# Make one more commit +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +add(repo, 'test-1.txt') +commit(repo, "Next commit message") + +# Create one more file +writeLines("Hello world!", file.path(path, "test-2.txt")) + +# Check that there are no stashes +stash_list(repo) + +# Stash +stash(repo) + +# Only untracked changes, therefore no stashes +stash_list(repo) + +# Stash and include untracked changes +stash(repo, "Stash message", untracked=TRUE) + +# View stash +stash_list(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/stash-methods.Rd r-cran-git2r-0.22.1/man/stash-methods.Rd --- r-cran-git2r-0.21.0/man/stash-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stash.r -\docType{methods} -\name{stash} -\alias{stash} -\alias{stash,git_repository-method} -\title{Stash} -\usage{ -stash(object, message = as.character(Sys.time()), index = FALSE, - untracked = FALSE, ignored = FALSE, stasher = default_signature(object)) - -\S4method{stash}{git_repository}(object, message = as.character(Sys.time()), - index = FALSE, untracked = FALSE, ignored = FALSE, - stasher = default_signature(object)) -} -\arguments{ -\item{object}{The repository \code{object}.} - -\item{message}{Optional description. Defaults to current time.} - -\item{index}{All changes already added to the index are left -intact in the working directory. Default is FALSE} - -\item{untracked}{All untracked files are also stashed and then -cleaned up from the working directory. Default is FALSE} - -\item{ignored}{All ignored files are also stashed and then cleaned -up from the working directory. Default is FALSE} - -\item{stasher}{Signature with stasher and time of stash} -} -\value{ -invisible S4 class git_stash if anything to stash else NULL -} -\description{ -Stash -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -# Create a file, add and commit -writeLines("Hello world!", file.path(path, "test.txt")) -add(repo, 'test.txt') -commit(repo, "Commit message") - -# Change file -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) - -# Check status of repository -status(repo) - -# Create stash in repository -stash(repo) - -# Check status of repository -status(repo) - -# View stash -stash_list(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/stash_pop.Rd r-cran-git2r-0.22.1/man/stash_pop.Rd --- r-cran-git2r-0.21.0/man/stash_pop.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash_pop.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,67 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stash.R +\name{stash_pop} +\alias{stash_pop} +\title{Pop stash} +\usage{ +stash_pop(object = ".", index = 1) +} +\arguments{ +\item{object}{path to a repository, or a \code{git_repository} +object, or the stash \code{object} to pop. Default is a +\code{path = '.'} to a reposiory.} + +\item{index}{The index to the stash to pop. Only used when +\code{object} is a path to a repository or a +\code{git_repository} object. Default is \code{index = 1}.} +} +\value{ +invisible NULL +} +\description{ +Apply a single stashed state from the stash list and remove it +from the list if successful. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +# Create a file, add and commit +writeLines("Hello world!", file.path(path, "test.txt")) +add(repo, 'test.txt') +commit(repo, "Commit message") + +# Change file +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo) + +# Change file +writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo) + +# View stashes +stash_list(repo) + +# Read file +readLines(file.path(path, "test.txt")) + +# Pop latest git_stash object in repository +stash_pop(stash_list(repo)[[1]]) + +# Read file +readLines(file.path(path, "test.txt")) + +# View stashes +stash_list(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/stash.Rd r-cran-git2r-0.22.1/man/stash.Rd --- r-cran-git2r-0.21.0/man/stash.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/stash.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stash.R +\name{stash} +\alias{stash} +\title{Stash} +\usage{ +stash(repo = ".", message = as.character(Sys.time()), index = FALSE, + untracked = FALSE, ignored = FALSE, stasher = NULL) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{message}{Optional description. Defaults to current time.} + +\item{index}{All changes already added to the index are left +intact in the working directory. Default is FALSE} + +\item{untracked}{All untracked files are also stashed and then +cleaned up from the working directory. Default is FALSE} + +\item{ignored}{All ignored files are also stashed and then cleaned +up from the working directory. Default is FALSE} + +\item{stasher}{Signature with stasher and time of stash} +} +\value{ +invisible \code{git_stash} object if anything to stash + else NULL +} +\description{ +Stash +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +# Create a file, add and commit +writeLines("Hello world!", file.path(path, "test.txt")) +add(repo, 'test.txt') +commit(repo, "Commit message") + +# Change file +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) + +# Check status of repository +status(repo) + +# Create stash in repository +stash(repo) + +# Check status of repository +status(repo) + +# View stash +stash_list(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/status-methods.Rd r-cran-git2r-0.22.1/man/status-methods.Rd --- r-cran-git2r-0.21.0/man/status-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/status-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/status.r -\docType{methods} -\name{status} -\alias{status} -\alias{status,missing-method} -\alias{status,git_repository-method} -\title{Status} -\usage{ -status(repo, staged = TRUE, unstaged = TRUE, untracked = TRUE, - ignored = FALSE, all_untracked = FALSE, ...) - -\S4method{status}{missing}(repo, staged = TRUE, unstaged = TRUE, - untracked = TRUE, ignored = FALSE, all_untracked = FALSE, ...) - -\S4method{status}{git_repository}(repo, staged = TRUE, unstaged = TRUE, - untracked = TRUE, ignored = FALSE, all_untracked = FALSE, ...) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}} to get status from. If the -\code{repo} argument is missing, the repository is searched -for with \code{\link{discover_repository}} in the current -working directory.} - -\item{staged}{Include staged files. Default TRUE.} - -\item{unstaged}{Include unstaged files. Default TRUE.} - -\item{untracked}{Include untracked files and directories. Default -TRUE.} - -\item{ignored}{Include ignored files. Default FALSE.} - -\item{all_untracked}{Shows individual files in untracked -directories if \code{untracked} is \code{TRUE}.} - -\item{...}{Additional arguments to status.} -} -\value{ -S3 class \code{git_status} with repository status -} -\description{ -Display state of the repository working directory and the staging -area. -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file -writeLines("Hello world!", file.path(path, "test.txt")) - -## Check status; untracked file -status(repo) - -## Add file -add(repo, "test.txt") - -## Check status; staged file -status(repo) - -## Commit -commit(repo, "First commit message") - -## Check status; clean -status(repo) - -## Change the file -writeLines(c("Hello again!", "Here is a second line", "And a third"), - file.path(path, "test.txt")) - -## Check status; unstaged file -status(repo) - -## Add file and commit -add(repo, "test.txt") -commit(repo, "Second commit message") - -## Check status; clean -status(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/status.Rd r-cran-git2r-0.22.1/man/status.Rd --- r-cran-git2r-0.21.0/man/status.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/status.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,75 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/status.R +\name{status} +\alias{status} +\title{Status} +\usage{ +status(repo = ".", staged = TRUE, unstaged = TRUE, untracked = TRUE, + ignored = FALSE, all_untracked = FALSE) +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} + +\item{staged}{Include staged files. Default TRUE.} + +\item{unstaged}{Include unstaged files. Default TRUE.} + +\item{untracked}{Include untracked files and directories. Default +TRUE.} + +\item{ignored}{Include ignored files. Default FALSE.} + +\item{all_untracked}{Shows individual files in untracked +directories if \code{untracked} is \code{TRUE}.} +} +\value{ +\code{git_status} with repository status +} +\description{ +Display state of the repository working directory and the staging +area. +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file +writeLines("Hello world!", file.path(path, "test.txt")) + +## Check status; untracked file +status(repo) + +## Add file +add(repo, "test.txt") + +## Check status; staged file +status(repo) + +## Commit +commit(repo, "First commit message") + +## Check status; clean +status(repo) + +## Change the file +writeLines(c("Hello again!", "Here is a second line", "And a third"), + file.path(path, "test.txt")) + +## Check status; unstaged file +status(repo) + +## Add file and commit +add(repo, "test.txt") +commit(repo, "Second commit message") + +## Check status; clean +status(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/sub-.git_tree.Rd r-cran-git2r-0.22.1/man/sub-.git_tree.Rd --- r-cran-git2r-0.21.0/man/sub-.git_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/sub-.git_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,59 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{[.git_tree} +\alias{[.git_tree} +\title{Extract object from tree} +\usage{ +\method{[}{git_tree}(x, i) +} +\arguments{ +\item{x}{The tree \code{object}} + +\item{i}{The index (integer or logical) of the tree object to +extract. If negative values, all elements except those indicated +are selected. A character vector to match against the names of +objects to extract.} +} +\value{ +Git object +} +\description{ +Lookup a tree entry by its position in the tree +} +\examples{ +\dontrun{ +##' Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +dir.create(file.path(path, "subfolder")) +repo <- init(path) + +##' Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +##' Create three files and commit +writeLines("First file", file.path(path, "example-1.txt")) +writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +writeLines("Third file", file.path(path, "example-3.txt")) +add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +new_commit <- commit(repo, "Commit message") + +##' Pick a tree in the repository +tree_object <- tree(new_commit) + +##' Display tree +tree_object + +##' Select item by name +tree_object["example-1.txt"] + +##' Select first item in tree +tree_object[1] + +##' Select first three items in tree +tree_object[1:3] + +##' Select all blobs in tree +tree_object[vapply(as(tree_object, 'list'), is_blob, logical(1))] +} +} diff -Nru r-cran-git2r-0.21.0/man/summary-git_blob-method.Rd r-cran-git2r-0.22.1/man/summary-git_blob-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_blob-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_blob-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/blob.r -\docType{methods} -\name{summary,git_blob-method} -\alias{summary,git_blob-method} -\title{Summary of blob} -\usage{ -\S4method{summary}{git_blob}(object, ...) -} -\arguments{ -\item{object}{The blob \code{object}} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Summary of blob -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit_1 <- commit(repo, "First commit message") -blob_1 <- tree(commit_1)["example.txt"] - -## Get summary of the blob -summary(blob_1) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary-git_commit-method.Rd r-cran-git2r-0.22.1/man/summary-git_commit-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_commit-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_commit-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/commit.r -\docType{methods} -\name{summary,git_commit-method} -\alias{summary,git_commit-method} -\alias{summary,git_commit-methods} -\title{Summary of commit} -\usage{ -\S4method{summary}{git_commit}(object, ...) -} -\arguments{ -\item{object}{The commit \code{object}} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Summary of commit -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Write to a file and commit -writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", - file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Summary of commit in repository -summary(commits(repo)[[1]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary-git_diff-method.Rd r-cran-git2r-0.22.1/man/summary-git_diff-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_diff-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_diff-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/diff.r -\docType{methods} -\name{summary,git_diff-method} -\alias{summary,git_diff-method} -\alias{summary,git_diff-methods} -\title{Show the summary of a diff} -\usage{ -\S4method{summary}{git_diff}(object, ...) -} -\arguments{ -\item{object}{The diff \code{object}.} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Show the summary of a diff -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file, add, commit -writeLines("Hello world!", file.path(path, "test.txt")) -add(repo, "test.txt") -commit(repo, "Commit message") - -## Change the file -writeLines(c("Hello again!", "Here is a second line", "And a third"), - file.path(path, "test.txt")) - -## diff between index and workdir -diff_1 <- diff(repo) -summary(diff_1) - -## Diff between index and HEAD is empty -diff_2 <- diff(repo, index=TRUE) -summary(diff_2) - -## Diff between tree and working dir, same as diff_1 -diff_3 <- diff(tree(commits(repo)[[1]])) -summary(diff_3) - -## Add changes, diff between index and HEAD is the same as diff_1 -add(repo, "test.txt") -diff_4 <- diff(repo, index=TRUE) -summary(diff_4) - -## Diff between tree and index -diff_5 <- diff(tree(commits(repo)[[1]]), index=TRUE) -summary(diff_5) - -## Diff between two trees -commit(repo, "Second commit") -tree_1 <- tree(commits(repo)[[2]]) -tree_2 <- tree(commits(repo)[[1]]) -diff_6 <- diff(tree_1, tree_2) -summary(diff_6) - -## Binary files -set.seed(42) -writeBin(as.raw((sample(0:255, 1000, replace=TRUE))), - con=file.path(path, "test.bin")) -add(repo, "test.bin") -diff_7 <- diff(repo, index=TRUE) -summary(diff_7) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary-git_repository-method.Rd r-cran-git2r-0.22.1/man/summary-git_repository-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_repository-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_repository-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{summary,git_repository-method} -\alias{summary,git_repository-method} -\alias{summary,git_repository-methods} -\title{Summary of repository} -\usage{ -\S4method{summary}{git_repository}(object, ...) -} -\arguments{ -\item{object}{The repository \code{object}} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Summary of repository -} -\examples{ -\dontrun{ -## Initialize a repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Config user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create a file -writeLines("Hello world!", file.path(path, "test.txt")) -summary(repo) - -## Add file -add(repo, "test.txt") -summary(repo) - -## Commit -commit(repo, "First commit message") -summary(repo) - -## Change the file -writeLines(c("Hello again!", "Here is a second line", "And a third"), - file.path(path, "test.txt")) -summary(repo) - -## Add file and commit -add(repo, "test.txt") -commit(repo, "Second commit message") -summary(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary.git_repository.Rd r-cran-git2r-0.22.1/man/summary.git_repository.Rd --- r-cran-git2r-0.21.0/man/summary.git_repository.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary.git_repository.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,52 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{summary.git_repository} +\alias{summary.git_repository} +\title{Summary of repository} +\usage{ +\method{summary}{git_repository}(object, ...) +} +\arguments{ +\item{object}{The repository \code{object}} + +\item{...}{Additional arguments affecting the summary produced.} +} +\value{ +None (invisible 'NULL'). +} +\description{ +Summary of repository +} +\examples{ +\dontrun{ +## Initialize a repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Config user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Create a file +writeLines("Hello world!", file.path(path, "test.txt")) +summary(repo) + +## Add file +add(repo, "test.txt") +summary(repo) + +## Commit +commit(repo, "First commit message") +summary(repo) + +## Change the file +writeLines(c("Hello again!", "Here is a second line", "And a third"), + file.path(path, "test.txt")) +summary(repo) + +## Add file and commit +add(repo, "test.txt") +commit(repo, "Second commit message") +summary(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/summary-git_stash-method.Rd r-cran-git2r-0.22.1/man/summary-git_stash-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_stash-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_stash-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stash.r -\docType{methods} -\name{summary,git_stash-method} -\alias{summary,git_stash-method} -\alias{summary,git_stash-methods} -\title{Summary of a stash} -\usage{ -\S4method{summary}{git_stash}(object, ...) -} -\arguments{ -\item{object}{The stash \code{object}} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Summary of a stash -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -# Configure a user -config(repo, user.name="Alice", user.email="alice@example.org") - -# Create a file, add and commit -writeLines("Hello world!", file.path(path, "test.txt")) -add(repo, 'test.txt') -commit(repo, "Commit message") - -# Change file -writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) - -# Create stash in repository -stash(repo, "Stash message") - -# View summary of stash -summary(stash_list(repo)[[1]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary.git_stash.Rd r-cran-git2r-0.22.1/man/summary.git_stash.Rd --- r-cran-git2r-0.21.0/man/summary.git_stash.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary.git_stash.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stash.R +\name{summary.git_stash} +\alias{summary.git_stash} +\title{Summary of a stash} +\usage{ +\method{summary}{git_stash}(object, ...) +} +\arguments{ +\item{object}{The stash \code{object}} + +\item{...}{Additional arguments affecting the summary produced.} +} +\value{ +None (invisible 'NULL'). +} +\description{ +Summary of a stash +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +# Configure a user +config(repo, user.name="Alice", user.email="alice@example.org") + +# Create a file, add and commit +writeLines("Hello world!", file.path(path, "test.txt")) +add(repo, 'test.txt') +commit(repo, "Commit message") + +# Change file +writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) + +# Create stash in repository +stash(repo, "Stash message") + +# View summary of stash +summary(stash_list(repo)[[1]]) +} +} diff -Nru r-cran-git2r-0.21.0/man/summary-git_tag-method.Rd r-cran-git2r-0.22.1/man/summary-git_tag-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_tag-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_tag-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tag.r -\docType{methods} -\name{summary,git_tag-method} -\alias{summary,git_tag-method} -\alias{summary,git_tag-methods} -\title{Summary of a tag} -\usage{ -\S4method{summary}{git_tag}(object, ...) -} -\arguments{ -\item{object}{The tag \code{object}} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Summary of a tag -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create tag -tag(repo, "Tagname", "Tag message") - -## Summary of tag -summary(tags(repo)[[1]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary-git_tree-method.Rd r-cran-git2r-0.22.1/man/summary-git_tree-method.Rd --- r-cran-git2r-0.21.0/man/summary-git_tree-method.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary-git_tree-method.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{summary,git_tree-method} -\alias{summary,git_tree-method} -\alias{summary,git_tree-methods} -\title{Summary of tree} -\usage{ -\S4method{summary}{git_tree}(object, ...) -} -\arguments{ -\item{object}{The tree \code{object}} - -\item{...}{Additional arguments affecting the summary produced.} -} -\value{ -None (invisible 'NULL'). -} -\description{ -Summary of tree -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -summary(tree(commits(repo)[[1]])) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/summary.git_tree.Rd r-cran-git2r-0.22.1/man/summary.git_tree.Rd --- r-cran-git2r-0.21.0/man/summary.git_tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/summary.git_tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{summary.git_tree} +\alias{summary.git_tree} +\title{Summary of tree} +\usage{ +\method{summary}{git_tree}(object, ...) +} +\arguments{ +\item{object}{The tree \code{object}} + +\item{...}{Additional arguments affecting the summary produced.} +} +\value{ +None (invisible 'NULL'). +} +\description{ +Summary of tree +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +summary(tree(last_commit(repo))) +} +} diff -Nru r-cran-git2r-0.21.0/man/tag_delete-methods.Rd r-cran-git2r-0.22.1/man/tag_delete-methods.Rd --- r-cran-git2r-0.21.0/man/tag_delete-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tag_delete-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tag.r -\docType{methods} -\name{tag_delete} -\alias{tag_delete} -\alias{tag_delete,git_repository-method} -\alias{tag_delete,character-method} -\alias{tag_delete,git_tag-method} -\title{Delete an existing tag reference} -\usage{ -tag_delete(object, ...) - -\S4method{tag_delete}{git_repository}(object, name) - -\S4method{tag_delete}{character}(object) - -\S4method{tag_delete}{git_tag}(object) -} -\arguments{ -\item{object}{Can be either a -(\code{\linkS4class{git_repository}}) object, a -\code{\linkS4class{git_tag}} object or the tag name. If the -\code{object} argument is the tag name, the repository is -searched for with \code{\link{discover_repository}} in the -current working directory.} - -\item{...}{Additional arguments} - -\item{name}{If the \code{object} argument is a -\code{git_repository}, the name of the tag to delete.} -} -\value{ -\code{invisible(NULL)} -} -\description{ -Delete an existing tag reference -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create two tags -tag(repo, "Tag1", "Tag message 1") -t2 <- tag(repo, "Tag2", "Tag message 2") - -## List the two tags in the repository -tags(repo) - -## Delete the two tags in the repository -tag_delete(repo, "Tag1") -tag_delete(t2) - -## Show the empty list with tags in the repository -tags(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/tag_delete.Rd r-cran-git2r-0.22.1/man/tag_delete.Rd --- r-cran-git2r-0.21.0/man/tag_delete.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tag_delete.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tag.R +\name{tag_delete} +\alias{tag_delete} +\title{Delete an existing tag reference} +\usage{ +tag_delete(object = ".", name = NULL) +} +\arguments{ +\item{object}{Can be either the path (default is ".") to a +repository, or a \code{git_repository} object, or a +\code{git_tag} object. or the tag name.} + +\item{name}{If the \code{object} argument is a path to a +repository or a \code{git_repository}, the name of the tag to +delete.} +} +\value{ +\code{invisible(NULL)} +} +\description{ +Delete an existing tag reference +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Commit a text file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Create two tags +tag(repo, "Tag1", "Tag message 1") +t2 <- tag(repo, "Tag2", "Tag message 2") + +## List the two tags in the repository +tags(repo) + +## Delete the two tags in the repository +tag_delete(repo, "Tag1") +tag_delete(t2) + +## Show the empty list with tags in the repository +tags(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/tag-methods.Rd r-cran-git2r-0.22.1/man/tag-methods.Rd --- r-cran-git2r-0.21.0/man/tag-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tag-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tag.r -\docType{methods} -\name{tag} -\alias{tag} -\alias{tag,git_repository-method} -\title{Create tag targeting HEAD commit in repository} -\usage{ -tag(object, name, message, session = FALSE, - tagger = default_signature(object)) - -\S4method{tag}{git_repository}(object, name, message, session = FALSE, - tagger = default_signature(object)) -} -\arguments{ -\item{object}{The repository \code{object}.} - -\item{name}{Name for the tag.} - -\item{message}{The tag message.} - -\item{session}{Add sessionInfo to tag message. Default is FALSE.} - -\item{tagger}{The tagger (author) of the tag} -} -\value{ -invisible(\code{git_tag}) object -} -\description{ -Create tag targeting HEAD commit in repository -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create tag -tag(repo, "Tagname", "Tag message") - -## List tags -tags(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/tag.Rd r-cran-git2r-0.22.1/man/tag.Rd --- r-cran-git2r-0.21.0/man/tag.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tag.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tag.R +\name{tag} +\alias{tag} +\title{Create tag targeting HEAD commit in repository} +\usage{ +tag(object = ".", name = NULL, message = NULL, session = FALSE, + tagger = NULL) +} +\arguments{ +\item{object}{The repository \code{object}.} + +\item{name}{Name for the tag.} + +\item{message}{The tag message.} + +\item{session}{Add sessionInfo to tag message. Default is FALSE.} + +\item{tagger}{The tagger (author) of the tag} +} +\value{ +invisible(\code{git_tag}) object +} +\description{ +Create tag targeting HEAD commit in repository +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Commit a text file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Create tag +tag(repo, "Tagname", "Tag message") + +## List tags +tags(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/tags-methods.Rd r-cran-git2r-0.22.1/man/tags-methods.Rd --- r-cran-git2r-0.21.0/man/tags-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tags-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tag.r -\docType{methods} -\name{tags} -\alias{tags} -\alias{tags,missing-method} -\alias{tags,git_repository-method} -\title{Tags} -\usage{ -tags(repo) - -\S4method{tags}{missing}() - -\S4method{tags}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -list of tags in repository -} -\description{ -Tags -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Commit a text file -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create tag -tag(repo, "Tagname", "Tag message") - -## List tags -tags(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/tags.Rd r-cran-git2r-0.22.1/man/tags.Rd --- r-cran-git2r-0.21.0/man/tags.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tags.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,40 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tag.R +\name{tags} +\alias{tags} +\title{Tags} +\usage{ +tags(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +list of tags in repository +} +\description{ +Tags +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a user +config(repo, user.name="Alice", user.email="alice@example.org") + +## Commit a text file +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Create tag +tag(repo, "Tagname", "Tag message") + +## List tags +tags(repo) +} +} diff -Nru r-cran-git2r-0.21.0/man/tree-index-methods.Rd r-cran-git2r-0.22.1/man/tree-index-methods.Rd --- r-cran-git2r-0.21.0/man/tree-index-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tree-index-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{[,git_tree,integer,missing-method} -\alias{[,git_tree,integer,missing-method} -\alias{[,git_tree,numeric,missing-method} -\alias{[,git_tree,logical,missing-method} -\alias{[,git_tree,character,missing-method} -\title{Extract object from tree} -\usage{ -\S4method{[}{git_tree,integer,missing}(x, i) - -\S4method{[}{git_tree,numeric,missing}(x, i) - -\S4method{[}{git_tree,logical,missing}(x, i) - -\S4method{[}{git_tree,character,missing}(x, i) -} -\arguments{ -\item{x}{The tree \code{object}} - -\item{i}{The index (integer or logical) of the tree object to -extract. If negative values, all elements except those indicated -are selected. A character vector to match against the names of -objects to extract.} -} -\value{ -Git object -} -\description{ -Lookup a tree entry by its position in the tree -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -dir.create(file.path(path, "subfolder")) -repo <- init(path) - -## Create a user -config(repo, user.name="Alice", user.email="alice@example.org") - -## Create three files and commit -writeLines("First file", file.path(path, "example-1.txt")) -writeLines("Second file", file.path(path, "subfolder/example-2.txt")) -writeLines("Third file", file.path(path, "example-3.txt")) -add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) -new_commit <- commit(repo, "Commit message") - -## Pick a tree in the repository -tree_object <- tree(new_commit) - -## Summarize tree -summary(tree_object) - -## Select item by name -tree_object["example-1.txt"] - -## Select first item in tree -tree_object[1] - -## Select first three items in tree -tree_object[1:3] - -## Select all blobs in tree -tree_object[vapply(as(tree_object, 'list'), is_blob, logical(1))] -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/tree-methods.Rd r-cran-git2r-0.22.1/man/tree-methods.Rd --- r-cran-git2r-0.21.0/man/tree-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tree-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tree.r -\docType{methods} -\name{tree} -\alias{tree} -\alias{tree,git_commit-method} -\alias{tree,git_stash-method} -\title{Tree} -\usage{ -tree(object) - -\S4method{tree}{git_commit}(object) - -\S4method{tree}{git_stash}(object) -} -\arguments{ -\item{object}{the \code{commit} or \code{stash} object} -} -\value{ -A S4 class git_tree object -} -\description{ -Get the tree pointed to by a commit or stash. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a first user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -tree(commits(repo)[[1]]) -summary(tree(commits(repo)[[1]])) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/tree.Rd r-cran-git2r-0.22.1/man/tree.Rd --- r-cran-git2r-0.21.0/man/tree.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/tree.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/tree.R +\name{tree} +\alias{tree} +\title{Tree} +\usage{ +tree(object = NULL) +} +\arguments{ +\item{object}{the \code{commit} or \code{stash} object} +} +\value{ +A S3 class git_tree object +} +\description{ +Get the tree pointed to by a commit or stash. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a first user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +tree(last_commit(repo)) +} +} diff -Nru r-cran-git2r-0.21.0/man/when-methods.Rd r-cran-git2r-0.22.1/man/when-methods.Rd --- r-cran-git2r-0.21.0/man/when-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/when-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/when.r -\docType{methods} -\name{when} -\alias{when} -\alias{when,git_commit-method} -\alias{when,git_signature-method} -\alias{when,git_stash-method} -\alias{when,git_tag-method} -\alias{when,git_time-method} -\title{When} -\usage{ -when(object) - -\S4method{when}{git_commit}(object) - -\S4method{when}{git_signature}(object) - -\S4method{when}{git_stash}(object) - -\S4method{when}{git_tag}(object) - -\S4method{when}{git_time}(object) -} -\arguments{ -\item{object}{the \code{object} to extract the time slot from.} -} -\value{ -A \code{character} vector of length one. -} -\description{ -Help method to extract the time as a character string from the S4 -classes \code{git_commit}, \code{git_signature}, \code{git_tag} -and \code{git_time}. -} -\examples{ -\dontrun{ -## Initialize a temporary repository -path <- tempfile(pattern="git2r-") -dir.create(path) -repo <- init(path) - -## Create a first user and commit a file -config(repo, user.name="Alice", user.email="alice@example.org") -writeLines("Hello world!", file.path(path, "example.txt")) -add(repo, "example.txt") -commit(repo, "First commit message") - -## Create tag -tag(repo, "Tagname", "Tag message") - -when(commits(repo)[[1]]) -when(tags(repo)[[1]]) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/when.Rd r-cran-git2r-0.22.1/man/when.Rd --- r-cran-git2r-0.21.0/man/when.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/when.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/when.R +\name{when} +\alias{when} +\title{When} +\usage{ +when(object) +} +\arguments{ +\item{object}{the \code{object} to extract the time slot from.} +} +\value{ +A \code{character} vector of length one. +} +\description{ +Help method to extract the time as a character string from a +git_commit, git_signature, git_tag and git_time object. +} +\examples{ +\dontrun{ +## Initialize a temporary repository +path <- tempfile(pattern="git2r-") +dir.create(path) +repo <- init(path) + +## Create a first user and commit a file +config(repo, user.name="Alice", user.email="alice@example.org") +writeLines("Hello world!", file.path(path, "example.txt")) +add(repo, "example.txt") +commit(repo, "First commit message") + +## Create tag +tag(repo, "Tagname", "Tag message") + +when(commits(repo)[[1]]) +when(tags(repo)[[1]]) +} +} diff -Nru r-cran-git2r-0.21.0/man/workdir-methods.Rd r-cran-git2r-0.22.1/man/workdir-methods.Rd --- r-cran-git2r-0.21.0/man/workdir-methods.Rd 2018-01-02 13:29:31.000000000 +0000 +++ r-cran-git2r-0.22.1/man/workdir-methods.Rd 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/repository.r -\docType{methods} -\name{workdir} -\alias{workdir} -\alias{workdir,missing-method} -\alias{workdir,git_repository-method} -\title{Workdir of repository} -\usage{ -workdir(repo) - -\S4method{workdir}{missing}() - -\S4method{workdir}{git_repository}(repo) -} -\arguments{ -\item{repo}{The repository \code{object} -\code{\linkS4class{git_repository}}. If the \code{repo} argument -is missing, the repository is searched for with -\code{\link{discover_repository}} in the current working -directory.} -} -\value{ -Character vector with the path of the workdir. If the -repository is bare, \code{NULL} will be returned. -} -\description{ -Workdir of repository -} -\examples{ -\dontrun{ -## Create a directory in tempdir -path <- tempfile(pattern="git2r-") -dir.create(path) - -## Initialize a repository -repo <- init(path) - -## Get the path of the workdir for repository -workdir(repo) -} -} -\keyword{methods} diff -Nru r-cran-git2r-0.21.0/man/workdir.Rd r-cran-git2r-0.22.1/man/workdir.Rd --- r-cran-git2r-0.21.0/man/workdir.Rd 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/man/workdir.Rd 2018-07-09 19:28:39.000000000 +0000 @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/repository.R +\name{workdir} +\alias{workdir} +\title{Workdir of repository} +\usage{ +workdir(repo = ".") +} +\arguments{ +\item{repo}{a path to a repository or a \code{git_repository} +object. Default is '.'} +} +\value{ +Character vector with the path of the workdir. If the +repository is bare, \code{NULL} will be returned. +} +\description{ +Workdir of repository +} +\examples{ +\dontrun{ +## Create a directory in tempdir +path <- tempfile(pattern="git2r-") +dir.create(path) + +## Initialize a repository +repo <- init(path) + +## Get the path of the workdir for repository +workdir(repo) +} +} diff -Nru r-cran-git2r-0.21.0/MD5 r-cran-git2r-0.22.1/MD5 --- r-cran-git2r-0.21.0/MD5 2018-01-04 16:50:12.000000000 +0000 +++ r-cran-git2r-0.22.1/MD5 2018-07-10 15:00:03.000000000 +0000 @@ -1,268 +1,231 @@ -ffc419b5f50e4204a3ec2ee19a50bd20 *DESCRIPTION -a2071b6aaf08f79885ce95099cb4e39b *NAMESPACE -796d5ce6f0a2db42fe34f2b8be24e2ea *NEWS -1fbc6e8d7d1c4a26ab2cbc5aaace2e50 *R/S4_classes.r -55d7fbdd2cd0fd97f79469dade24cd9e *R/blame.r -a3b6b85e54ee8906580960b5e06b925c *R/blob.r -889b323a36782fcbd25cdeb91731cd79 *R/branch.r -36423d5cca3f7cd5853dfdcd6468a0e4 *R/bundle_r_package.r -b0854884c33d0bc2012134f2e5e4cbd1 *R/checkout.r -df0b55489ace4046c99cd404e44a5d7c *R/commit.r -22787eb1cf784ef8bb2c814e20c2b103 *R/config.r -114591c4cffc8b1d2c52a5f182dae6c8 *R/contributions.r -94ce4cd80d90fc07a485b42079f782a0 *R/credential.r -eb1f3cd2c5d38ca1584ae604b3c36141 *R/diff.r -7f254ba6ec436a2a5be77ea7da2c8c37 *R/fetch.r -e38f66f4283102274809440a66deb660 *R/git2r.r -69f5acca242bbdccd7c0b39373154150 *R/index.r -83244e4f3bd55640af4cd049f47b2276 *R/libgit2.r -477b702f623b5ae7a132d495b157b48e *R/merge.r -d91b5ef8fa6f529bc839613504800ca1 *R/note.r -18189b2db73cf8e8e1c67e6df3db829e *R/odb.r -70a128a63f05e042bf5d827a8ef8aeff *R/plot.r -e5923351b87a7f61f63e7cc1527d1c3d *R/pull.r -7c491f612e5b385e71af3f036d433f1c *R/punch_card.r -8626372951ea8e03e91ff2d06100c96b *R/push.r -ed7bddb5f481397b3aa2b43af76667db *R/reference.r -1da5a19fd2839d924df3027d150ce743 *R/reflog.r -74f9ecf5c35095bc000a047fc2a10707 *R/refspec.r -fe0f08d5d48688bfdadb7dd0b0a44c7a *R/remote.r -d09c59e9ec2188c9572c3dd2a82c9347 *R/repository.r -ac3dbee7fe47bfef66ddec5292d9e9e6 *R/reset.r -07b860f1fd7750b4e4541584608e3034 *R/revparse.r -f34190e77cc3ff45eb19a053bb11ae2a *R/signature.r -cfff5f6fe679cbd46266c93dd9662c45 *R/stash.r -9ded799fc416286a2221de9b5e0811cb *R/status.r -d1dd10ea75c5763c7a4670e4fb171d5c *R/tag.r -9513cb353314f765ecf300afc42da7c3 *R/time.r -83541461814f6cbf1d75786fb228a1d4 *R/tree.r -2af153734deeed503d4ae3391fe71be2 *R/when.r -a284d16104b1daa50434f339a415037d *cleanup -8f095910507c1cff875ca9ebcfd558db *configure -2dcb0138b690a200040afe08ad3a18ae *configure.ac +e1e48346d99837ee98029d93756391c9 *DESCRIPTION +a704a2a0f7d03bb5bff77c1db6c2e15d *NAMESPACE +01fbe5021a455e5b087bfc1a87625a8d *NEWS +a051a3d150f55584c825790476494169 *R/blame.R +fb4e61c42693b6a80997fdff20e968fd *R/blob.R +39a67496623b5e3fb1617cf66673e5a1 *R/branch.R +03f7498c16073260234740b738019418 *R/bundle_r_package.R +6bee11dbbd47e65085a661ffa9dabac5 *R/checkout.R +5f437f4f684aaea98a21251cf9898ccc *R/commit.R +acf517a9028810eb0c9046bb0d7d77d1 *R/config.R +b163171b9e3f7f709d1a22ba0f2a78c6 *R/contributions.R +b90e902ceff356e788cb5217e8c34176 *R/credential.R +7fa5f95689ee3c9999f5cfbb1edac3cb *R/diff.R +0c80d92f82a88cacb3b64ee7c188ed3b *R/fetch.R +591b22a986719bf07323f85f6c98ddae *R/git2r.R +97cf922db354841d4e7720daa493ae3f *R/index.R +027eec93446c942d562c5b9dc278c3f8 *R/libgit2.R +0a87c4338eb4c309ca5d83e60a07aa63 *R/merge.R +229c799252d0a02afabb2b23cc8cbedf *R/note.R +42c767089b64b0a62cf8204301576ec4 *R/odb.R +6999bcb9fbbf80219a5e9182bd5dc764 *R/plot.R +b20c21e5ea6705beba0fd0dc9bd9cb1f *R/pull.R +181d5eeb327463e1dab327ed8c0ba71e *R/punch_card.R +93b1e08a34d1b7a601baaee7dda73337 *R/push.R +f5b8f32790861c8dfdcc6d6d37616cfc *R/reference.R +6d72aa77a0c18fd74ae4f461e0ab4160 *R/reflog.R +f46ff2a3373b60e272fb7825215ea26a *R/refspec.R +a2581ce31be01acad63b76fe458a1cbd *R/remote.R +c8be85e64482725ef2471a96c04a1450 *R/repository.R +efe97f02307f9f962acc447e0f83c8ac *R/reset.R +58e922eba86fd7faf1de5c56f278c059 *R/revparse.R +0997d062b3b5a445d65b4c8e7bd96901 *R/sha.R +13459417a7a640f49e4c3518baa57cbf *R/signature.R +449ffdee72aee4636b5077ae2d7e5e11 *R/stash.R +489366911aa58a1f6ebfc83725fa0697 *R/status.R +57259b2b90c4d99ed5b2fde8600290ae *R/tag.R +ada1727a90eca1ea80c0bd48148fd5d8 *R/time.R +7f8c3a3a9206b9d419f05f06bab10a8d *R/tree.R +3d9e04941b4da3dbe3004091a455ac15 *R/when.R +de70826e35ee5fafdfaf08dafbf9f162 *cleanup +1f50f1292a24d2b6fc4a961e7b93451c *configure +adf305db521779957ce654d5a893a3c7 *configure.ac 4ddf2ad84203347f690b3ec0527d3c9a *inst/AUTHORS a570c78338c55f6460bebfc37da47a7b *inst/CITATION ad7ba52b680bdbdd9c9f41bd34686586 *inst/COPYING fab51b51886c7f7e35b7c16bbaa143ee *inst/COPYRIGHTS -48b9f1ab8170395adba6a3bb5af26923 *man/add-methods.Rd -4b8b91b9dfa2731f44a59d785dec334f *man/add_session_info.Rd -85061577bbfcadc1d5343f14d7e9402d *man/ahead_behind-methods.Rd -f0ce7015645955163366526ba1bb06d2 *man/blame-methods.Rd -b2b523c5d4733cd041bb925df122996e *man/blob_create-methods.Rd -51e367e7e2033a7ab5741f36abce2584 *man/branch_create-methods.Rd -ea4b554c8ae8d32da62ca0be561e2d6f *man/branch_delete-methods.Rd -73b7bbba5d5676a5ece563a78fbcd49b *man/branch_get_upstream-methods.Rd -a29b0b0431621876d29fb81d015cc53b *man/branch_remote_name-methods.Rd -a67780f3ee9c1d36361543ff454c8ce0 *man/branch_remote_url-methods.Rd -cd9201bbefe9de054140eeb3a9b925bd *man/branch_rename-methods.Rd -c3d6196e06386060c8ee621f5e7628b6 *man/branch_set_upstream-methods.Rd -fff39ce2b0ad15730bf5034979236244 *man/branch_target-methods.Rd -d5e5f7006024c6e440871463ea5357d6 *man/branches-methods.Rd -afd74d4cd512f21ff199961c086ae46a *man/bundle_r_package-methods.Rd -a88e571e99020285e37d3a3f8eebcde3 *man/checkout-methods.Rd -d089ce832673d48583bd11ed36bab76c *man/clone-methods.Rd -8c9b69a09357853f0da87ec4104c06f6 *man/coerce-git_commit-method.Rd -015653da9a52776173a584cb197de591 *man/coerce-git_repository-method.Rd -e34b99ba485596992966f773b13c3df4 *man/coerce-git_tree-data.frame-method.Rd -a3733f82661691c5b5200ffbc4a06bec *man/coerce-git_tree-list-method.Rd -9e876aa66e7a79edaf321ca5df4a13fc *man/commit-methods.Rd -a9266d80aeca69061bc6ce99f9fedc87 *man/commits-methods.Rd -625ce4a68c957dec889c87b1b90f6894 *man/config.Rd -1eb13de2efe93ef38f03789268f74935 *man/content-methods.Rd -ae80e7b4fdae01c67bd80acf155f4678 *man/contributions-methods.Rd -69d72f1fa7ffc44834904425275f09fd *man/cred_env-class.Rd -a3c9e88f9f00be88aa407b68ba297a16 *man/cred_env-methods.Rd -3fc6963640c560b3b37c6fd51d41f5ec *man/cred_ssh_key-class.Rd -3fe0dbb0a6c9f218c5c8e359248d2e98 *man/cred_ssh_key.Rd -86cfe34798204598789f517997beb886 *man/cred_token-class.Rd -e67d029ff1d9e6be292842694928abdc *man/cred_token.Rd -d46c813a1fc78a4172dec8ebb2fd14af *man/cred_user_pass-class.Rd -8ad03640451838fe65aed68474940b91 *man/cred_user_pass-methods.Rd -d24f9914237790423d1c4a2dfa3f18c3 *man/default_signature-methods.Rd -e802e0c00fec03833d3ee00d76669f27 *man/descendant_of-methods.Rd -0d437891322bd7bc55d3d94c72bb8690 *man/diff-methods.Rd -22ebf7456a3dcb5c3945ccff16ff4463 *man/discover_repository-methods.Rd -649149504a2e5e580d7d41453e05348e *man/fetch-methods.Rd -1c2e446acd6631f4fed92fa3c5ca9017 *man/fetch_heads-methods.Rd -1c7e60a8e5c2453e20b842c3eb6983c5 *man/get_refspec.Rd -5e75e74d68fa50f08a7a7c38549dadef *man/git2r.Rd -8093916f785b66eceaa8308e629bcfbe *man/git_blame-class.Rd -bb61d592a044f0fe852538338874fa90 *man/git_blame_hunk-class.Rd -b76ec17b665507dd221dfac6233a979b *man/git_blob-class.Rd -c593c637ac7e305448446801c8f8bf1b *man/git_branch-class.Rd -a1c545f968b4ffae99dd4eb3a3288ac4 *man/git_commit-class.Rd -948af6c54971d1841ec4630cbb4638cd *man/git_diff-class.Rd -402638b24634f0cafc404dd79d90aeb5 *man/git_diff_file-class.Rd -b64e881de76543db80587eba2ab701f9 *man/git_diff_hunk-class.Rd -7821d16bbae3affb9585aa04fcdeb126 *man/git_diff_line-class.Rd -e1513bbf2edec98aab97785e1c51cc8b *man/git_fetch_head.Rd -694a02e0b8e795c60a1e171fccffed24 *man/git_merge_result.Rd -886157d27931b3c7916ac14af3674818 *man/git_note-class.Rd -843279ef405e01f7ddb6f64e58c25fe7 *man/git_reference-class.Rd -fdd9e537851e73a319c0e053c0391b85 *man/git_reflog_entry-class.Rd -3f8c5e50b78b480f0764abab55d0d70d *man/git_repository-class.Rd -59fc15c7e6d879c60c594c8bec29e30f *man/git_signature-class.Rd -5ea40f0bfd3135fb05b32ca3b268976a *man/git_stash-class.Rd -bdb9c255bb2c0d833c44f2b12198f2c4 *man/git_tag-class.Rd -9ec76a844ed6d1fd5c3c24449abd11f2 *man/git_time-class.Rd -e269c1ade22ab0c2285763dd272e7ba3 *man/git_transfer_progress-class.Rd -107707ca12052d1b01c1c1677af65630 *man/git_tree-class.Rd -ee317973d836d5597b48a48f5ea917a1 *man/hash-methods.Rd -90e52e28d5068d1ec198b37425c7d0c3 *man/hashfile-methods.Rd -b024a5747b5bd94a8151d21c00a98c81 *man/head-methods.Rd -57caeac25baa897ff42aba951a8d3c18 *man/in_repository-methods.Rd -7576cbc00c7f8c3f8c1806db300b9c15 *man/index_remove_bypath-methods.Rd -32f2797d7e408444093b77e55e39315e *man/init-methods.Rd -93739069558b4c82b07ab3e52a0db1cc *man/is_bare-methods.Rd -015350927966a80de628c5142a979840 *man/is_binary-methods.Rd -cae8bb3d3fc36521ee805946fbb804b5 *man/is_blob.Rd -36d0683040d2c20f1c73bd2aede78946 *man/is_branch.Rd -747216b1323dda18490416663a8021df *man/is_commit.Rd -d8f12577c6536e044d26f4404467ea2c *man/is_detached-methods.Rd -59a346c000e1ea9386f407e8e4b360b5 *man/is_empty-methods.Rd -39f866d418a76b21b20a8a79a5b9f8a0 *man/is_head-methods.Rd -35d6abbd3c61c05025ca8e8049a37205 *man/is_local-methods.Rd -ea8e232150ef0a65582890990dd46897 *man/is_merge-methods.Rd -d309f58cc39b87d830d1f81c4ba4fc63 *man/is_shallow-methods.Rd -db5719de4c85e549ef5e8c6ad67aa070 *man/length-git_blob-method.Rd -075c61f2b0ceaa6860df9a4851cafa9a *man/length-git_diff-method.Rd -afc3db965338b6dccce4d4ab92c4e5df *man/length-git_tree-method.Rd -aa6077a756ba1fa6e3aad574dd6908f3 *man/libgit2_features.Rd -068aa447a8d51a343a022c1539555814 *man/libgit2_sha.Rd -447b1ebe6ff4e4baf6950dd2d0df7b8d *man/libgit2_version.Rd -4869408b61d3b2484a4341745d41e779 *man/lookup-methods.Rd -c2376b872428e3acd6463c5adde91f02 *man/lookup_repository.Rd -0f6b0001d3cc86b78bff2d3679380d15 *man/merge-methods.Rd -da01f90451a105bcc1a46031ac8eb037 *man/merge_base-methods.Rd -1833b70fc6972e8c39feb705c66e4cd4 *man/merge_branch.Rd -437d79c57369497a24788448888b2793 *man/merge_named_branch.Rd -38459363738e544d33da5efa4b304b39 *man/note_create-methods.Rd -f7c7f7f573e4329b2280b99e98138136 *man/note_default_ref-methods.Rd -dfb6b1cebe44892898f66082ac352dda *man/note_remove-methods.Rd -2475aab56e17b5ae31f1b12dbedaaaa8 *man/notes-methods.Rd -af59289920a740d85899ddd846f0ab8d *man/odb_blobs-methods.Rd -78edb5fef2a9cc436665970697e7f500 *man/odb_objects-methods.Rd -c23a239a9e03a5fe3d289740ca58bdb2 *man/parents-methods.Rd -db6b5adf83597c833e4676640f842a99 *man/plot-methods.Rd -18ed11a60775f61f388269f9aecd8460 *man/pull-methods.Rd -8e2f2ee639f4ba0892aa2549541411c7 *man/punch_card-methods.Rd -0289bcad104bf5b3c13bb88f46fbc7f1 *man/push-methods.Rd -d9c094a24ae7f59787ec257ce42cc4d2 *man/references-methods.Rd -511e454ed7e4d18d8bbd7ea5ae9f11ec *man/reflog-methods.Rd -ea8a3bd94a9374a5be4350d37a71c456 *man/remote_add-methods.Rd -2fbfbf16dcc8c7f7e2979cab229dc195 *man/remote_ls-methods.Rd -88089c88265239f9984431fd0b43e870 *man/remote_remove-methods.Rd -0000445aa40c34f0db752bb419aef1d6 *man/remote_rename-methods.Rd -498d388a50bb9be823e7e4b14d84d33b *man/remote_set_url-methods.Rd -c0d5ed9e502755b669b6f57859b9cfaa *man/remote_url-methods.Rd -42b6dee1aa8087a0eae79686dc2571ea *man/remotes-methods.Rd -f9dfb88134a523b3ef7785ad72aeca57 *man/repository-methods.Rd -f56f4bfda679e2a5e9000a6b2a263774 *man/reset-methods.Rd -419ae50eacd4114972adca1d72e53687 *man/revparse_single-methods.Rd -74d6569a5c249108d79947e9c91c63f5 *man/rm_file-methods.Rd -e19282bb0604fc1e5df2e78512bfe534 *man/show-git_blob-method.Rd -02394850876ab12f929ab9e0b5a208e6 *man/show-git_branch-method.Rd -0506be798ad928a44ef705fddae68822 *man/show-git_commit-method.Rd -197e68cec9ee378668a7edf9d1870387 *man/show-git_diff-method.Rd -828d01655b00db3401dac959241a0f43 *man/show-git_merge_result-method.Rd -a17de840bcb37e2f1a5a5d6c04bfc795 *man/show-git_note-method.Rd -e2dffe39ef550896ef00cfd18dffe19d *man/show-git_reference-method.Rd -999e53a32abe6e641f100a389093eb1b *man/show-git_reflog_entry-method.Rd -70121f8ef4b55cd602e344f451143e15 *man/show-git_repository-method.Rd -84758b824d4e35071868b0440f728cb1 *man/show-git_signature-method.Rd -f92b4b65c961cae06171808abcf55a02 *man/show-git_stash-method.Rd -599617384cdbc62018c0d1c431f9c66d *man/show-git_tag-method.Rd -5cc835c8216e3eb56d08e76718c2b062 *man/show-git_time-method.Rd -a0272b0988b689c322284dac309056fd *man/show-git_tree-method.Rd -dba5317a1c9f97580b61a424e3305b8f *man/ssh_key_needs_passphrase.Rd -0538d10b32d39766e72e163d38a32177 *man/ssl_cert_locations.Rd -8d2cfc42416309a32f80aba2aef5ab2b *man/stash-methods.Rd -11840f538e5540f0ad95680f3bad0b22 *man/stash_drop-methods.Rd -bc650f1880de2e4b1111c7551f360879 *man/stash_list-methods.Rd -b0cce393bb6ddb26146772cab8d4c99c *man/status-methods.Rd -6dc788844f712b2ffdda12383f208f1f *man/summary-git_blob-method.Rd -169d942562f29c0c31bc9d117d5284e2 *man/summary-git_commit-method.Rd -f88a9d85267147d437b581a04b0d3f33 *man/summary-git_diff-method.Rd -27057577e031be53ba408da75c12f340 *man/summary-git_repository-method.Rd -ba05037a7e4e4e17146239168f39962b *man/summary-git_stash-method.Rd -fb8d492486f7c562d373139acd19bcc2 *man/summary-git_tag-method.Rd -8a36a7ab43f2781f398154cb4c269167 *man/summary-git_tree-method.Rd -cd2c60e4ddb61fd503f7e34b8d2ff98e *man/tag-methods.Rd -4e2d00343808f71ad7858157540a07ad *man/tag_delete-methods.Rd -beefd84cf07b3b62fe9a92dc6197860d *man/tags-methods.Rd -2b3cb4f2f5271886310028458fbdfc86 *man/tree-index-methods.Rd -c92fda7464efcdfec3997b91fe122389 *man/tree-methods.Rd -284abc5bdfb9d285f95567ac3aedfef9 *man/when-methods.Rd -248a335c7c4367a71be97df634ef10d6 *man/workdir-methods.Rd -cd86a8570c30d6c33730e07b2828c3ed *src/Makevars.in -fb1c28b23724c7f88b6dde787454d5ec *src/Makevars.win -0eb3369a6bb566f801d28088c7355fd4 *src/git2r.c -f7dd5ec5697332d6530411566b3360e9 *src/git2r_arg.c -a6b728c0397338f7c7edaead1c4ed3ea *src/git2r_arg.h -8316c134a0bfd98ca751ffcd5d35b091 *src/git2r_blame.c +b8c73ff31135791a2378010364cb221e *man/add.Rd +909a0a941b8e800cacbdbd883b3a856e *man/ahead_behind.Rd +dbdb6b6b3abd84eb8f67f6769e30c78c *man/as.data.frame.git_repository.Rd +89c38040256e3a476bc5d677f253c600 *man/as.data.frame.git_tree.Rd +59f70896bf9f8332424d004ddee290d3 *man/as.list.git_tree.Rd +56d9ac1222da7ebf56e58f3e7d736da9 *man/blame.Rd +3599c4fb3b5e5b0f369ef382ac703651 *man/blob_create.Rd +0cc3365e734403a29c7ee613d7711377 *man/branch_create.Rd +73e5bb6a98c6f610e2f85140803a3540 *man/branch_delete.Rd +86eaab078e99e156e403eb4054c81dcf *man/branch_get_upstream.Rd +76251b749ce7ae1b0b3d3712c61c0bd3 *man/branch_remote_name.Rd +deed21630d3a14c800c30b229ffd20e2 *man/branch_remote_url.Rd +fe4659cef167db3f6e69a2795937e703 *man/branch_rename.Rd +a4207e8dbeadb30cc9fae166eddf1015 *man/branch_set_upstream.Rd +67b866dc79c46c4cdb883292b2149944 *man/branch_target.Rd +e2578bc8454b895eb2a33b476b6641be *man/branches.Rd +ed8ff151e968286185df78d45cc83bfe *man/bundle_r_package.Rd +5a631c099c783363b16637e6bd0ecd48 *man/checkout.Rd +eb99cc04da7392482d93cdfee321607c *man/clone.Rd +42b94c1599f1f86127f31075798126b2 *man/commit.Rd +9d59da535680148b326025f9a4ff84a8 *man/commits.Rd +377b3ee874bfd019408521bc92826942 *man/config.Rd +bf8512eb96763ecaae129070090e27f0 *man/content.Rd +303462e1d937bb40e81e95c6fb4c78c8 *man/contributions.Rd +da779e1e7679fd98d69c087dd7e78b40 *man/cred_env.Rd +d56703e36e2d2d9cc8be11ccb2b43e42 *man/cred_ssh_key.Rd +e8722c92519caba1c492e39f14e82c6a *man/cred_token.Rd +30954c3d9d1b8fdbfc63651ed3baf338 *man/cred_user_pass.Rd +a2fa5d8d7f71c666dfbf87d12cf1c545 *man/default_signature.Rd +f48ca0cd637c124e4521c5c54635fc20 *man/descendant_of.Rd +c0eb2eb6f45498cd6d48d5872227da44 *man/diff-methods.Rd +1b7bc0ee484b083ac8bba68fe410cbe9 *man/discover_repository.Rd +b28f587912a4b0050aeb9c0cfa1e077d *man/fetch.Rd +c2200966133c5208fa30a171a6447edc *man/fetch_heads.Rd +04a6177abab83d653fe00b8d2435e939 *man/git2r.Rd +d7893bf1f3346d206e352944b0775109 *man/git_config_files.Rd +75c7cf71a0d88eaf129e99e1ec774629 *man/hash.Rd +2ec1d3f8d1a1563b592519eddffd9bad *man/hashfile.Rd +5516aeed4e83475ed0294e43ade94d2f *man/head.git_repository.Rd +993dacbbfd3e4f671c86b70e3af2eac6 *man/in_repository.Rd +ba5259c7e99beb9c502fb57e8a9e7e83 *man/index_remove_bypath.Rd +0d5233096ef030b09028f3809951105e *man/init.Rd +cd85ef7784fad166d026729b621a25aa *man/is_bare.Rd +7d7dce2117fc444d13d5779bbece0d5c *man/is_binary.Rd +28deec5fe1c0e29f802a3df36affa745 *man/is_blob.Rd +057ca90455eff882e64c997803e4e1b8 *man/is_branch.Rd +d7a459260e9a25e398a82d624a591005 *man/is_commit.Rd +530a710dede0b19495b5dd752be1c95b *man/is_detached.Rd +8b1ef17f66b54d064e87ab16dbe1cda7 *man/is_empty.Rd +1c4544bce4222ed7ddcdff9fab6a5f9e *man/is_head.Rd +3e4159c076e854842568222008d9804e *man/is_local.Rd +74ecad533ad22904ee5682de78f98a35 *man/is_merge.Rd +a9e26af67497f697abd07681a4087425 *man/is_shallow.Rd +2116afea9f08a0ae7a698760f1ec94e8 *man/is_tree.Rd +bade6190d60a09b66ddf82d80c88d613 *man/last_commit.Rd +920d98cdd81c4cbfc4145a602d5e00ae *man/length.git_blob.Rd +ee72b371ae4ec50c4bd2d004f39fd6b0 *man/length.git_diff.Rd +811d9a9de11579c753be15aac2560671 *man/length.git_tree.Rd +856072dcdfff2daca80283c38fd9b9b8 *man/libgit2_features.Rd +f5b36b56e9898afc109a4167f2069167 *man/libgit2_version.Rd +af191edd835e0cca5cf0b85f25934b2c *man/lookup.Rd +4ff08be37a9c5c04a42f6b79011b1c67 *man/ls_tree.Rd +12b0c1ac4dbd6bb1ca76b49a77a4357c *man/merge.Rd +8a314b188f3b94545b3b594fb284446a *man/merge_base.Rd +06e31b1f4d627ee738a047e9c49e4300 *man/note_create.Rd +d6eed445f601a0e624cac8c700c5701f *man/note_default_ref.Rd +62d8c3784b621c01f5e546dca493800d *man/note_remove.Rd +bc1aa695283a1dfa5c81f792191aeea2 *man/notes.Rd +25f0f27fd33580f597e402defbb2eb05 *man/odb_blobs.Rd +30d6d9df7b3b64dbc6b7030e0565dfa8 *man/odb_objects.Rd +8c3a7381a8cd2be64cfa2b073638e6db *man/parents.Rd +cffcf994fd1859e70b4668eabb20a4a0 *man/plot.git_repository.Rd +f70f795c8ab2e023cf41ffc0e6635c6a *man/print.git_reflog_entry.Rd +84d19af207c96e2eb1871f3a6fcb31e9 *man/pull.Rd +3d235431994af0b8a92aa9b00ef637b3 *man/punch_card.Rd +883aac36b8c4db09bd9e85f46463a964 *man/push.Rd +af47035de41d6c776c29727190b31b43 *man/reexports.Rd +d95a058f045b24a4c7e8154b965604d0 *man/references.Rd +1290c31bcbad33f05264a7dd83811ffe *man/reflog.Rd +a6442cf9c888a63ce072a7b77b0177ce *man/remote_add.Rd +d5b4f6525762a4cdf01c8b70e3e74c69 *man/remote_ls.Rd +1b6691fb52d638be4f44137234ba03eb *man/remote_remove.Rd +5ff725a2213ff83eb3aec0734b67b120 *man/remote_rename.Rd +8bd38203528c1b20f80bc26139ffadf3 *man/remote_set_url.Rd +8e66dbd022ef80e36eafdebf21aecf10 *man/remote_url.Rd +99c329f0d3fd299c5def2cc5a9e3768f *man/remotes.Rd +b29af1b8c3585127f4f53aa7573a6482 *man/repository.Rd +9df21f476fd89b3f3ec1c1de9aff69ec *man/repository_head.Rd +1da34e53520ba02a0eb4ae101b6360ec *man/reset.Rd +84b6149cda37386957dc717f279a5d35 *man/revparse_single.Rd +8e90d0d433ad219a5000ed8ff447eb86 *man/rm_file.Rd +0cfe021925d6eb6c8767e430687210c9 *man/sha.Rd +8c26e0530f1e63e38046bf723ec8a4dd *man/ssh_path.Rd +dfb4cee2ca9b914e6632f1c7e86c1179 *man/ssl_cert_locations.Rd +aa57f217c9047d9afe781c6dc923ddac *man/stash.Rd +ec5d7436f8d811cb28baf54cd40dbc92 *man/stash_apply.Rd +026fce41fed32ff6d230b386272ce60c *man/stash_drop.Rd +b96f06c9fc091abd1119baa51758321f *man/stash_list.Rd +727ff51d9c80941f8cbfcb4b1a97047f *man/stash_pop.Rd +25acd5832c18ae9e5cbe673cc87b0e50 *man/status.Rd +62cea361a62d5cef753667cd6361dc8a *man/sub-.git_tree.Rd +891457f87e008608a30f9d00df7b13ac *man/summary.git_repository.Rd +7155570b7f66d8149083e11c89ffe4e6 *man/summary.git_stash.Rd +de35673364c382331f0de449e28f8970 *man/summary.git_tree.Rd +87889483c459e7eeb9da4f036817ab64 *man/tag.Rd +eb431887b0c58b50d04a0fb996c37eb7 *man/tag_delete.Rd +a3f3c811ba7b8c69437638bbd949041f *man/tags.Rd +70ca081c2338d670f7f06df9982d4b5f *man/tree.Rd +b1324d535d9b02fa0f52ce7d090bfbdf *man/when.Rd +ba3a1a4f454f3d9d5fc01c5a3b568c85 *man/workdir.Rd +fbd21714f2fcdb394e2958c148349fee *src/Makevars.in +db47ef15e60223671b5019130711cf33 *src/Makevars.win +4777f7482d84aad54a702680e93ae20c *src/Makevars_libgit2.in +05973c7e71cd5cd391388d14e9ef186e *src/git2r.c +ed1bd976ff5d2f7f62af7de0fe68708b *src/git2r_S3.c +88efbdf75df30d20edd9632febb9c700 *src/git2r_S3.h +214e8cd34c367d248667c13b79b246d9 *src/git2r_arg.c +b9727bcf16879b2ec17f291b54cde510 *src/git2r_arg.h +13829b9ab8874c94ce30612a196266d4 *src/git2r_blame.c 0590f03a2973f3b7ead4bfee123c1097 *src/git2r_blame.h -1ea91e24affa7be09c7dc0b4a87fe659 *src/git2r_blob.c -2a95d90c7334c67e41dc2131203d81d4 *src/git2r_blob.h -8a6ac627ecbba0ff83fe040e0dc08310 *src/git2r_branch.c -7884ea9b6b8be8d20334f93b436a4e7a *src/git2r_branch.h -93ab19d28684a89f24ba9d1528b2d94d *src/git2r_checkout.c +6e3830693e21b8588838cffcd8a6a5ac *src/git2r_blob.c +8e1e05b59d833860c48edcea3aedbab2 *src/git2r_blob.h +efde75215abf0dc903932730cf558b39 *src/git2r_branch.c +7d8eedf2fdd2c55dcb6e05ed5c6f618a *src/git2r_branch.h +3f82b44bdb24b3637608849a84b3cabf *src/git2r_checkout.c 89161937429aab6567363d9d4e59113d *src/git2r_checkout.h -b054f6801230708812339b535a0b1f42 *src/git2r_clone.c +ec831ead5841846ab77dc673568d4741 *src/git2r_clone.c 76406656a419de911c6ddc3ad17b908d *src/git2r_clone.h -9c72113329f14584bab30b4ba0a58720 *src/git2r_commit.c -0bd50f26b688788d370a69d930030f7d *src/git2r_commit.h -3de9d8619e7c3d549a4249a2ca20b09f *src/git2r_config.c -68b3a7fcd86b353e9089f04191b78b7b *src/git2r_config.h -aeec1c413ffeb65a36e0d4d11a5a94b0 *src/git2r_cred.c -d7acbaef590bb3d6a6dbefd646fcb793 *src/git2r_cred.h -60c95d5dd757f7a91a388de6a6ca1b97 *src/git2r_diff.c -b51b107b78a425e608d2d285e485d503 *src/git2r_diff.h -6e8472146c99625c8212f05be5d76759 *src/git2r_error.c -e0142dda9f857d03310125602bd16e29 *src/git2r_error.h -08ce432328e876e492598796a4a9385a *src/git2r_graph.c +e8ec99f08072f81badef2914eb5769d4 *src/git2r_commit.c +1a61abdcd5d7558ce07148454a9fe096 *src/git2r_commit.h +49a15286568d2b06cbfd72466bf6f0d5 *src/git2r_config.c +2a5cd9432062a0893957344f471503b5 *src/git2r_config.h +e845a290320c23b7910f090644f5142d *src/git2r_cred.c +d8f0e1ab20252b13d0c819e38eb59d01 *src/git2r_cred.h +65eaa0105a35ef46886d29a0e1a7564c *src/git2r_diff.c +b0d094213b75c83f7259e34db239cfdd *src/git2r_diff.h +3e04a3282286bff5a5f8ac3bc8067184 *src/git2r_error.c +b2d94c84cf719b7092f5a8f7773fabfb *src/git2r_error.h +7ecfec0ba121902c80b59204e679e0d7 *src/git2r_graph.c c3a13beeacf07e857036cbe877d7dae9 *src/git2r_graph.h -844853da2b131dc4e447a1d160c785d9 *src/git2r_index.c +2b021d21e3113eaae384f013e871b0ac *src/git2r_index.c 07277b9d8d7993129165ccf33ecd3b6b *src/git2r_index.h -074b65d765c199992766cf6cb439242e *src/git2r_libgit2.c +e663319d5ae049a7521c69960b991a97 *src/git2r_libgit2.c 5dc19c8872d38e8136b240417fec0a88 *src/git2r_libgit2.h -c4ff6c182a3619b92cc5aa0d2ba8f25a *src/git2r_merge.c -7c829ea7fca51e9477a2fc7c4ac796d8 *src/git2r_merge.h -cdc5e41ba42ae0f94ae0a7a72a252b5a *src/git2r_note.c +ef60261f8046b1933f8091bf74580324 *src/git2r_merge.c +e9fabfe4d16bcc226f6a47f2b492ad95 *src/git2r_merge.h +4d54a85bedff5049ddc28ba247ed7fae *src/git2r_note.c 00c8c66f54b30fac6733aad059256cdf *src/git2r_note.h -c651b30d2477cff43284bd9caf05b4f6 *src/git2r_object.c +2c61becd4f45503ce7ce80d3e9acdaac *src/git2r_object.c 5cfce52edcef1af271df02583927c19e *src/git2r_object.h -caa78a773d149db0b4f408b05a41a285 *src/git2r_odb.c +d284558b9226a8d123f493a0ba966acf *src/git2r_odb.c 25046d116d8caa2140a277ec719c7856 *src/git2r_odb.h 3a72047192880869c88e63e8bd4550ec *src/git2r_oid.c -585a11ea31f589ffe5199bce4d418a36 *src/git2r_oid.h -450010f6d165a9c15ec1a8a620a4c1a6 *src/git2r_push.c +c19b39cc1c34f5b3579a165d8f4973d6 *src/git2r_oid.h +fb73afc795976594f3e0c8ae871a21c3 *src/git2r_push.c 9f877e9f2bb03fa3478acb19c55bd054 *src/git2r_push.h -65978cec8cc045ffb62395c902ed4f33 *src/git2r_reference.c +9515e282dc276d98c4dc622b9fdc6521 *src/git2r_reference.c d1629967caccb4c27989a9723fb03369 *src/git2r_reference.h -ee2d556cc9059fd749cfd48c39f66be9 *src/git2r_reflog.c +8437acc6df332e770e86f0abecba6e41 *src/git2r_reflog.c 8b6e7c2e4207bdb8490e4d3b5284cd67 *src/git2r_reflog.h -86c4d3fef0f3115408138952cfb1123a *src/git2r_remote.c +985d6584a688c8ef9087d036924a373a *src/git2r_remote.c ccdd219017dfc1dbf7304963dada6880 *src/git2r_remote.h -6a4db192e32fd34043b1508bc13acb13 *src/git2r_repository.c -f86ecc844f9c1116f045748f49829000 *src/git2r_repository.h -f85e29309ec94c67742274f98d98490b *src/git2r_reset.c +99f17c63dc14f9b7ffeb024d49a1e52b *src/git2r_repository.c +1fd2bf3801d83d0a1f09df1852ac458f *src/git2r_repository.h +3b457587acc0a5220a20840a049be6a7 *src/git2r_reset.c 1f1475f57ee2f1607cd65c99cf54c9b6 *src/git2r_reset.h -49dacc78eb0b5fd6c44fdde423265d81 *src/git2r_revparse.c +502831328f87c632c2794d0aabfcda04 *src/git2r_revparse.c a5605827f68d65572c28ac647cbf0f55 *src/git2r_revparse.h -4fff52c93f6285e8ee13d5ca1a8e6f81 *src/git2r_revwalk.c +48e2082ecdf803d703bc431e8d850872 *src/git2r_revwalk.c 3cfdeca33edbeab473f55d11cd56263d *src/git2r_revwalk.h -b6cdfa6a96932e04733acd31e65b0d95 *src/git2r_signature.c -fc8bccae893c09a55d364a0d4973a29a *src/git2r_signature.h -3b4e9203d591925125c5c406f4769831 *src/git2r_stash.c -09be7ecfb9f590a4b8e4603a29666385 *src/git2r_stash.h -c4f23e2c8cc13e9124f83e695ada53fb *src/git2r_status.c +8c464741e959b2f40be05c2c4eb936c7 *src/git2r_signature.c +c644c059e5a3755fd2a42cedd35e8d7e *src/git2r_signature.h +9aed9b43cbc8583cacd4a0fa9af9872a *src/git2r_stash.c +3e9721fb8188f18df721813efe34d6a7 *src/git2r_stash.h +5402f643379a5b2841773525d9cebde0 *src/git2r_status.c bf57139eb87e930232eae7507ea17964 *src/git2r_status.h -7e56127bc3d3a23fac53fb7ae6002a60 *src/git2r_tag.c -6bcd3bfc59e770e63a3ff5c51ab3cb09 *src/git2r_tag.h -d6e79819abd7b5f11ffa7b1e238f6c96 *src/git2r_transfer.c -4ae8a1b56cca83b192755b0ce00aca5b *src/git2r_transfer.h -874513ded3f5b595dd95e8bbf3f33a10 *src/git2r_tree.c -7d7f2c578496de162a4252c33f240aaf *src/git2r_tree.h +10d9463b7930eadf81ad570c7021754b *src/git2r_tag.c +28b39608d1bc8c669cf17f6fbf578f44 *src/git2r_tag.h +88aa0f40d1ab8c40089299fe14373395 *src/git2r_transfer.c +f78ee8e7d18ebfb589839ede22c154c6 *src/git2r_transfer.h +749af4aec12777d770c3f4b3a1b68e78 *src/git2r_tree.c +fca98773c5f867d7c6f98afe6a8e3a4e *src/git2r_tree.h 20d989143ee48a92dacde4f06bbcb59a *src/libgit2/deps/http-parser/LICENSE-MIT 12700cf2cfc968d7f884b27e942b7d79 *src/libgit2/deps/http-parser/http_parser.c 0a232503f91c017704fab71390173109 *src/libgit2/deps/http-parser/http_parser.h @@ -273,9 +236,7 @@ 05cd7281a126a9432116821e50d10e8a *src/libgit2/deps/regex/regex_internal.c 3ad4585cc6cae987edbc397afdae48da *src/libgit2/deps/regex/regex_internal.h 760a9fff756040fde62ccf8f1141feb7 *src/libgit2/deps/regex/regexec.c -5c32d93f54a58c1382926a61792bfaed *src/libgit2/deps/winhttp/winhttp32.def.in -245dea4d9024e0381bc9f9bd3a8b6627 *src/libgit2/deps/winhttp/winhttp64.def.in -bd04c2893a6c38840b3297b57672cf86 *src/libgit2/include/git2.h +d48fd0d07a649fb82767817879e08453 *src/libgit2/include/git2.h 55ad69c971a856c48b2b8433d6953597 *src/libgit2/include/git2/annotated_commit.h 057d3d720aed2088a02a91f55c9fc469 *src/libgit2/include/git2/attr.h 55b9ff94ec29b73057cb71aad30152cf *src/libgit2/include/git2/blame.h @@ -286,61 +247,60 @@ 466634a1d1579701ef4322b051c1085f *src/libgit2/include/git2/cherrypick.h aa6fa92748e8ab36c3e0ba783a183b63 *src/libgit2/include/git2/clone.h ed75df9c34fe0246af9b1ff70e7f5d1d *src/libgit2/include/git2/commit.h -45b82fb8dddecd6f936ec10bb8644f8c *src/libgit2/include/git2/common.h -96417478941a669c8c16cc8613f3677f *src/libgit2/include/git2/config.h +20c908878fb297db2aa9dbb5203f41fa *src/libgit2/include/git2/common.h +b9cd24b100eb2843cbd7227b5fd31347 *src/libgit2/include/git2/config.h f5f07b5c8717ba17de187983450d53a0 *src/libgit2/include/git2/cred_helpers.h -42b94c5278bb6223183ea0c84bd2e5cf *src/libgit2/include/git2/describe.h -fb0cc9bc3dbabe19bab9e9f0dffb1328 *src/libgit2/include/git2/diff.h +d9f5625b285fd1cac7a9c68e3deea64d *src/libgit2/include/git2/describe.h +a95e6529244d116c047c6cfb2a578635 *src/libgit2/include/git2/diff.h 4da8fc405613ec7aaf387d3cf17c6695 *src/libgit2/include/git2/errors.h 652b11778ce4a2c356bff75a7151369a *src/libgit2/include/git2/filter.h fe34d6c0f5a2d0e97fb8ef224d83dc9f *src/libgit2/include/git2/global.h -4b84af0e508bc72ff725af8579d6cb0e *src/libgit2/include/git2/graph.h +d0dc163bc6cb01e6f970ee996ac6cdca *src/libgit2/include/git2/graph.h 7c6c5b33a1af3af55754db25d2adc709 *src/libgit2/include/git2/ignore.h 6f450db467ce78bbca21f58e268925e8 *src/libgit2/include/git2/index.h 55c9fce9739883716a1b02d82d5411f5 *src/libgit2/include/git2/indexer.h -73c5f24909256b93563c63d8aac8ae2d *src/libgit2/include/git2/merge.h -fe22c99a5195b789f86041d741c6f5d5 *src/libgit2/include/git2/message.h +384df996bd74019d5a0454a919e2a189 *src/libgit2/include/git2/merge.h +38e8259cc5bc1b7eaabffe4fb1f84913 *src/libgit2/include/git2/message.h c6bca7b8aea63621a479e7a42d209d6c *src/libgit2/include/git2/net.h -ac2b7aca10acb88899e5875809725e87 *src/libgit2/include/git2/notes.h +e4c0679e6dfdb19ad037ebb632a14dfd *src/libgit2/include/git2/notes.h 502a5d8a726b118848b5c553a2cca24f *src/libgit2/include/git2/object.h -b8d1b101b106c227f7dd206222ff1da3 *src/libgit2/include/git2/odb.h +67f092af2468e6dfa25797ed4e6766c1 *src/libgit2/include/git2/odb.h 3dc5caa9d9d4b3acbc13b319e3474c58 *src/libgit2/include/git2/odb_backend.h f5d4adb9d24e632ad2bdc1768d503a78 *src/libgit2/include/git2/oid.h cef73f1567da68168c83765f526eb5e6 *src/libgit2/include/git2/oidarray.h 537fd073d6ba83f82f5fb6db04ce66f0 *src/libgit2/include/git2/pack.h -443a807bf2cdbbdf2db18008f9b01f5e *src/libgit2/include/git2/patch.h -ef826cf0ae8330c1e0d65a8d6ef09242 *src/libgit2/include/git2/pathspec.h +55d9cba424cd1490d846a612908d62ab *src/libgit2/include/git2/patch.h +cacecfa6ad5604b1bbcb3c65e782cbff *src/libgit2/include/git2/pathspec.h 21815583d2745bfe3ca5fdb95bf4b3aa *src/libgit2/include/git2/proxy.h b8864704fd5bd3c2072edeeb8c9d48fd *src/libgit2/include/git2/rebase.h 15c63b4d0d57a09871b3c91f286eba05 *src/libgit2/include/git2/refdb.h bead33d7ed800b97c78e8e97c102dbab *src/libgit2/include/git2/reflog.h -67f8f248289b56584bc81beb42354c48 *src/libgit2/include/git2/refs.h +4a1ef83cdac1be16fb346d2a9b4e3736 *src/libgit2/include/git2/refs.h 53cd6881d8ef58ecb7c1399ad4e2525e *src/libgit2/include/git2/refspec.h -32e8cd2d08fee418103a7e508938b7d7 *src/libgit2/include/git2/remote.h -3431b6af4facd7d1a777fd9c994aa899 *src/libgit2/include/git2/repository.h -8b556a7d79586faae3b42527e5baa39d *src/libgit2/include/git2/reset.h +49ec96f424917acf5e57a21283d067be *src/libgit2/include/git2/remote.h +90f9e8f8566d6908c362dd63eeb16df8 *src/libgit2/include/git2/repository.h +f50b51bf0308a1641827a2c9b0485730 *src/libgit2/include/git2/reset.h 12281669019763f9dc55a9f7e1a3f4bd *src/libgit2/include/git2/revert.h 25ce2fd20d5ab1cdf3ba98ab6869b2df *src/libgit2/include/git2/revparse.h 1b61c6197dc41eb855eea84496a534f3 *src/libgit2/include/git2/revwalk.h 121c6764a266f3248b8639cbe6196a69 *src/libgit2/include/git2/signature.h ee274a0e03ce9529b0a570f1cb1846b4 *src/libgit2/include/git2/stash.h -6b115cec2278981c0c6a024c31cf3679 *src/libgit2/include/git2/status.h +1c63c753664b856b58178718615a92d8 *src/libgit2/include/git2/status.h 3e93b77c526b3abbc6f2e25d0158d042 *src/libgit2/include/git2/strarray.h 3d4bba1a3ac07fd6948c4a1c4d30971a *src/libgit2/include/git2/submodule.h 455d1b16edff575b5a2a38ff331c4290 *src/libgit2/include/git2/sys/commit.h -a03212944ef36214bab4e4fbd88d6287 *src/libgit2/include/git2/sys/config.h +1cc5860809bb9165fe7d1c65a50d9ddd *src/libgit2/include/git2/sys/config.h c21f458e1d80f0b83690a586a20cabed *src/libgit2/include/git2/sys/diff.h 47e2921e115a615a63c48d9bdbd76ae8 *src/libgit2/include/git2/sys/filter.h 528ce9e7374369cdef155a57c3427ab4 *src/libgit2/include/git2/sys/hashsig.h 5d799b7101260390bb65d528fd3163b7 *src/libgit2/include/git2/sys/index.h -d6ca0f74e6e20c3a21a26bcdec157804 *src/libgit2/include/git2/sys/mempack.h +90d347977dad8fc1f5fc84de50831143 *src/libgit2/include/git2/sys/mempack.h 77b50ab8fe1f84eeb1a6844e8beffea2 *src/libgit2/include/git2/sys/merge.h -267a3161f8370f0c83c29ff54695d268 *src/libgit2/include/git2/sys/odb_backend.h +712ac3d4cc2c968961e23993413d32be *src/libgit2/include/git2/sys/odb_backend.h 35100b3dc3308443df5ca45008ae0ab5 *src/libgit2/include/git2/sys/openssl.h c061b9d429448a4460a26794238e77e1 *src/libgit2/include/git2/sys/refdb_backend.h 5b7105b9bd458c44870a17a8574e1584 *src/libgit2/include/git2/sys/reflog.h 5ef00738bc010797724ea40412cb1eb9 *src/libgit2/include/git2/sys/refs.h -5d744662052cfc97b5f961d3eeeb1fe7 *src/libgit2/include/git2/sys/remote.h 5a62706202a4fc7b5baa900d5859873d *src/libgit2/include/git2/sys/repository.h fa488e15ffb2ce0ccc1a292c9e3fdb9c *src/libgit2/include/git2/sys/stream.h 8993e90d527a6e38baf7a82f3c927c7b *src/libgit2/include/git2/sys/time.h @@ -349,353 +309,325 @@ 519e2fd8f3c68029b94514cc3861f509 *src/libgit2/include/git2/trace.h d9e33aae83238f7b44232c3873933946 *src/libgit2/include/git2/transaction.h 3c369b0194184eb876b9f21321d372b8 *src/libgit2/include/git2/transport.h -01a530dd918af42faaeb0c5dceefa9b3 *src/libgit2/include/git2/tree.h -f0284da6b3f4981599c63b45a6b58a60 *src/libgit2/include/git2/types.h -2335710f6f45cf45b23a55717620a8b2 *src/libgit2/include/git2/version.h -c3d0b14002144e7665a3c35cd038d97a *src/libgit2/include/git2/worktree.h -90ee2277beead7ad7e5c2bfdcb92b8a5 *src/libgit2/src/annotated_commit.c -f4234b79c0e2badbed261a9a84cce23a *src/libgit2/src/annotated_commit.h -2195db271519f99f52707c09cbed4868 *src/libgit2/src/apply.c -b0f94fa86df17a21811bc46b26c9879d *src/libgit2/src/apply.h +ca6b91994b6812192cad69ffbcb0ce77 *src/libgit2/include/git2/tree.h +68f92de7a9faa5ae9300deb0375a1417 *src/libgit2/include/git2/types.h +27f6660620d4e1b8c39211c2d1d3bf80 *src/libgit2/include/git2/version.h +9919449e5033d822c1c9bcf715ea8d9a *src/libgit2/include/git2/worktree.h +9faeda2370accdde328afa321db972d6 *src/libgit2/src/annotated_commit.c +a28b1d43148529cda316e68eede35642 *src/libgit2/src/annotated_commit.h +9c0f74f07eae5cc493017806c12d4b75 *src/libgit2/src/apply.c +62bb5141e27e5ca5d52ad35310686541 *src/libgit2/src/apply.h e239aff944d41ec36656d68ce1b84a9f *src/libgit2/src/array.h -0a037e1654af28029091b803c1f21f99 *src/libgit2/src/attr.c -afdc38b7bda8d3b6bc29041371839e4b *src/libgit2/src/attr.h -5b9f9e43b41c3c66a8bb6096d308c143 *src/libgit2/src/attr_file.c -7fb57b0585c96416a840c4fa83bb0ee0 *src/libgit2/src/attr_file.h -884ba6a504a1458b6330067af0ef1e78 *src/libgit2/src/attrcache.c -6c1ef305d258d1e5611a97c63d2d0b2e *src/libgit2/src/attrcache.h +893f36ed80de394122933e952bbbd3e3 *src/libgit2/src/attr.c +dee6edde38dac6fe5bdbba88c9074e6e *src/libgit2/src/attr.h +24fb0ee56e832362f20fe3c66054f1fb *src/libgit2/src/attr_file.c +9b342a93c65a5122bc95d138fb29eaae *src/libgit2/src/attr_file.h +4fb0a35482cca1bdc85a65d2d774cb8f *src/libgit2/src/attrcache.c +c4e401e26528ba15e293e51bf09aa01f *src/libgit2/src/attrcache.h 93d6655d87a8606fe606aedfa86ed7d1 *src/libgit2/src/bitvec.h -70ccbac5a61684919baa8f5ab43875ce *src/libgit2/src/blame.c -ac053f56228184cb4b027ca691512f3e *src/libgit2/src/blame.h -129440e6d6f2fbbce67f374595665656 *src/libgit2/src/blame_git.c -3915206dedc55c553b2400c74a5acd1d *src/libgit2/src/blame_git.h -5da26c2d77220239130562e337009ff5 *src/libgit2/src/blob.c -29f3e2538d418edd27d55550cf802a2b *src/libgit2/src/blob.h -e455242a6b346c5d0c6233b7fbc26eff *src/libgit2/src/branch.c -66c3e6db4b7463265ec8dec5c8a94d3a *src/libgit2/src/branch.h -c31d69eba45f1fbe2803230a4cd258a4 *src/libgit2/src/buf_text.c -687818ed6cee09db0ecd6901676187e8 *src/libgit2/src/buf_text.h -3c28d3ee78b5ae2c6d04eedc83723f1a *src/libgit2/src/buffer.c -fd4c6c5e7d9f2703f8868e54de11450e *src/libgit2/src/buffer.h -0db0882ac5794d7e342522730af17960 *src/libgit2/src/cache.c -e241c6f5e20b426f0ab9029f419a5e47 *src/libgit2/src/cache.h -cbc6bf45084b94b2c039b9e335a0d7cd *src/libgit2/src/cc-compat.h -c58732054d4138ef414bb3cb5feeea0c *src/libgit2/src/checkout.c -23bb62ebed396fced235699238b0fc44 *src/libgit2/src/checkout.h -fdf19db8ad5b8d4093c91c1c5b3a4590 *src/libgit2/src/cherrypick.c -db7a96c7f34db41724d3e103837e04b0 *src/libgit2/src/clone.c -a301719304ff81e65582d301a1c830dc *src/libgit2/src/clone.h -82e291c078836341650ec359277eecfe *src/libgit2/src/commit.c -b5a4c3929e6ae13cc06b71599044d4ee *src/libgit2/src/commit.h -f75ba2068b0cca6c71ef0767970a61f2 *src/libgit2/src/commit_list.c -555f4b4d949f2cd41bb377ad9a933813 *src/libgit2/src/commit_list.h -e576a3edf6ccc6434b0ed762989c1e4e *src/libgit2/src/common.h -974af3e2a5f148cc96443f4cd23d5f9c *src/libgit2/src/config.c -659b687f729870fad64d75d46f7a499b *src/libgit2/src/config.h -64a0d4d0b2c362e063f023261baf4112 *src/libgit2/src/config_cache.c -9267851bc81ba5784a62c66dc3e4db17 *src/libgit2/src/config_file.c -d5903a4c9b283fff44a07c9b556f397c *src/libgit2/src/config_file.h -e203432d80cfa475653c3e49d4e7190d *src/libgit2/src/crlf.c -4dbb5a912a6d1da8932a8f3fefa5f9b2 *src/libgit2/src/curl_stream.c -50ea8edd525d446a5b5ec1a4e1079ae5 *src/libgit2/src/curl_stream.h +aa0c4bee813196ca22296b1e72e957c5 *src/libgit2/src/blame.c +d0ec5b309c305d35d88cd68f6f86456a *src/libgit2/src/blame.h +2e4417ed285f892995a8fb9dcd59b338 *src/libgit2/src/blame_git.c +03327443d37fab50256dffdf86eb0965 *src/libgit2/src/blame_git.h +ee11826bfe066efd0845c92893fdd142 *src/libgit2/src/blob.c +003cedeb0e7c0185aa1fd7382d59e7d9 *src/libgit2/src/blob.h +3f6190f86a352b3b838194647640961b *src/libgit2/src/branch.c +8c1e7705b12a2533e9e6cb81dac4df26 *src/libgit2/src/branch.h +86c75d8efaab35d5345bda5183b05c12 *src/libgit2/src/buf_text.c +6bdfe1696c72e8e9b296795737b55e51 *src/libgit2/src/buf_text.h +0f76a4fa2c9c101f4527adb347fbfd9a *src/libgit2/src/buffer.c +9f6b511a7b96686b8e28ac21bb5a8f7a *src/libgit2/src/buffer.h +46aece55bd6631293bd4d0659fc8c6ed *src/libgit2/src/cache.c +c248167a5f85407aadc0765c1aa447e8 *src/libgit2/src/cache.h +c1b344f43f0425602359670b58d1353c *src/libgit2/src/cc-compat.h +793009c581e20dc3b9494aacd0fffa12 *src/libgit2/src/checkout.c +9b40cb51278171193441aaba1a17218d *src/libgit2/src/checkout.h +869737dfeabc058dfdd1ac1b901cc40c *src/libgit2/src/cherrypick.c +ebd8bde8ae40a5c486faa1ba185b40dd *src/libgit2/src/clone.c +36fd00ab1fb0f4efc3a38dc4a1146101 *src/libgit2/src/clone.h +49f3ca57a742393d7f07caf28567bbcc *src/libgit2/src/commit.c +d3fc2496af93842596fbcdffae58729e *src/libgit2/src/commit.h +61a780572f33a712f86bf77f1b3d849e *src/libgit2/src/commit_list.c +722e5b18f41002822addf797059ff213 *src/libgit2/src/commit_list.h +4581a7c567a8ad152b578141f2a1ac46 *src/libgit2/src/common.h +824c62209f336c9c45ce45fc62989b5d *src/libgit2/src/config.c +bbcaeaab5a5c86d0fe9c3a9836e1e6df *src/libgit2/src/config.h +0605c7b301bf2884e78bb564f603ee90 *src/libgit2/src/config_cache.c +b06fb46864d9fa19895857855d0645e8 *src/libgit2/src/config_file.c +c680f3147d47efe4c074ec7263c4452a *src/libgit2/src/config_file.h +623270001b95c57e3fa76a6ec67562a9 *src/libgit2/src/config_parse.c +3f8a809f2c6acb2e2e90738caf8d27f9 *src/libgit2/src/config_parse.h +5108830b3131fe7c174844acf6daf855 *src/libgit2/src/crlf.c 37a1f5b63396adf481ad147f423b9f11 *src/libgit2/src/date.c 95dc5d6d287f560fb5d5968e6efe82b4 *src/libgit2/src/delta.c -50dfbbf2bd9e9fade535918512de1e1a *src/libgit2/src/delta.h -889e8949b92252d136ee0d0cf50d46fc *src/libgit2/src/describe.c -d72537f845b45b61f081f63fd08a88cc *src/libgit2/src/diff.c -3d080baeb695266643ad5f09f446535d *src/libgit2/src/diff.h -ab42c248e1fc33a0f1717f838b817f25 *src/libgit2/src/diff_driver.c -aff012a9bba25749cc65133a622c4fc9 *src/libgit2/src/diff_driver.h -da21ea88f6114c6c970c597ae08b2a6a *src/libgit2/src/diff_file.c -003201cf9e1afca0bafcdb22a2a89632 *src/libgit2/src/diff_file.h -9e4f050b1229ab584889fbc01679f331 *src/libgit2/src/diff_generate.c -cec48eb418e2a6bec9708d8af7dbe6b9 *src/libgit2/src/diff_generate.h -65c07fa43a91c6cb595cdd36c50c4374 *src/libgit2/src/diff_parse.c -5f00645684b9dca52693795d1d00a554 *src/libgit2/src/diff_parse.h -5a06bdcf5e3d777619ab8fcc3bc96dfc *src/libgit2/src/diff_print.c -4845657b8642a9110b889fbebd5a59dc *src/libgit2/src/diff_stats.c -345729a9eb9757029bc18febf9ddbd33 *src/libgit2/src/diff_tform.c -0e258b00997a2f23f623e35775d4c62b *src/libgit2/src/diff_tform.h -4fc2c30e2679cc84698cc757676369c0 *src/libgit2/src/diff_xdiff.c -0403200dce2069c84ab3668f1e986143 *src/libgit2/src/diff_xdiff.h -a08e377fe18f1b9707ae7c2f6baad330 *src/libgit2/src/errors.c -37b290903c497ccaee7b24c734b82bc7 *src/libgit2/src/fetch.c -8af62c1b5664e052b591b04fac5fbdf8 *src/libgit2/src/fetch.h -eae58573872304aaf845580e6b120376 *src/libgit2/src/fetchhead.c -f4217df6b8561e818d49b1964ab816d2 *src/libgit2/src/fetchhead.h -eab2bf90e445558de32f61acd43420dc *src/libgit2/src/filebuf.c -3cffbfba2f95a366f1d526d69fed799a *src/libgit2/src/filebuf.h -2473268968ff43a2bc7a124833d7e22b *src/libgit2/src/fileops.c -41961369713529ea9db011cf8795af25 *src/libgit2/src/fileops.h -4083447f2b55f40c644164654ba5952b *src/libgit2/src/filter.c -d7a2d7ca92ed206284da8c31263ff368 *src/libgit2/src/filter.h -30801a7591210779bd8265f0d7d3e7f5 *src/libgit2/src/fnmatch.c -13a7d4372cdc155bbd2c81f3042b96fd *src/libgit2/src/fnmatch.h -d9969b4095c716b98204e974330485fa *src/libgit2/src/global.c -716227d9a11718b0131202d81547d6b7 *src/libgit2/src/global.h -ce89817b6332e365c78a4e1fc3ecfe1f *src/libgit2/src/graph.c -cf76c46ead6e49f6d098c09d6b73f88c *src/libgit2/src/hash.c -fee40233f8d7644bd4d15a0483c19fa2 *src/libgit2/src/hash.h -9ee9713b689c0062ea37515959969e44 *src/libgit2/src/hash/hash_collisiondetect.h -55913ca0d3c94e3acc86fe212b35027a *src/libgit2/src/hash/hash_common_crypto.h -4e36a28549fa4f380bafc6671d8c3ac0 *src/libgit2/src/hash/hash_generic.c -c264e4d571abd9eb664af3ac2bdb77a0 *src/libgit2/src/hash/hash_generic.h -6170acc507d5ee2fde2e7330b75b6e10 *src/libgit2/src/hash/hash_openssl.h -78c44ddbb5d0bfaacc069a26b3c06130 *src/libgit2/src/hash/hash_win32.c -ea5a983361cb86b40ce577b7cb97ae37 *src/libgit2/src/hash/hash_win32.h -836fc05511d23b9643e6c93c7d227263 *src/libgit2/src/hash/sha1dc/sha1.c -21c70909bcd057283a6a2b023256dafc *src/libgit2/src/hash/sha1dc/sha1.h -14bd8908eb52a8a4a426faf9c538d077 *src/libgit2/src/hash/sha1dc/ubc_check.c -6633a9728e2b0278c0a60eb3f77651a3 *src/libgit2/src/hash/sha1dc/ubc_check.h -3be58aad5a1e5649c7efc7676385804d *src/libgit2/src/hashsig.c -e7d76df02baccda47bf67e967cf14806 *src/libgit2/src/ident.c +556d99a82704627f1dec80bbbabba87d *src/libgit2/src/delta.h +8482c93dae2d6e036080b5f4960fabd4 *src/libgit2/src/describe.c +4fd4ef2523e7670b2a926152ee936484 *src/libgit2/src/diff.c +b6949d13ffeae1aaf32c59ee202e3d3e *src/libgit2/src/diff.h +d85fd81ce1f2439df6f537e91c059a50 *src/libgit2/src/diff_driver.c +beeef329f781689b83779c37234b57d6 *src/libgit2/src/diff_driver.h +bdb0adb220ffb68ed43ba180c165289f *src/libgit2/src/diff_file.c +83d9581685720d65d5084afa4b784271 *src/libgit2/src/diff_file.h +aaa9203484fdf3948fec4a1d2863a0a8 *src/libgit2/src/diff_generate.c +879b4b34d8cdad7c940fd824f809018b *src/libgit2/src/diff_generate.h +8a950b4eae3d744489ed3a56e3a31d96 *src/libgit2/src/diff_parse.c +af7be5f396b0180b1bbd8b9b228cab22 *src/libgit2/src/diff_parse.h +453c17670a2eed9651066e146e6cd600 *src/libgit2/src/diff_print.c +20858185655223e27f9921cd50ce5470 *src/libgit2/src/diff_stats.c +7246f262d3165dec3ec6b9c0626044df *src/libgit2/src/diff_tform.c +a06cbfd4d605b5b1e5a6348e7085b891 *src/libgit2/src/diff_tform.h +67d1955ea5e2440b9c3e367c74f95751 *src/libgit2/src/diff_xdiff.c +170b2b9972e83bed35d60ce5845ccb17 *src/libgit2/src/diff_xdiff.h +addd2c4559cbd10c4ac1ff56f2b5b9ec *src/libgit2/src/errors.c +04a3721da8b852585799ef3279db836b *src/libgit2/src/fetch.c +0415665c1ed6a7837725529eb5b1018c *src/libgit2/src/fetch.h +5cd5798ef1c2113ec1549588adcad186 *src/libgit2/src/fetchhead.c +3ac96a36098810374155c4a69dc56874 *src/libgit2/src/fetchhead.h +fd1286778d0b1b7dd02885e6f818414d *src/libgit2/src/filebuf.c +b0381290f0bafa463deedf40790d7b5c *src/libgit2/src/filebuf.h +a9c0925c5a67459e7d279e222d51bf8c *src/libgit2/src/fileops.c +1a1a2cd3be744cdba193c7bb9e99a30d *src/libgit2/src/fileops.h +3f9821294e9d7d7f9a8207b8b562f7dc *src/libgit2/src/filter.c +4b92e9b4da7d3e81c2280a50451dca01 *src/libgit2/src/filter.h +b8a015d1f72bdb6260f83ddae0a8a3e9 *src/libgit2/src/fnmatch.c +178b4214e4bfca1d97f8a44f3a355c44 *src/libgit2/src/fnmatch.h +8a6126759779dae5a0283355e35dd2d2 *src/libgit2/src/global.c +d0ff89d7fb6aaf710b8faa728192ff59 *src/libgit2/src/global.h +848607e2ba25937091627556374fcd98 *src/libgit2/src/graph.c +016c94c6e627b6c7a2156f3a68d5eb90 *src/libgit2/src/hash.c +f2d0df05ca4681f207ba059a145abaaa *src/libgit2/src/hash.h +f057c15ed35303db074fd9b9226a90aa *src/libgit2/src/hash/hash_openssl.h +b5cc6845c06f2ae01a193b8147807624 *src/libgit2/src/hashsig.c +042c55997d31eb563f891e93703da374 *src/libgit2/src/ident.c 7d5d46b4e3226f071522a29c3bdc0ad6 *src/libgit2/src/idxmap.c -7663b96da1e3f583ed219e155b9b42ba *src/libgit2/src/idxmap.h -c7d3918d935ab34d7bf6dda91cfd5ccd *src/libgit2/src/ignore.c -41c7e8216fc28adc13bb5ae4f69f1539 *src/libgit2/src/ignore.h -f1c67d1730febf444768802a14738891 *src/libgit2/src/index.c -f264f282aec5bda80fedcb31ff6d7f54 *src/libgit2/src/index.h -bff749c5179ceaadcd3fa2c5ace3ddc9 *src/libgit2/src/indexer.c -7577c08f585112a19028214b3940e834 *src/libgit2/src/indexer.h -b812636afa9df962106b4ba53ebe0d78 *src/libgit2/src/integer.h -c483d39e971aa590bafa855e6aa93254 *src/libgit2/src/iterator.c -5d2bc17e942527dbdc1c6bc5345d9872 *src/libgit2/src/iterator.h +918f33ec71b93fd83f9a17ab2c26f9a5 *src/libgit2/src/idxmap.h +0bb0dc8c3432a022573c8b670f63592a *src/libgit2/src/ignore.c +b1cff5c92d6c11f2e9ffc591b32e2f19 *src/libgit2/src/ignore.h +bbe7dfd87b4c3f677b54c8f33795e5ca *src/libgit2/src/index.c +e6cc4d99a873e3442a8755fe7150e7fd *src/libgit2/src/index.h +fb2f65e8258a43e5cac0e212a9a84d51 *src/libgit2/src/indexer.c +107ec5ceb74e68cb57bf24b8c9ca9e66 *src/libgit2/src/indexer.h +2404dbfddb5427d68019df0563863218 *src/libgit2/src/integer.h +ade368f503667d19022c018e99ea4b23 *src/libgit2/src/iterator.c +1d99c3a2a870a510f67a54e793c6bc09 *src/libgit2/src/iterator.h 2b05c2d91d61728691c3c2968b409897 *src/libgit2/src/khash.h -7eca0fbf518dca28e502584674d22fd7 *src/libgit2/src/map.h -8c7373fe1d58d3da9f17d3ad8ca95c82 *src/libgit2/src/merge.c -ac38450b7bb4cef6d51f8c21e8c98937 *src/libgit2/src/merge.h -709f167044104954fbf6604f9917a8ba *src/libgit2/src/merge_driver.c -ad763d3f7462d681f84ac9bf7c1ebfdf *src/libgit2/src/merge_driver.h -2c288f570ae6f47586391c6c254d990e *src/libgit2/src/merge_file.c +33238f0d9a04b0d7fca82510653e1044 *src/libgit2/src/map.h +2fa1eaf47e43873af604111a5cdb38e2 *src/libgit2/src/merge.c +86b834243fa2d9181fd6c19f37ef76c6 *src/libgit2/src/merge.h +5e3cbb4f7787e368685801101e22a162 *src/libgit2/src/merge_driver.c +7b8bce8e499a50c8c01ec4c2e2e1034e *src/libgit2/src/merge_driver.h +589e764e0f8dc1573adfbed0d5603279 *src/libgit2/src/merge_file.c 4c04d38e446b87c0feeba237fc378d0a *src/libgit2/src/message.c -03c131034b22879c0745dcb9f830e75e *src/libgit2/src/message.h -c5c7eaf0c1953801bb9f83555b125759 *src/libgit2/src/mwindow.c -7af7dec6ef2839cd4682719b33951e4d *src/libgit2/src/mwindow.h -2b8b19470d7ae3bc805026424e8ff5ea *src/libgit2/src/netops.c -7c817a7cc0fa82df00252ec111d629fd *src/libgit2/src/netops.h -36521ac4806d5f511ba4a352eddbcf91 *src/libgit2/src/notes.c -81f81df1fbdf35fea323b4f82f57cb0d *src/libgit2/src/notes.h -b1b77a12d73d6314620e1e68d3909c7c *src/libgit2/src/object.c -bb2d2f92f046f3e837f9929961d75e46 *src/libgit2/src/object.h -ad6cfa0fe6eb1bc25ed2e2ca89edc728 *src/libgit2/src/object_api.c -6584ad9688199c41dc0c8c4c7180366a *src/libgit2/src/odb.c -a5dc3217c7a69095ef3ce4e5b5621ffb *src/libgit2/src/odb.h -ebbf36a787cd1705b1161250389485e2 *src/libgit2/src/odb_loose.c -e75179003544e9963d77ebe455df4232 *src/libgit2/src/odb_mempack.c -ffc615580498a28ed280f1ca801827cd *src/libgit2/src/odb_pack.c +6166420f26f3c52ae8db63ec340899a4 *src/libgit2/src/message.h +08aa2ad163a5ef2e4793829b94afc414 *src/libgit2/src/mwindow.c +7972ec57b87327bcb7a32b8135e37b24 *src/libgit2/src/mwindow.h +9e7e31f2cab32fc2a6f492d625ffb1b8 *src/libgit2/src/netops.c +46689680a5dbbaef3a2d45bfe7a87aab *src/libgit2/src/netops.h +f61b8236b03cfc615f95edba8be60233 *src/libgit2/src/notes.c +43424e790704016a8fe028df20009bab *src/libgit2/src/notes.h +8850739ff348eca1723a380c91444e77 *src/libgit2/src/object.c +3e23033e72ef8f43efd5093957200c39 *src/libgit2/src/object.h +2351d64d1f559f94b9c91dabb50b46b3 *src/libgit2/src/object_api.c +85b91919add979f99d44c6bd81135a6b *src/libgit2/src/odb.c +6a3e3cb386a1e577d9e552ff6d6c9064 *src/libgit2/src/odb.h +5f56be3a822a0fb038a35d155fe0e9ba *src/libgit2/src/odb_loose.c +5c00f773309961f4684bf16248789763 *src/libgit2/src/odb_mempack.c +90af37b0c40f7d6a8837ff79b18a6ab2 *src/libgit2/src/odb_pack.c d314a99cf479c3f9c8abd6c3bd00db73 *src/libgit2/src/offmap.c -bf9a4762bd1fd3693c498354dc18c7b3 *src/libgit2/src/offmap.h -7c2e8945f95d1cb01cb78ff5f92b5eed *src/libgit2/src/oid.c -3a9e0c53c99ba0a122e9c2cbee571db5 *src/libgit2/src/oid.h -2597179125c2bc92fd71d08667c83fec *src/libgit2/src/oidarray.c -0a093723d7a8723dc8736fb19c963cd9 *src/libgit2/src/oidarray.h +cb04f1d788b9df478f02c807435d371b *src/libgit2/src/offmap.h +66e9d77df1de9d301a19c4b154c302ae *src/libgit2/src/oid.c +08d8f66109fe29f77e3e91e894cd81a9 *src/libgit2/src/oid.h +97f3f17f89f73e6514f2a018468d4453 *src/libgit2/src/oidarray.c +d4cab7dde89df13b08eec0f912b68eee *src/libgit2/src/oidarray.h 1ea3739bfbe0e0aa0deadab43d72f5ef *src/libgit2/src/oidmap.c -25b54049bc8660e1ca61540eb2dd700c *src/libgit2/src/oidmap.h -250d94604017bcfb20fddf71cf728b15 *src/libgit2/src/openssl_stream.c -6375b853ff05faea3fa10e7901650c78 *src/libgit2/src/openssl_stream.h -a6f7f49c772955e4399ce73dd714e6c1 *src/libgit2/src/pack-objects.c -4c7d84be89964d9ef58f09b89fed902d *src/libgit2/src/pack-objects.h -d8f6256c9fae61365bb0352e779a636d *src/libgit2/src/pack.c -ae02e05acee790d83e3d01f1dcc380ba *src/libgit2/src/pack.h -d784c68e2b33e5704fc310f6886c9d7e *src/libgit2/src/patch.c -25190c9fc26b9606628a186432b266dd *src/libgit2/src/patch.h -d50543771007b8ce9c07a6e72603a334 *src/libgit2/src/patch_generate.c -aa5b333eca3d6fab046bea892491fe48 *src/libgit2/src/patch_generate.h -b2abbfa73797b0b2ccd761f80bc56327 *src/libgit2/src/patch_parse.c -bc8b249ba1b57d3ce262ee0bae98a497 *src/libgit2/src/patch_parse.h -ddd0ee919aa304545eab1a7004228aae *src/libgit2/src/path.c -d46394a09f3404c3e658f16ea209e26b *src/libgit2/src/path.h -40b6d6d8056d005cd73edb4601a452df *src/libgit2/src/pathspec.c -2191d4ea7478444ccbbd804b7a6c5618 *src/libgit2/src/pathspec.h -fcdace62a2780605c57a66979b2b55b3 *src/libgit2/src/pool.c -231efd1f40b0f05363cc82ab8dbf8608 *src/libgit2/src/pool.h -c9fa15fe93c1e7988ce8e7c7c013c518 *src/libgit2/src/posix.c -cf0c2d83b80dd817fb3c7204f013fb99 *src/libgit2/src/posix.h -6a64b5fdd2c1ddb58e4a3fc7fdf4dda8 *src/libgit2/src/pqueue.c -314bc5323aa4e205d2b6d468a2b36bd4 *src/libgit2/src/pqueue.h -8db2144847f7fe29573b7a4119cba24f *src/libgit2/src/proxy.c -99bc206903da822800a2f5cc4f33ec04 *src/libgit2/src/proxy.h -d0bf055ad28f54fc0d04c3aca97b3615 *src/libgit2/src/push.c -7ca9f9faf6a793853adb3ac9a5b597b4 *src/libgit2/src/push.h -215d3303eea0993dd620c3510588fa38 *src/libgit2/src/rebase.c -0063a9455d726a60e503e22717652fec *src/libgit2/src/refdb.c -6417592ca7605036e5dbf3b6528239e3 *src/libgit2/src/refdb.h -d8eb10748b0a95e2d6309d7fa25ecc6a *src/libgit2/src/refdb_fs.c -98563b2ed8c9960d944ac03e10d1aac7 *src/libgit2/src/refdb_fs.h -eb03afc52553da382f178389c38de5ab *src/libgit2/src/reflog.c -ed893c1c6c01d80dbe3c5da1f731921d *src/libgit2/src/reflog.h -6578851aca1e893b2a08f2c1c932c32e *src/libgit2/src/refs.c -7fef380eb7333e9da71dfec524153833 *src/libgit2/src/refs.h -6e044dc81018f20f8f9a4072361993e8 *src/libgit2/src/refspec.c -911b1d3771d29c81e2ad6bd8b6da3731 *src/libgit2/src/refspec.h -3030af0ea200f8409d227ca9def55a42 *src/libgit2/src/remote.c -5c697854f4af580a65f7ff97a7fd902f *src/libgit2/src/remote.h +044002c9ce63bfdc0c24df9c6e1a5758 *src/libgit2/src/oidmap.h +223a076fa633da268af20f99fd691d8e *src/libgit2/src/pack-objects.c +b97018ea8d8aa2bdae98a81cc0b6012a *src/libgit2/src/pack-objects.h +50d1a0898409b9f57d68ec219f69409b *src/libgit2/src/pack.c +30336f0d6ab3e841aa684b391f52ce76 *src/libgit2/src/pack.h +61df7a8edbffc70a654bc6b4a9805115 *src/libgit2/src/parse.c +d00ad5f87a35906432c8535e3403b6ff *src/libgit2/src/parse.h +d567662878e1e7d509b32f3e62b7d8bf *src/libgit2/src/patch.c +59706e320d105777d7fe67b281b1316d *src/libgit2/src/patch.h +4ad7365e1208dd0df69a907d9f7c9015 *src/libgit2/src/patch_generate.c +d67744ede42e614e7aea95a8e88b5eb4 *src/libgit2/src/patch_generate.h +4bc5204e67b34b048ac26e7732b3d2ff *src/libgit2/src/patch_parse.c +5b70e6a39b5159d48d8a772cb781c490 *src/libgit2/src/patch_parse.h +df26f0277d3459178c3dcf1c134b8f77 *src/libgit2/src/path.c +ca85b801d75bfcd37da6c43a77a295bc *src/libgit2/src/path.h +4b92b2d327fc6c8f9ce3d926228a8e17 *src/libgit2/src/pathspec.c +66a1cc51a099ef0d9cf6cfb04dc42526 *src/libgit2/src/pathspec.h +1676e682e789ab2054714ad237b2e445 *src/libgit2/src/pool.c +66024da08e8adb9cac32c39c85ab7a8e *src/libgit2/src/pool.h +ca16c0f599bf6312dc20ebada802c02f *src/libgit2/src/posix.c +d77d65467cd1eddcd8e6af0fd5728aef *src/libgit2/src/posix.h +994f1d3b5dda2e4f30f1d69efe3b8a60 *src/libgit2/src/pqueue.c +55a8ef0429841f9730be8ef63fa125a4 *src/libgit2/src/pqueue.h +d5b875599f4bdd050b89afc657e64ad0 *src/libgit2/src/proxy.c +c813798d45282a651a0d90ca188e18cd *src/libgit2/src/proxy.h +1fa4d31d8a3a2d2cbc707c5a8568f907 *src/libgit2/src/push.c +8536373f6083ec160fcc5db80b83b4b2 *src/libgit2/src/push.h +67cf71a7d3a08b5b4627b08b80e6a63f *src/libgit2/src/rebase.c +f9e0fa1cfa9a2431a9fbf6cdbe85ab4a *src/libgit2/src/refdb.c +36397572816b876b8a07197ea5f31e41 *src/libgit2/src/refdb.h +ad0eb1ca8076a320b47c48e9c0d84d4f *src/libgit2/src/refdb_fs.c +2d3d102cc4b6ecf0dddaf5ff00e1be01 *src/libgit2/src/refdb_fs.h +bfbbabfcd04de15f2926442e41c0888e *src/libgit2/src/reflog.c +b87cfc1afaae103e87d40b559667053a *src/libgit2/src/reflog.h +8d73fcd534db9107cee80f325be5b775 *src/libgit2/src/refs.c +fe0db8383e78a71b86cda32bf251f14b *src/libgit2/src/refs.h +f6bf01f5b3dd53677177e2bd65fafefd *src/libgit2/src/refspec.c +8abc5eaabe356823b31e8293d8cf14c3 *src/libgit2/src/refspec.h +e8faa7be518d29621d3fb6910bfa20cd *src/libgit2/src/remote.c +14fb488e826c5d1ef57b202430c701f2 *src/libgit2/src/remote.h bb97d27e951ecf221616baea38bacfae *src/libgit2/src/repo_template.h -76f1a3661caa4b6205290eac6176bc5e *src/libgit2/src/repository.c -129fddf4facb2d4909fdb7327fe8658f *src/libgit2/src/repository.h -8b274d2f582c683d9ebddda8ab410d60 *src/libgit2/src/reset.c -74a7d23b565b90e93f2769312ab31c0f *src/libgit2/src/revert.c -3510e587da192b292633310a2df9cf88 *src/libgit2/src/revparse.c -1deb4bfb3cb1e4649ab07aecee430c73 *src/libgit2/src/revwalk.c -c626de1b3b60f8780a04367d1fca2700 *src/libgit2/src/revwalk.h -90da43d4028174e15456d0e1199ff9c3 *src/libgit2/src/settings.c -afb843b8cbf106297300bafe4aa8a589 *src/libgit2/src/sha1_lookup.c -366ddc51c10b9a29f3baa774618c6c46 *src/libgit2/src/sha1_lookup.h -c20308f452662cf10d696381cd7faaf6 *src/libgit2/src/signature.c -bf5f8cdada3bb27e97ae004aab354c92 *src/libgit2/src/signature.h -9719c19afcfc8a3b855a0db834ff5d1c *src/libgit2/src/socket_stream.c -605c2888835f34f5f93dc3a5973789a5 *src/libgit2/src/socket_stream.h -08c03b5698d177b5791b2a82abf2ec75 *src/libgit2/src/sortedcache.c -9da4400c1a12e16ca302c6583500d65e *src/libgit2/src/sortedcache.h -11e6eb082232824f62c8d5b53671d4be *src/libgit2/src/stash.c -58c9b905ddf457353a81e467b652ef0f *src/libgit2/src/status.c -78ded62c5d54953c16f97e21d7ba74b6 *src/libgit2/src/status.h -6613f7223e8657e5daba89d24b424659 *src/libgit2/src/stransport_stream.h +2252b0ff55f9a955cb4f5f0e7352b722 *src/libgit2/src/repository.c +146fb1c5bd8dfeedd70671b6347e72a1 *src/libgit2/src/repository.h +e52ad35eb6eb5ec68ecfe514a0e20074 *src/libgit2/src/reset.c +e6db60e4d9ef4023bc6bb04d3a07770a *src/libgit2/src/revert.c +77e29b81d3eb97f4e8bdeb482fa97863 *src/libgit2/src/revparse.c +8e96881c8cf5edcf0304f094bfcd280c *src/libgit2/src/revwalk.c +cfc907b0a2796b25c1b183424209ab43 *src/libgit2/src/revwalk.h +2453702050fec6afb37d4aee39e68342 *src/libgit2/src/settings.c +35ac274f67df0fbe0f5107879b730c7f *src/libgit2/src/sha1_lookup.c +6c8400b690f4310ab2768a515f6613ea *src/libgit2/src/sha1_lookup.h +7b56e8eedfebd20ecdd3a27472d448b3 *src/libgit2/src/signature.c +ae2450a5a00b5b638983675f1f8af191 *src/libgit2/src/signature.h +ec64576765f40baad67cca336e913998 *src/libgit2/src/sortedcache.c +0a0f58dc2153dc4d9c9ae69179e070e2 *src/libgit2/src/sortedcache.h +f92de2067a48a4599ebdda9a4e599112 *src/libgit2/src/stash.c +8fd3ac6784ece39a2317fb49081d474c *src/libgit2/src/status.c +c7d4ad139216eb42b5bc1ba33798fe7c *src/libgit2/src/status.h c64427522d9f164ca9a7303467805865 *src/libgit2/src/stream.h +9bb533ce1e2846126e4e205a7b9edeb5 *src/libgit2/src/streams/curl.c +351fff940294c97159c42261367eee58 *src/libgit2/src/streams/curl.h +abe8d21f7df0f7959f6f733af784b20c *src/libgit2/src/streams/openssl.c +935c609c45c6e00915c31a1dd200dbc9 *src/libgit2/src/streams/openssl.h +b9e87e63179d994711417799d45c99ca *src/libgit2/src/streams/socket.c +ce8e433250a62a8f3acde5d842bc6467 *src/libgit2/src/streams/socket.h +c60a18b619ced0ecfc67653b4fbcd3e3 *src/libgit2/src/streams/stransport.c +613e6562fc0295bed8dd06add4a7e972 *src/libgit2/src/streams/stransport.h +4ab84442322f97d5309c02989d23de18 *src/libgit2/src/streams/tls.c +39b2b898f8244b935e8f45ef5df8edd1 *src/libgit2/src/streams/tls.h aff356b12b14da6ef64e770b5476e6c6 *src/libgit2/src/strmap.c b271b5211b8249f70d43afc08870050c *src/libgit2/src/strmap.h e273cf0b693f64646805204f59b1762b *src/libgit2/src/strnlen.h -bcfe73ead73ad4139ea091338ba53235 *src/libgit2/src/submodule.c -abf0514bacec99145cc153501dc57fab *src/libgit2/src/submodule.h -e975bbed5b81802b1236c144a92406d0 *src/libgit2/src/sysdir.c -3ec25ef8b71e46efec80e0a5e4702516 *src/libgit2/src/sysdir.h -7dc15277f63c9c1a3002eac765caade9 *src/libgit2/src/tag.c -1b05f300df73b1635c11d0b2d0cd48f5 *src/libgit2/src/tag.h -9aa69ae30a70bb16dce729436f82289e *src/libgit2/src/thread-utils.c -109ae72aea7480771dd7a3fa58737e96 *src/libgit2/src/thread-utils.h -2c1b7f858e4397c9db3e1f24d5e5f49f *src/libgit2/src/tls_stream.c -753a6a09d9d27a00d9743783c628940c *src/libgit2/src/tls_stream.h -83a755b90577b83420a61aa37d35bbbc *src/libgit2/src/trace.c -0f4240e840cc530dc0bc28627904fb7a *src/libgit2/src/trace.h -6770da804db92ac909f8905fc1773cd9 *src/libgit2/src/transaction.c +654c315d165c22aececf682aa17a5665 *src/libgit2/src/submodule.c +8c3a439055df39f8fbeb8d9b273542a2 *src/libgit2/src/submodule.h +a565ea61f51cb7c734b581b6d7e5c5da *src/libgit2/src/sysdir.c +c1258c9d76c7bd1fe54e872a665d1799 *src/libgit2/src/sysdir.h +e39aa95f334d0c2a7e0b4a0e9a9a70c1 *src/libgit2/src/tag.c +d463fd3e17d8dbc02c04137084fbef1f *src/libgit2/src/tag.h +030b10abb8406667c92256db68a368f4 *src/libgit2/src/thread-utils.c +dbc4a5c1b9611fd58c92a42a2346fa7b *src/libgit2/src/thread-utils.h +09dd08a41e85a5410f2ae190ca556320 *src/libgit2/src/trace.c +68928f563ac4e640a2353e692b363ef2 *src/libgit2/src/trace.h +cae15b1d7ec5434981a091fd33c003ca *src/libgit2/src/trailer.c +ab67b839b88bd1fdd1e05876048970ae *src/libgit2/src/transaction.c fb9e2b90a7b7e235cf9954f40f23ace1 *src/libgit2/src/transaction.h -de5c83851346583ce5ac939eb3786b7c *src/libgit2/src/transport.c -7a1846ec7c1b887b3abaf3ce640a94bd *src/libgit2/src/transports/auth.c -5ba158c1ae6d85e5f26b6c09b75df3f4 *src/libgit2/src/transports/auth.h -d363e581a3b0c6c2b54ec0023bda5bfa *src/libgit2/src/transports/auth_negotiate.h -b654d19b476354878bf2d02585513ee8 *src/libgit2/src/transports/cred.c -fe7773dd85592289e20caddf15d45a5f *src/libgit2/src/transports/cred.h -5840c57dcbb2dae0484094ca1ce47a43 *src/libgit2/src/transports/cred_helpers.c -870c29793709cf08db7656afe91c35f8 *src/libgit2/src/transports/git.c -79dd85a28793edb483b62cf3490d03e5 *src/libgit2/src/transports/http.c -1d07144f375a15e329d4e835ba417744 *src/libgit2/src/transports/local.c -5b89e3800b227d89aa0bf7f6396609ad *src/libgit2/src/transports/smart.c -92b55f6dd26e4847d87d7c1459c71c8c *src/libgit2/src/transports/smart.h +dc18892deb0544c1c4015cac70d286d9 *src/libgit2/src/transport.c +71e34e826659868173e00c6a857e0fed *src/libgit2/src/transports/auth.c +fdb53d126b76c0afdbcb44d53774635e *src/libgit2/src/transports/auth.h +c86c93bd004e26c64a745e8f5e47831a *src/libgit2/src/transports/auth_negotiate.h +47ba13039a8fa2c88048e192f56b29c2 *src/libgit2/src/transports/cred.c +6e05ac2d6c73c08fa212fce36c9c95a1 *src/libgit2/src/transports/cred.h +c3f4d5913fe0cd54a9903fb82aa02b3d *src/libgit2/src/transports/cred_helpers.c +fe8725486c6ff9958cba524ce0ef836a *src/libgit2/src/transports/git.c +69f709ea6fae8c252d458764664ccedf *src/libgit2/src/transports/http.c +21dded436e2f674a43e7d9be28bc961b *src/libgit2/src/transports/http.h +3205b0d6d5be49785bb65369e147bf16 *src/libgit2/src/transports/local.c +d49ccfdc2cb62824b495afe54f1e1ef1 *src/libgit2/src/transports/smart.c +4bbe23d4ae398e41074d7715fe989c82 *src/libgit2/src/transports/smart.h f6d4fa40c4a877e4e6910d3206fab7fe *src/libgit2/src/transports/smart_pkt.c -521316ea462eefcddb144b8b414a36a1 *src/libgit2/src/transports/smart_protocol.c -a782e79605c91a8b4c639f59784232f7 *src/libgit2/src/transports/ssh.c -0b2801d7daeaa305c7581e278459ce60 *src/libgit2/src/transports/ssh.h -fbb267f06032ee750ce84b5259cb85f5 *src/libgit2/src/transports/winhttp.c -35e770806641e3789faf50167c70227a *src/libgit2/src/tree-cache.c -e0d75a89fcad2f7ca72995fc27b5349e *src/libgit2/src/tree-cache.h -d624f616a36a50e380c811869377e962 *src/libgit2/src/tree.c -d0c0b79a3dc90b61f0d09c4529f0d826 *src/libgit2/src/tree.h -82db2013c370465326131835945ceaad *src/libgit2/src/tsort.c -0825ff56c61a04b770fc24d10671cb7d *src/libgit2/src/unix/map.c -1967122e83cd621cd410d97df662a66e *src/libgit2/src/unix/posix.h -77d02bbf29d13da8efe61e3d5b5344c8 *src/libgit2/src/unix/pthread.h -f6100e7fecad600e2af0a084433d543f *src/libgit2/src/unix/realpath.c +5e4ced491932f39614bcdf5c16cdc020 *src/libgit2/src/transports/smart_protocol.c +a3a8c99a056701a0fabf83141f20f5d5 *src/libgit2/src/transports/ssh.c +7772089c95ff23af72787dfb93e9a6b1 *src/libgit2/src/transports/ssh.h +afff5d47ead94d991426982ca5c8936c *src/libgit2/src/transports/winhttp.c +b75df82159343c5f1c164a8ffe318bd3 *src/libgit2/src/tree-cache.c +6f7ff2aa0536f676ee3b7b608dac213d *src/libgit2/src/tree-cache.h +1619571174cd735cca386f607c0090d4 *src/libgit2/src/tree.c +4454e60b6129c08effb8202ab105a3df *src/libgit2/src/tree.h +099f31bdc0f9d4ea037d9ea963bfb507 *src/libgit2/src/tsort.c +735ca5923c2f77484bf59362954958ed *src/libgit2/src/unix/map.c +28153f10345ee166792696fe661d2f74 *src/libgit2/src/unix/posix.h +44f34c426ed81b69c31e31a37433eab7 *src/libgit2/src/unix/pthread.h +3c5b85aeb3bb2d2483bc4911e688b47c *src/libgit2/src/unix/realpath.c eacd3240b2835977a4b9c7985fb8f654 *src/libgit2/src/userdiff.h -f3d53383b056c640ffd88a1d8411d3f1 *src/libgit2/src/util.c -b26533014cc7f621d2668df6ff83583b *src/libgit2/src/util.h -da1dd49cce65d13c5523ecf31a0ddac5 *src/libgit2/src/varint.c -d8f3efd0fa7aedd2fbe18a93f33e5c30 *src/libgit2/src/varint.h -86f1d401da0148bad777647c96dc9ba6 *src/libgit2/src/vector.c +36f847c7ed2fd49cd4c07792105257e3 *src/libgit2/src/util.c +179793f53a2f0ee983f24799dfa13679 *src/libgit2/src/util.h +6cff1530561052a5d4fdadf522b6b251 *src/libgit2/src/varint.c +dc74d714a3595cc232434f62a3693477 *src/libgit2/src/varint.h +be79c8c228525721fee73a7a8da54a61 *src/libgit2/src/vector.c 37c65816de87343ad7525c0c1f6421a1 *src/libgit2/src/vector.h -dfbad12c8d56e882363089cec15b0522 *src/libgit2/src/win32/dir.c -e7a4c255f92183728449619dac80b446 *src/libgit2/src/win32/dir.h -116f07ac7f52786c2dc5c3694af65a8a *src/libgit2/src/win32/error.c -f58cbe2a65925120ff9c034a472ced54 *src/libgit2/src/win32/error.h -59eb891b342451b5cded6a0f74df50fa *src/libgit2/src/win32/findfile.c -1995ceb5c4b2c80fa4150cc4f0557aee *src/libgit2/src/win32/findfile.h -3b4968c8dc94232324fa520d7b3a13b7 *src/libgit2/src/win32/git2.rc -50db817a5e11c3a6a50690385368644c *src/libgit2/src/win32/map.c -699c339639367125812063973c37e6f1 *src/libgit2/src/win32/mingw-compat.h -62b9281080c5773fe2d1b69484a98666 *src/libgit2/src/win32/msvc-compat.h -24979c2eaec2ad1997225ff05530837c *src/libgit2/src/win32/path_w32.c -349bfbd967d69e8af7db394a911dca43 *src/libgit2/src/win32/path_w32.h -2a908861b9bd980a7524aaaaa3c5d1b5 *src/libgit2/src/win32/posix.h -2264a8a2ef06ae35d9696891545f6dea *src/libgit2/src/win32/posix_w32.c -51cc80a9f3a538b3a381f45813263076 *src/libgit2/src/win32/precompiled.c -34a683f4ecb53e74bdb4b4c271260b31 *src/libgit2/src/win32/precompiled.h -c361d236a64988a91e319e50e7cca7f9 *src/libgit2/src/win32/reparse.h -782eabf429b0213f224714a2e22a7ebe *src/libgit2/src/win32/thread.h -3420a58e0ca49c26463d5c8e77860cd9 *src/libgit2/src/win32/utf-conv.c -72e68365f496d0148d6f240e74d9460c *src/libgit2/src/win32/utf-conv.h -67fe840ac3241bdcb1c001cc9cbf2f1c *src/libgit2/src/win32/version.h -36e8d49bfa816566ab57f9cdcc81fb67 *src/libgit2/src/win32/w32_buffer.c -5bb29136fc235ca83c229888fe711c1b *src/libgit2/src/win32/w32_buffer.h -827a763f46c9669f917725d69d2cb7bb *src/libgit2/src/win32/w32_util.c -0c5a3f6cdfff06b50fe179192012b43f *src/libgit2/src/win32/w32_util.h -f2208f8989e79c1e5ac2daebac0edd7c *src/libgit2/src/win32/win32-compat.h -c404320573af65371ee70c4b3b4f1527 *src/libgit2/src/worktree.c -b3bd0b3fdadc0442d11c765f52374921 *src/libgit2/src/worktree.h -afa61932bb07ff23581171e0da280522 *src/libgit2/src/xdiff/xdiff.h -cb6f5bf8f09b8fcfa13a89c2396b4373 *src/libgit2/src/xdiff/xdiffi.c -d6ef1031f57b79853a25afee1ff65c97 *src/libgit2/src/xdiff/xdiffi.h -121387bee72fcfb99662f8107d9d9d23 *src/libgit2/src/xdiff/xemit.c -44f2f06b19224c16513bc8889c403e6a *src/libgit2/src/xdiff/xemit.h -ccba9e74ed3d6aa82f78cf2715c572f1 *src/libgit2/src/xdiff/xhistogram.c -dc8be6e9d0f497cc015be9454cee7d61 *src/libgit2/src/xdiff/xinclude.h -776f5fea6750c71efd4836c2155a6b32 *src/libgit2/src/xdiff/xmacros.h -c5dc4dd4ac584cc88d1bac7405d287aa *src/libgit2/src/xdiff/xmerge.c -6ba2ee914d1acbc08a7cf7ab5b47720f *src/libgit2/src/xdiff/xpatience.c -0e98f5111d10fc56a76e5770f66fbb90 *src/libgit2/src/xdiff/xprepare.c -77ffc92820d7747f2d1b824f4082489d *src/libgit2/src/xdiff/xprepare.h -aa929d6d6d7eed92d24a3de70d6bcb5f *src/libgit2/src/xdiff/xtypes.h -5276498f73f2ce4abbf075f50e68ad98 *src/libgit2/src/xdiff/xutils.c -7ef45649869517e2d7950030368c0638 *src/libgit2/src/xdiff/xutils.h -be0c87172491341ede223b820aea16dc *src/libgit2/src/zstream.c -316c75bcf94e22ddaae9da49bcefa416 *src/libgit2/src/zstream.h +e64aa70445ecd19b71e26b2c9e0d253f *src/libgit2/src/worktree.c +2e6f7eee44be326f7049e2de8f0f5012 *src/libgit2/src/worktree.h +febd9a4cfaf0f362067bcfd37a533893 *src/libgit2/src/xdiff/xdiff.h +c191db41454b6d9e19f70ebaffa3beaf *src/libgit2/src/xdiff/xdiffi.c +d7650bda93bed570818d4420fc699ebd *src/libgit2/src/xdiff/xdiffi.h +33effe2ad82e89510f69e06d56190740 *src/libgit2/src/xdiff/xemit.c +a6f80630bd86179645cf3330edc2bfd3 *src/libgit2/src/xdiff/xemit.h +a38455ffe444af32bdb2c29917767809 *src/libgit2/src/xdiff/xhistogram.c +9a47aafe5eba86a3294e4e99343c5047 *src/libgit2/src/xdiff/xinclude.h +d591e0442d508c7d81142aa1581435b9 *src/libgit2/src/xdiff/xmacros.h +7010e76b94c89e2c0c0c5f4321c74315 *src/libgit2/src/xdiff/xmerge.c +29f20d0c45870d44715932b0b84ce771 *src/libgit2/src/xdiff/xpatience.c +8a94cb6c35c82920a2d6872a8a4c7977 *src/libgit2/src/xdiff/xprepare.c +a9726a13f78e5d5f5d8a99765d236d03 *src/libgit2/src/xdiff/xprepare.h +4be97a01eee799e84a73e1dcb9f87e40 *src/libgit2/src/xdiff/xtypes.h +d7889689a442e6af8ef4aca098be7b6a *src/libgit2/src/xdiff/xutils.c +fc55e92966e2a695b353f946684e3bf6 *src/libgit2/src/xdiff/xutils.h +7233a41fdcbb37b656f806d20728799b *src/libgit2/src/zstream.c +067bd451ea0e45f8cfda263f36145a6e *src/libgit2/src/zstream.h 87881ebd53e07c0abdce7a9e78a43201 *tests/add-force.R 80a433aad2825461db9da8b85f0c1f1a *tests/bare_repository.R -5c2b3fd22855172335b89775d061f151 *tests/blame.R -023bcd4b112384493c2682663d76f963 *tests/blob.R -3e293ea8595f2d99026d0a2bffdcc380 *tests/branch.R -750c470a9adea1e0da327b9c5a5b5d68 *tests/checkout-named-branch.R -1a645744e64d2b52daaee2de6cb30979 *tests/checkout.R -9fec8253c92d61075a83c6333cbd45e8 *tests/checkout_branch.R +9f71c9cce06888b2fb007a33338d4596 *tests/blame.R +c5dc31ffa088752bd8f2111ef9c54de8 *tests/blob.R +7b9b7226f84faa55917ab9871521c670 *tests/branch.R +2749a553090e5f07e7ad604f70159546 *tests/checkout-named-branch.R +5a72ff6961cca89187a0b0fa056e0eee *tests/checkout.R +eba6b657f63e71bfe6c4d94d5e3b12fe *tests/checkout_branch.R 09fe34acc453934e75b9768817e7af32 *tests/checkout_commit.R -28c5671cb66b1e9334a62c5662a12b8c *tests/checkout_tag.R -72937a6c85a01d9ebfc2c1b602be633d *tests/clone_bare.R -d680c9d135c6b7b24e0c98ed40b9b68e *tests/clone_branch.R -3a69a33e6282676cd8f40a43f3f9b2af *tests/clone_checkout.R -85609feaf57fd6784863387f21a6b9f6 *tests/commit.R -56e2e02f58141d953c175e9078061017 *tests/config.R -9da6057bc238916d073b7ac4896544da *tests/diff.R -941feca837ca092ab205c30fc14eaf31 *tests/fast_forward_merge.R -b600a2d43f4b7d44a09915c1fb994b28 *tests/fetch.R +a6b4986c83376cdd82cffac183413838 *tests/checkout_tag.R +b9e43c43ad5d5213348c1824e25b3639 *tests/clone_bare.R +282614650ac656fd03bfc0ccbb80176b *tests/clone_branch.R +d4bfe766611709e4b4023c5d58fb08de *tests/clone_checkout.R +6ddec5cbd1dfb383a14aa583ee38e1fc *tests/commit.R +665a438c9b7bae434611a7e0969b97c4 *tests/config.R +baa836e7764b26a0302b17eb4f26e084 *tests/diff.R +38ccd937c424fb717d8d60b516d9d63a *tests/fast_forward_merge.R +c50bccd6d75c0c41d0c4675ab91d0adf *tests/fetch.R 51077ba2b00401d7079aa48157dbd84f *tests/graph.R 90f82360abcbe79150a0d89e1df4c491 *tests/index.R d7e41a80c0764fa136606df680a1d042 *tests/invalid-conf-var.R -0a1c9ee5231b6082f500fcced2b5f6c1 *tests/libgit2.R -9171ad34b297419fb2ef01ad0b4a7b32 *tests/merge.R -ea1fb08e8f15710f502e48849b8a40f0 *tests/merge_named_branch.R -547a85a04e64c72412b622a18dc5c7ba *tests/normal_merge.R -3ff27b239118cae160ca21c323a30d54 *tests/note.R +ca7cd1f49a01091d3ebc34620cc81f7a *tests/libgit2.R +f8d18caedf4a44eec497eb9f593b7198 *tests/merge.R +a38e0dcb8423e25538a83f2bd787903a *tests/merge_named_branch.R +49a5a7923218743af4b8a9bac2a2dba7 *tests/normal_merge.R +534160bf29408e9b4e26322602062236 *tests/note.R bc7ac89ea036a56ecb8d0cfa7b57e56c *tests/odb_blobs.R -5749b7c3bc945394fcee1250f624ca76 *tests/pre-process-path.R -db68ddc87e208712eaa90b157f4cf31d *tests/pull.R -3d010b52c0e66f923edfdb012d38ad16 *tests/push-force.R -678c59ad904048800ebd8df4c22452ab *tests/push.R +ee4a54051492a4e184bad2032766e6b8 *tests/pre-process-path.R +4eee9b325113e7c78830e3be3b58a018 *tests/pull.R +f55b8c815aabf20442064c9a8b6793c6 *tests/push-force.R +b9249d2ce1d5a09bbdf0e0373cfcde40 *tests/push.R 7a8b2af4ba3ebce271d4da76e5138c27 *tests/reference.R -a6482678546d8c773c8b80c9bdd01b31 *tests/reflog.R +95076b13556d16c16665a6f37e93efd0 *tests/reflog.R 553445219946986a8558903ee574cdd9 *tests/refspec.R dad5c0cb24ccc25715568e8f0ec8e439 *tests/remotes.R -df7a536d3da3eafc5c7199343468956e *tests/remove.R -5a8f9df8afe9aede76f18f74c09e1ef1 *tests/repository.R +cc70ad44490be5ca474470f293c67a62 *tests/remove.R +00593368be128f7ac2372b810b8b6a99 *tests/repository.R 461bf682dd7caa5e49721ff3aaef219f *tests/reset.R -b3d0759d15d449b98723084be39f9537 *tests/revparse.R -9c7033e91827825c5e2d3fbc2bf7e86d *tests/signature.R -3c4b299bc927d3e1fc20f3b00c55b755 *tests/stash.R +508f9eb9d2f99a527f622e14003eb407 *tests/revparse.R +d08135a3127725bd2c325b6402acba41 *tests/signature.R +3fe6aa731b4820c4a33a2960fa65a07e *tests/stash.R 9ca0cf8d2b8040c988eab40dd1ed3f7c *tests/status.R -752649dd2724132a15701cc11b273813 *tests/tag.R -938d99f1c5d7dde02b61471769c28044 *tests/time.R -4332db3cb4d0d78310c254b62f03be7f *tests/tree.R -7a415b884d773ca3cb168ab1ece971bc *tests/when.R +53e67bb1468943e1ec9ce38639bed1c2 *tests/tag.R +ddf30d8d3db5d1141fd52d5a4d39db1a *tests/time.R +608126ec0fe375df9fea21ac2871e05a *tests/tree.R +a9fce33288a9275f333f93a3bf7a8eed *tests/when.R c53118f6682ac1db40935d5705145d5a *tools/config.guess e768d6a5b46753aeb6800eefb4b2540e *tools/config.sub f6b34e2198c1cf50c8038f5704f664c4 *tools/install-sh 39863e129e88b53ba61340e53ad595b1 *tools/libcurl.m4 f56e89fee26d40334bb9a1474895b187 *tools/missing -990aca077ab65fa1addaf7f3470aa7f0 *tools/winlibs.R +186c8d7e226ddbba6f2c082b3af852f3 *tools/version.c +327f451d66fbab809bb322e0e1bac006 *tools/winlibs.R diff -Nru r-cran-git2r-0.21.0/NAMESPACE r-cran-git2r-0.22.1/NAMESPACE --- r-cran-git2r-0.21.0/NAMESPACE 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/NAMESPACE 2018-07-01 21:27:25.000000000 +0000 @@ -1,135 +1,165 @@ # Generated by roxygen2: do not edit by hand +S3method("[",git_tree) +S3method(as.POSIXct,git_time) +S3method(as.character,git_time) +S3method(as.data.frame,git_commit) +S3method(as.data.frame,git_repository) +S3method(as.data.frame,git_tree) +S3method(as.list,git_tree) +S3method(diff,git_repository) +S3method(diff,git_tree) +S3method(format,git_blob) +S3method(format,git_commit) +S3method(format,git_merge_result) +S3method(format,git_note) +S3method(format,git_signature) +S3method(format,git_tag) +S3method(head,git_repository) +S3method(length,git_blob) +S3method(length,git_diff) +S3method(length,git_tree) +S3method(merge,character) +S3method(merge,git_branch) +S3method(merge,git_repository) +S3method(plot,git_repository) +S3method(print,git_blob) +S3method(print,git_branch) +S3method(print,git_commit) S3method(print,git_config) +S3method(print,git_diff) +S3method(print,git_merge_result) +S3method(print,git_note) +S3method(print,git_reference) S3method(print,git_reflog) +S3method(print,git_reflog_entry) +S3method(print,git_repository) +S3method(print,git_signature) S3method(print,git_status) +S3method(print,git_tag) +S3method(print,git_time) +S3method(print,git_tree) +S3method(sha,git_blob) +S3method(sha,git_branch) +S3method(sha,git_commit) +S3method(sha,git_fetch_head) +S3method(sha,git_merge_result) +S3method(sha,git_note) +S3method(sha,git_reference) +S3method(sha,git_reflog_entry) +S3method(sha,git_tag) +S3method(sha,git_tree) +S3method(summary,git_commit) +S3method(summary,git_diff) +S3method(summary,git_repository) +S3method(summary,git_stash) +S3method(summary,git_tag) +S3method(summary,git_tree) +export(add) +export(ahead_behind) +export(as.data.frame) +export(blame) +export(blob_create) +export(branch_create) +export(branch_delete) +export(branch_get_upstream) +export(branch_remote_name) +export(branch_remote_url) +export(branch_rename) +export(branch_set_upstream) +export(branch_target) +export(branches) +export(bundle_r_package) +export(checkout) +export(clone) +export(commit) +export(commits) export(config) +export(content) +export(contributions) +export(cred_env) export(cred_ssh_key) export(cred_token) +export(cred_user_pass) +export(default_signature) +export(descendant_of) +export(diff) +export(discover_repository) +export(fetch) +export(fetch_heads) +export(git_config_files) +export(hash) +export(hashfile) +export(head) +export(in_repository) +export(index_remove_bypath) +export(init) +export(is_bare) +export(is_binary) export(is_blob) export(is_branch) export(is_commit) +export(is_detached) +export(is_empty) +export(is_head) +export(is_local) +export(is_merge) +export(is_shallow) +export(is_tree) +export(last_commit) export(libgit2_features) -export(libgit2_sha) export(libgit2_version) +export(lookup) +export(ls_tree) +export(merge) +export(merge_base) +export(note_create) +export(note_default_ref) +export(note_remove) +export(notes) +export(odb_blobs) +export(odb_objects) +export(parents) +export(pull) export(punch_card) +export(push) +export(references) +export(reflog) +export(remote_add) export(remote_ls) +export(remote_remove) +export(remote_rename) +export(remote_set_url) +export(remote_url) +export(remotes) +export(repository) +export(repository_head) +export(reset) +export(revparse_single) +export(rm_file) +export(sha) +export(ssh_path) export(ssl_cert_locations) -exportClasses(cred_env) -exportClasses(cred_ssh_key) -exportClasses(cred_token) -exportClasses(cred_user_pass) -exportClasses(git_blame) -exportClasses(git_blame_hunk) -exportClasses(git_blob) -exportClasses(git_branch) -exportClasses(git_commit) -exportClasses(git_diff) -exportClasses(git_diff_file) -exportClasses(git_diff_hunk) -exportClasses(git_diff_line) -exportClasses(git_fetch_head) -exportClasses(git_merge_result) -exportClasses(git_note) -exportClasses(git_reference) -exportClasses(git_reflog_entry) -exportClasses(git_repository) -exportClasses(git_signature) -exportClasses(git_stash) -exportClasses(git_tag) -exportClasses(git_time) -exportClasses(git_transfer_progress) -exportClasses(git_tree) -exportMethods("[") -exportMethods(add) -exportMethods(ahead_behind) -exportMethods(blame) -exportMethods(blob_create) -exportMethods(branch_create) -exportMethods(branch_delete) -exportMethods(branch_get_upstream) -exportMethods(branch_remote_name) -exportMethods(branch_remote_url) -exportMethods(branch_rename) -exportMethods(branch_set_upstream) -exportMethods(branch_target) -exportMethods(branches) -exportMethods(bundle_r_package) -exportMethods(checkout) -exportMethods(clone) -exportMethods(commit) -exportMethods(commits) -exportMethods(content) -exportMethods(contributions) -exportMethods(cred_env) -exportMethods(cred_user_pass) -exportMethods(default_signature) -exportMethods(descendant_of) -exportMethods(diff) -exportMethods(discover_repository) -exportMethods(fetch) -exportMethods(fetch_heads) -exportMethods(hash) -exportMethods(hashfile) -exportMethods(head) -exportMethods(in_repository) -exportMethods(index_remove_bypath) -exportMethods(init) -exportMethods(is_bare) -exportMethods(is_binary) -exportMethods(is_detached) -exportMethods(is_empty) -exportMethods(is_head) -exportMethods(is_local) -exportMethods(is_merge) -exportMethods(is_shallow) -exportMethods(length) -exportMethods(lookup) -exportMethods(merge) -exportMethods(merge_base) -exportMethods(note_create) -exportMethods(note_default_ref) -exportMethods(note_remove) -exportMethods(notes) -exportMethods(odb_blobs) -exportMethods(odb_objects) -exportMethods(parents) -exportMethods(plot) -exportMethods(pull) -exportMethods(punch_card) -exportMethods(push) -exportMethods(references) -exportMethods(reflog) -exportMethods(remote_add) -exportMethods(remote_ls) -exportMethods(remote_remove) -exportMethods(remote_rename) -exportMethods(remote_set_url) -exportMethods(remote_url) -exportMethods(remotes) -exportMethods(repository) -exportMethods(reset) -exportMethods(revparse_single) -exportMethods(rm_file) -exportMethods(show) -exportMethods(stash) -exportMethods(stash_drop) -exportMethods(stash_list) -exportMethods(status) -exportMethods(summary) -exportMethods(tag) -exportMethods(tag_delete) -exportMethods(tags) -exportMethods(tree) -exportMethods(when) -exportMethods(workdir) -import(methods) +export(stash) +export(stash_apply) +export(stash_drop) +export(stash_list) +export(stash_pop) +export(status) +export(tag) +export(tag_delete) +export(tags) +export(tree) +export(when) +export(workdir) importFrom(graphics,axis) importFrom(graphics,barplot) importFrom(graphics,par) importFrom(graphics,plot.new) importFrom(graphics,plot.window) importFrom(graphics,symbols) +importFrom(graphics,title) importFrom(utils,capture.output) +importFrom(utils,head) importFrom(utils,sessionInfo) useDynLib(git2r, .registration=TRUE) diff -Nru r-cran-git2r-0.21.0/NEWS r-cran-git2r-0.22.1/NEWS --- r-cran-git2r-0.21.0/NEWS 2018-01-03 21:26:45.000000000 +0000 +++ r-cran-git2r-0.22.1/NEWS 2018-07-09 21:44:24.000000000 +0000 @@ -1,3 +1,53 @@ +git2r 0.22.1 +------------ + +NEW FEATURES + +* Added the 'git_config_files' method to locate configuration files. + +* Added the 'stash_pop' method to apply a single stashed state from + the stash list and remove it from the list if successful. + +* Added the 'stash_apply' method to apply a single stashed state from + the stash list. + +IMPROVEMENTS + +* Updated the bundled libgit2 source code to v0.27.2 (8d36dc6). + +* git2r can now build against a system installation of libgit2 + (Elliott Sales de Andrade in PR #345, #344 and #336). + +* Refactoring of the configuration scripts to use a prebuilt libgit2 + on macOS and Windows (Thanks Jeroen). + +* Ensure that git2r writes the config file to the correct location on + Windows (John Blischak in PR #320). + +* Better default location to find ssh keys in 'cred_ssh_key()' (Ian + Lyttle in PR #317). + +BUG FIXES + +* If a merge results in no change, the returned 'git_merge_result' now returns + 'FALSE' for 'fast_forward' and 'conflicts' and 'NA' for 'sha'. Previously it + returned 'logical(0)' for 'fast_forward' and 'conflicts' and 'character(0)' + for 'sha'. + +BREAKING CHANGES + +* Changed from S4 classes to S3 classes to simplify the design and + facilitate future development. + +* Removed the trailing slash from the directory name when reporting + repository path or workdir. + +* Removed the 'libgit2_sha' method. Use the 'libgit2_version' method + instead. + +* Changed the 'stash_drop' argument 'index' from zero-based to + one-based i.e. use index = 1 to drop the first stash. + git2r 0.21.0 ------------ diff -Nru r-cran-git2r-0.21.0/R/blame.r r-cran-git2r-0.22.1/R/blame.r --- r-cran-git2r-0.21.0/R/blame.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/blame.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Get blame for file -##' -##' @rdname blame-methods -##' @docType methods -##' @param repo The repository -##' @param path Path to the file to consider -##' @return S4 class git_blame object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a first user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create a second user and change the file -##' config(repo, user.name="Bob", user.email="bob@@example.org") -##' writeLines(c("Hello world!", "HELLO WORLD!", "HOLA"), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Second commit message") -##' -##' ## Check blame -##' blame(repo, "example.txt") -##' } -setGeneric("blame", - signature = c("repo", "path"), - function(repo, - path) - standardGeneric("blame")) - -##' @rdname blame-methods -##' @export -setMethod("blame", - signature(repo = "git_repository", - path = "character"), - function(repo, - path) - { - .Call(git2r_blame_file, repo, path) - } -) diff -Nru r-cran-git2r-0.21.0/R/blame.R r-cran-git2r-0.22.1/R/blame.R --- r-cran-git2r-0.21.0/R/blame.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/blame.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,95 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Get blame for file +##' +##' @template repo-param +##' @param path Path to the file to consider +##' @return git_blame object with the following entries: +##' \describe{ +##' \item{path}{ +##' The path to the file of the blame +##' } +##' \item{hunks}{ +##' List of blame hunks +##' } +##' \item{repo}{ +##' The git_repository that contains the file +##' } +##' } +##' \describe{ +##' \item{lines_in_hunk}{ +##' The number of lines in this hunk +##' } +##' \item{final_commit_id}{ +##' The sha of the commit where this line was last changed +##' } +##' \item{final_start_line_number}{ +##' The 1-based line number where this hunk begins, in the final +##' version of the file +##' } +##' \item{final_signature}{ +##' Final committer +##' } +##' \item{orig_commit_id}{ +##' The sha of the commit where this hunk was found. This will usually +##' be the same as 'final_commit_id'. +##' } +##' \item{orig_start_line_number}{ +##' The 1-based line number where this hunk begins in the file +##' named by 'orig_path' in the commit specified by 'orig_commit_id'. +##' } +##' \item{orig_signature}{ +##' Origin committer +##' } +##' \item{orig_path}{ +##' The path to the file where this hunk originated, as of the commit +##' specified by 'orig_commit_id' +##' } +##' \item{boundary}{ +##' TRUE iff the hunk has been tracked to a boundary commit. +##' } +##' \item{repo}{ +##' The \code{git_repository} object that contains the blame hunk +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a first user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Create a second user and change the file +##' config(repo, user.name="Bob", user.email="bob@@example.org") +##' writeLines(c("Hello world!", "HELLO WORLD!", "HOLA"), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Second commit message") +##' +##' ## Check blame +##' blame(repo, "example.txt") +##' } +blame <- function(repo = ".", path = NULL) { + .Call(git2r_blame_file, lookup_repository(repo), path) +} diff -Nru r-cran-git2r-0.21.0/R/blob.r r-cran-git2r-0.22.1/R/blob.r --- r-cran-git2r-0.21.0/R/blob.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/blob.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,382 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Create blob from file on disk -##' -##' Read a file from the filesystem and write its content to the -##' Object Database as a loose blob. The method is vectorized and -##' accepts a vector of files to create blobs from. -##' @rdname blob_create-methods -##' @docType methods -##' @param repo The repository where the blob(s) will be written. Can -##' be a bare repository. -##' @param path The file(s) from which the blob will be created. -##' @param relative TRUE if the file(s) from which the blob will be -##' created is relative to the repository's working dir. Default is -##' TRUE. -##' @return list of S4 class git_blob \code{objects} -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create blobs from files relative to workdir -##' writeLines("Hello, world!", file.path(path, "example-1.txt")) -##' writeLines("test content", file.path(path, "example-2.txt")) -##' blob_list_1 <- blob_create(repo, c("example-1.txt", -##' "example-2.txt")) -##' -##' ## Create blobs from files not relative to workdir -##' temp_file_1 <- tempfile() -##' temp_file_2 <- tempfile() -##' writeLines("Hello, world!", temp_file_1) -##' writeLines("test content", temp_file_2) -##' blob_list_2 <- blob_create(repo, c(temp_file_1, temp_file_2), relative = FALSE) -##' } -setGeneric("blob_create", - signature = c("repo", "path"), - function(repo, path, relative = TRUE) - standardGeneric("blob_create")) - -##' @rdname blob_create-methods -##' @export -setMethod("blob_create", - signature(repo = "git_repository", - path = "character"), - function(repo, path, relative) - { - ## Argument checking - stopifnot(is.logical(relative), - identical(length(relative), 1L)) - - if (relative) { - result <- .Call(git2r_blob_create_fromworkdir, - repo, - path) - } else { - path <- normalizePath(path, mustWork = TRUE) - result <- .Call(git2r_blob_create_fromdisk, - repo, - path) - } - - result - } -) - -##' Content of blob -##' -##' @rdname content-methods -##' @docType methods -##' @param blob The blob \code{object}. -##' @param split Split blob content to text lines. Default TRUE. -##' @return The content of the blob. NA_character_ if the blob is binary. -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Display content of blob. -##' content(tree(commits(repo)[[1]])["example.txt"]) -##' } -setGeneric("content", - signature = "blob", - function(blob, - split = TRUE) - standardGeneric("content")) - -##' @rdname content-methods -##' @export -setMethod("content", - signature(blob = "git_blob"), - function(blob, split) - { - if (is_binary(blob)) - return(NA_character_) - - ret <- .Call(git2r_blob_content, blob) - if (isTRUE(split)) - ret <- strsplit(ret, "\n")[[1]] - ret - } -) - -##' Determine the sha from a blob string -##' -##' The blob is not written to the object database. -##' @rdname hash-methods -##' @docType methods -##' @param data The string vector to hash. -##' @return A string vector with the sha for each string in data. -##' @keywords methods -##' @examples -##' \dontrun{ -##' identical(hash(c("Hello, world!\n", -##' "test content\n")), -##' c("af5626b4a114abcb82d63db7c8082c3c4756e51b", -##' "d670460b4b4aece5915caf5c68d12f560a9fe3e4")) -##' } -setGeneric("hash", - signature = "data", - function(data) - standardGeneric("hash")) - -##' @rdname hash-methods -##' @export -setMethod("hash", - signature(data = "character"), - function(data) - { - .Call(git2r_odb_hash, data) - } -) - -##' Determine the sha from a blob in a file -##' -##' The blob is not written to the object database. -##' @rdname hashfile-methods -##' @docType methods -##' @param path The path vector with files to hash. -##' @return A vector with the sha for each file in path. -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create a file. NOTE: The line endings from writeLines gives -##' ## LF (line feed) on Unix/Linux and CRLF (carriage return, line feed) -##' ## on Windows. The example use writeChar to have more control. -##' path <- tempfile() -##' f <- file(path, "wb") -##' writeChar("Hello, world!\n", f, eos = NULL) -##' close(f) -##' -##' ## Generate hash -##' hashfile(path) -##' identical(hashfile(path), hash("Hello, world!\n")) -##' } -setGeneric("hashfile", - signature = "path", - function(path) - standardGeneric("hashfile")) - -##' @rdname hashfile-methods -##' @export -setMethod("hashfile", - signature(path = "character"), - function(path) - { - path <- normalizePath(path, mustWork = TRUE) - .Call(git2r_odb_hashfile, path) - } -) - -##' Is blob binary -##' -##' @rdname is_binary-methods -##' @docType methods -##' @param blob The blob \code{object}. -##' @return TRUE if binary data, FALSE if not. -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' -##' ## Check if binary -##' b_text <- tree(commit_1)["example.txt"] -##' is_binary(b_text) -##' -##' ## Commit plot file (binary) -##' x <- 1:100 -##' y <- x^2 -##' png(file.path(path, "plot.png")) -##' plot(y ~ x, type = "l") -##' dev.off() -##' add(repo, "plot.png") -##' commit_2 <- commit(repo, "Second commit message") -##' -##' ## Check if binary -##' b_png <- tree(commit_2)["plot.png"] -##' is_binary(b_png) -##' } -setGeneric("is_binary", - signature = "blob", - function(blob) - standardGeneric("is_binary")) - -##' @rdname is_binary-methods -##' @export -setMethod("is_binary", - signature(blob = "git_blob"), - function(blob) - { - .Call(git2r_blob_is_binary, blob) - } -) - -##' Check if object is S4 class git_blob -##' -##' @param object Check if object is S4 class git_blob -##' @return TRUE if object is S4 class git_blob, else FALSE -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' blob_1 <- tree(commit_1)["example.txt"] -##' -##' ## Check if blob -##' is_blob(commit_1) -##' is_blob(blob_1) -##' } -is_blob <- function(object) { - is(object = object, class2 = "git_blob") -} - -##' Size in bytes of the contents of a blob -##' -##' @docType methods -##' @param x The blob \code{object} -##' @return a non-negative integer -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' blob_1 <- tree(commit_1)["example.txt"] -##' -##' ## Get length in size of bytes of the content of the blob -##' length(blob_1) -##' } -setMethod("length", - signature(x = "git_blob"), - function(x) - { - .Call(git2r_blob_rawsize, x) - } -) - -##' Brief summary of blob -##' -##' @aliases show,git_blob-methods -##' @docType methods -##' @param object The blob \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Brief summary of the blob in the repository -##' tree(commits(repo)[[1]])["example.txt"] -##' } -setMethod("show", - signature(object = "git_blob"), - function(object) - { - cat(sprintf("blob: %s\n", object@sha)) - } -) - -##' Summary of blob -##' -##' @docType methods -##' @param object The blob \code{object} -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' blob_1 <- tree(commit_1)["example.txt"] -##' -##' ## Get summary of the blob -##' summary(blob_1) -##' } -setMethod("summary", - signature(object = "git_blob"), - function(object, ...) - { - cat(sprintf("blob: %s\nsize: %i bytes\n", - object@sha, - length(object))) - } -) diff -Nru r-cran-git2r-0.21.0/R/blob.R r-cran-git2r-0.22.1/R/blob.R --- r-cran-git2r-0.21.0/R/blob.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/blob.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,241 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Create blob from file on disk +##' +##' Read a file from the filesystem and write its content to the +##' Object Database as a loose blob. The method is vectorized and +##' accepts a vector of files to create blobs from. +##' @param repo The repository where the blob(s) will be written. Can +##' be a bare repository. A \code{git_repository} object, or a +##' path to a repository, or \code{NULL}. If the \code{repo} +##' argument is \code{NULL}, the repository is searched for with +##' \code{\link{discover_repository}} in the current working +##' directory. +##' @param path The file(s) from which the blob will be created. +##' @param relative TRUE if the file(s) from which the blob will be +##' created is relative to the repository's working dir. Default +##' is TRUE. +##' @return list of S3 class git_blob \code{objects} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create blobs from files relative to workdir +##' writeLines("Hello, world!", file.path(path, "example-1.txt")) +##' writeLines("test content", file.path(path, "example-2.txt")) +##' blob_list_1 <- blob_create(repo, c("example-1.txt", +##' "example-2.txt")) +##' +##' ## Create blobs from files not relative to workdir +##' temp_file_1 <- tempfile() +##' temp_file_2 <- tempfile() +##' writeLines("Hello, world!", temp_file_1) +##' writeLines("test content", temp_file_2) +##' blob_list_2 <- blob_create(repo, c(temp_file_1, temp_file_2), relative = FALSE) +##' } +blob_create <- function(repo = ".", path = NULL, relative = TRUE) { + repo <- lookup_repository(repo) + if (isTRUE(relative)) + return(.Call(git2r_blob_create_fromworkdir, repo, path)) + path <- normalizePath(path, mustWork = TRUE) + .Call(git2r_blob_create_fromdisk, repo, path) +} + +##' Content of blob +##' +##' @param blob The blob object. +##' @param split Split blob content to text lines. Default TRUE. +##' @return The content of the blob. NA_character_ if the blob is binary. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Display content of blob. +##' content(tree(commits(repo)[[1]])["example.txt"]) +##' } +content <- function(blob = NULL, split = TRUE) { + if (is_binary(blob)) + return(NA_character_) + + ret <- .Call(git2r_blob_content, blob) + if (isTRUE(split)) + ret <- strsplit(ret, "\n")[[1]] + ret +} + +##' Determine the sha from a blob string +##' +##' The blob is not written to the object database. +##' @param data The string vector to hash. +##' @return A string vector with the sha for each string in data. +##' @export +##' @examples +##' \dontrun{ +##' identical(hash(c("Hello, world!\n", +##' "test content\n")), +##' c("af5626b4a114abcb82d63db7c8082c3c4756e51b", +##' "d670460b4b4aece5915caf5c68d12f560a9fe3e4")) +##' } +hash <- function(data = NULL) { + .Call(git2r_odb_hash, data) +} + +##' Determine the sha from a blob in a file +##' +##' The blob is not written to the object database. +##' @param path The path vector with files to hash. +##' @return A vector with the sha for each file in path. +##' @export +##' @examples +##' \dontrun{ +##' ## Create a file. NOTE: The line endings from writeLines gives +##' ## LF (line feed) on Unix/Linux and CRLF (carriage return, line feed) +##' ## on Windows. The example use writeChar to have more control. +##' path <- tempfile() +##' f <- file(path, "wb") +##' writeChar("Hello, world!\n", f, eos = NULL) +##' close(f) +##' +##' ## Generate hash +##' hashfile(path) +##' identical(hashfile(path), hash("Hello, world!\n")) +##' } +hashfile <- function(path = NULL) { + .Call(git2r_odb_hashfile, normalizePath(path, mustWork = TRUE)) +} + +##' Is blob binary +##' +##' @param blob The blob \code{object}. +##' @return TRUE if binary data, FALSE if not. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' +##' ## Check if binary +##' b_text <- tree(commit_1)["example.txt"] +##' is_binary(b_text) +##' +##' ## Commit plot file (binary) +##' x <- 1:100 +##' y <- x^2 +##' png(file.path(path, "plot.png")) +##' plot(y ~ x, type = "l") +##' dev.off() +##' add(repo, "plot.png") +##' commit_2 <- commit(repo, "Second commit message") +##' +##' ## Check if binary +##' b_png <- tree(commit_2)["plot.png"] +##' is_binary(b_png) +##' } +is_binary <- function(blob = NULL) { + .Call(git2r_blob_is_binary, blob) +} + +##' Check if object is S3 class git_blob +##' +##' @param object Check if object is S3 class git_blob +##' @return TRUE if object is S3 class git_blob, else FALSE +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' blob_1 <- tree(commit_1)["example.txt"] +##' +##' ## Check if blob +##' is_blob(commit_1) +##' is_blob(blob_1) +##' } +is_blob <- function(object) { + inherits(object, "git_blob") +} + +##' Size in bytes of the contents of a blob +##' +##' @param x The blob \code{object} +##' @return a non-negative integer +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' blob_1 <- tree(commit_1)["example.txt"] +##' +##' ## Get length in size of bytes of the content of the blob +##' length(blob_1) +##' } +length.git_blob <- function(x) { + .Call(git2r_blob_rawsize, x) +} + +##' @export +format.git_blob <- function(x, ...) { + sprintf("blob: %s\nsize: %i bytes", x$sha, length(x)) +} + +##' @export +print.git_blob <- function(x, ...) { + cat(format(x, ...), "\n", sep = "") +} diff -Nru r-cran-git2r-0.21.0/R/branch.r r-cran-git2r-0.22.1/R/branch.r --- r-cran-git2r-0.21.0/R/branch.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/branch.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,668 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Create a branch -##' -##' @rdname branch_create-methods -##' @docType methods -##' @param commit Commit to which branch should point. -##' @param name Name for the branch -##' @param force Overwrite existing branch. Default = FALSE -##' @return invisible S4 class git_branch object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' -##' ## Create a branch -##' branch_1 <- branch_create(commit_1, name = "test-branch") -##' -##' ## Add one more commit -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_2 <- commit(repo, "Another commit message") -##' -##' ## Create a branch with the same name should fail -##' try(branch_create(commit_2, name = "test-branch"), TRUE) -##' -##' ## Force it -##' branch_2 <- branch_create(commit_2, name = "test-branch", force = TRUE) -##' } -setGeneric("branch_create", - signature = "commit", - function(commit, name, force = FALSE) - standardGeneric("branch_create")) - -##' @rdname branch_create-methods -##' @export -setMethod("branch_create", - signature = "git_commit", - function(commit, name, force) - { - invisible(.Call(git2r_branch_create, name, commit, force)) - } -) - -##' Delete a branch -##' -##' @rdname branch_delete-methods -##' @docType methods -##' @param branch The branch -##' @return invisible NULL -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' -##' ## Create a 'dev' branch -##' dev <- branch_create(commit_1, name = "dev") -##' branches(repo) -##' -##' ## Delete 'dev' branch -##' branch_delete(dev) -##' branches(repo) -##' } -setGeneric("branch_delete", - signature = "branch", - function(branch) - standardGeneric("branch_delete")) - -##' @rdname branch_delete-methods -##' @export -setMethod("branch_delete", - signature = "git_branch", - function(branch) - { - invisible(.Call(git2r_branch_delete, branch)) - } -) - -##' Remote name of a branch -##' -##' The name of remote that the remote tracking branch belongs to -##' @rdname branch_remote_name-methods -##' @docType methods -##' @param branch The branch -##' @return character string with remote name -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize two temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## Get remote name -##' branch_remote_name(branches(repo)[[2]]) -##' } -setGeneric("branch_remote_name", - signature = "branch", - function(branch) - standardGeneric("branch_remote_name")) - -##' @rdname branch_remote_name-methods -##' @export -setMethod("branch_remote_name", - signature = "git_branch", - function(branch) - { - .Call(git2r_branch_remote_name, branch) - } -) - -##' Remote url of a branch -##' -##' @rdname branch_remote_url-methods -##' @docType methods -##' @param branch The branch -##' @return character string with remote url -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize two temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## Get remote url of tracking branch to branch 'master' -##' branch_remote_url(branch_get_upstream(head(repo))) -##' } -setGeneric("branch_remote_url", - signature = "branch", - function(branch) - standardGeneric("branch_remote_url")) - -##' @rdname branch_remote_url-methods -##' @export -setMethod("branch_remote_url", - signature = "git_branch", - function(branch) - { - .Call(git2r_branch_remote_url, branch) - } -) - -##' Rename a branch -##' -##' @rdname branch_rename-methods -##' @docType methods -##' @param branch Branch to rename -##' @param name The new name for the branch -##' @param force Overwrite existing branch. Default is FALSE -##' @return invisible renamed S4 class git_branch -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Rename 'master' branch to 'dev' -##' branches(repo) -##' branch_rename(head(repo), "dev") -##' branches(repo) -##' } -setGeneric("branch_rename", - signature = "branch", - function(branch, name, force = FALSE) - standardGeneric("branch_rename")) - -##' @rdname branch_rename-methods -##' @export -setMethod("branch_rename", - signature = "git_branch", - function(branch, name, force) - { - invisible(.Call(git2r_branch_rename, branch, name, force)) - } -) - -##' Get target (sha) pointed to by a branch -##' -##' @rdname branch_target-methods -##' @docType methods -##' @param branch The branch -##' @return sha or NA if not a direct reference -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Get target (sha) pointed to by 'master' branch -##' branch_target(head(repo)) -##' } -setGeneric("branch_target", - signature = "branch", - function(branch) - standardGeneric("branch_target")) - -##' @rdname branch_target-methods -##' @export -setMethod("branch_target", - signature = "git_branch", - function(branch) - { - .Call(git2r_branch_target, branch) - } -) - -##' Get remote tracking branch -##' -##' Get remote tracking branch, given a local branch. -##' @rdname branch_get_upstream-methods -##' @docType methods -##' @param branch The branch -##' @return S4 class git_branch or NULL if no remote tracking branch. -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize two temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## Get remote tracking branch -##' branch_get_upstream(head(repo)) -##' } -setGeneric("branch_get_upstream", - signature = "branch", - function(branch) - standardGeneric("branch_get_upstream")) - -##' @rdname branch_get_upstream-methods -##' @export -setMethod("branch_get_upstream", - signature = "git_branch", - function(branch) - { - .Call(git2r_branch_get_upstream, branch) - } -) - -##' Set remote tracking branch -##' -##' Set the upstream configuration for a given local branch -##' @rdname branch_set_upstream-methods -##' @docType methods -##' @param branch The branch to configure -##' @param name remote-tracking or local branch to set as -##' upstream. Pass NULL to unset. -##' @return invisible NULL -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize two temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## Unset remote remote tracking branch -##' branch_get_upstream(head(repo)) -##' branch_set_upstream(head(repo), NULL) -##' branch_get_upstream(head(repo)) -##' -##' ## Set remote tracking branch -##' branch_set_upstream(head(repo), "origin/master") -##' branch_get_upstream(head(repo)) -##' } -setGeneric("branch_set_upstream", - signature = "branch", - function(branch, name) - standardGeneric("branch_set_upstream")) - -##' @rdname branch_set_upstream-methods -##' @export -setMethod("branch_set_upstream", - signature(branch = "git_branch"), - function(branch, name) - { - if (missing(name)) { - stop("Missing argument name") - } - invisible(.Call(git2r_branch_set_upstream, branch, name)) - } -) - -##' Branches -##' -##' List branches in repository -##' @rdname branches-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @param flags Filtering flags for the branch listing. Valid values -##' are 'all', 'local' or 'remote' -##' @return list of branches in repository -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config first user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## List branches -##' branches(repo) -##' } -setGeneric("branches", - signature = "repo", - function(repo, flags=c("all", "local", "remote")) - standardGeneric("branches")) - -##' @rdname branches-methods -##' @export -setMethod("branches", - signature(repo = "missing"), - function(flags) - { - callGeneric(repo = lookup_repository(), flags = flags) - } -) - -##' @rdname branches-methods -##' @export -setMethod("branches", - signature(repo = "git_repository"), - function(repo, flags) - { - flags <- switch(match.arg(flags), - local = 1L, - remote = 2L, - all = 3L) - - .Call(git2r_branch_list, repo, flags) - } -) - -##' Check if branch is head -##' -##' @rdname is_head-methods -##' @docType methods -##' @param branch The branch \code{object} to check if it's head -##' @return TRUE if branch is head, else FALSE -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## List branches -##' branches(repo) -##' -##' ## Check that 'master' is_head -##' master <- branches(repo)[[1]] -##' is_head(master) -##' -##' ## Create and checkout 'dev' branch -##' checkout(repo, "dev", create = TRUE) -##' -##' ## List branches -##' branches(repo) -##' -##' ## Check that 'master' is no longer head -##' is_head(master) -##' } -setGeneric("is_head", - signature = "branch", - function(branch) - standardGeneric("is_head")) - -##' @rdname is_head-methods -##' @export -setMethod("is_head", - signature(branch = "git_branch"), - function(branch) - { - .Call(git2r_branch_is_head, branch) - } -) - -##' Check if branch is local -##' -##' @rdname is_local-methods -##' @docType methods -##' @param branch The branch \code{object} to check if it's local -##' @return TRUE if branch is local, else FALSE -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config first user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## List branches -##' branches(repo) -##' -##' ## Check if first branch is_local -##' is_local(branches(repo)[[1]]) -##' -##' ## Check if second branch is_local -##' is_local(branches(repo)[[2]]) -##' } -setGeneric("is_local", - signature = "branch", - function(branch) - standardGeneric("is_local")) - -##' @rdname is_local-methods -##' @export -setMethod("is_local", - signature(branch = "git_branch"), - function(branch) - { - identical(branch@type, 1L) - } -) - -##' Brief summary of branch -##' -##' @aliases show,git_branch-methods -##' @docType methods -##' @param object The branch \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @include S4_classes.r -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Brief summary of the branch in the repository -##' branches(repo)[[1]] -##' } -setMethod("show", - signature(object = "git_branch"), - function(object) - { - sha <- branch_target(object) - if (!is.na(sha)) { - cat(sprintf("[%s] ", substr(sha, 1 , 6))) - } - - if (is_local(object)) { - cat("(Local) ") - } else { - cat(sprintf("(%s @ %s) ", - branch_remote_name(object), - branch_remote_url(object))) - } - - if (is_head(object)) { - cat("(HEAD) ") - } - - if (is_local(object)) { - cat(sprintf("%s\n", object@name)) - } else { - cat(sprintf("%s\n", - substr(object@name, - start = nchar(branch_remote_name(object)) + 2, - stop = nchar(object@name)))) - } - } -) - -##' Check if object is S4 class git_branch -##' -##' @param object Check if object is S4 class git_branch -##' @return TRUE if object is S4 class git_branch, else FALSE -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' branch <- branches(repo)[[1]] -##' -##' ## Check if branch -##' is_branch(branch) -##' } -is_branch <- function(object) { - methods::is(object = object, class2 = "git_branch") -} diff -Nru r-cran-git2r-0.21.0/R/branch.R r-cran-git2r-0.22.1/R/branch.R --- r-cran-git2r-0.21.0/R/branch.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/branch.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,477 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Create a branch +##' +##' @param commit Commit to which branch should point. +##' @param name Name for the branch +##' @param force Overwrite existing branch. Default = FALSE +##' @return invisible git_branch object +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' +##' ## Create a branch +##' branch_1 <- branch_create(commit_1, name = "test-branch") +##' +##' ## Add one more commit +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_2 <- commit(repo, "Another commit message") +##' +##' ## Create a branch with the same name should fail +##' try(branch_create(commit_2, name = "test-branch"), TRUE) +##' +##' ## Force it +##' branch_2 <- branch_create(commit_2, name = "test-branch", force = TRUE) +##' } +branch_create <- function(commit = NULL, name = NULL, force = FALSE) { + invisible(.Call(git2r_branch_create, name, commit, force)) +} + +##' Delete a branch +##' +##' @param branch The branch +##' @return invisible NULL +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' +##' ## Create a 'dev' branch +##' dev <- branch_create(commit_1, name = "dev") +##' branches(repo) +##' +##' ## Delete 'dev' branch +##' branch_delete(dev) +##' branches(repo) +##' } +branch_delete <- function(branch = NULL) { + .Call(git2r_branch_delete, branch) + invisible(NULL) +} + +##' Remote name of a branch +##' +##' The name of remote that the remote tracking branch belongs to +##' @param branch The branch +##' @return character string with remote name +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize two temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## Get remote name +##' branch_remote_name(branches(repo)[[2]]) +##' } +branch_remote_name <- function(branch = NULL) { + .Call(git2r_branch_remote_name, branch) +} + +##' Remote url of a branch +##' +##' @param branch The branch +##' @return character string with remote url +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize two temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## Get remote url of tracking branch to branch 'master' +##' branch_remote_url(branch_get_upstream(repository_head(repo))) +##' } +branch_remote_url <- function(branch = NULL) { + .Call(git2r_branch_remote_url, branch) +} + +##' Rename a branch +##' +##' @param branch Branch to rename +##' @param name The new name for the branch +##' @param force Overwrite existing branch. Default is FALSE +##' @return invisible renamed \code{git_branch} object +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Rename 'master' branch to 'dev' +##' branches(repo) +##' branch_rename(repository_head(repo), "dev") +##' branches(repo) +##' } +branch_rename <- function(branch = NULL, name = NULL, force = FALSE) { + invisible(.Call(git2r_branch_rename, branch, name, force)) +} + +##' Get target (sha) pointed to by a branch +##' +##' @param branch The branch +##' @return sha or NA if not a direct reference +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Get target (sha) pointed to by 'master' branch +##' branch_target(repository_head(repo)) +##' } +branch_target <- function(branch = NULL) { + .Call(git2r_branch_target, branch) +} + +##' Get remote tracking branch +##' +##' Get remote tracking branch, given a local branch. +##' @param branch The branch +##' @return \code{git_branch} object or NULL if no remote tracking +##' branch. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize two temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## Get remote tracking branch +##' branch_get_upstream(repository_head(repo)) +##' } +branch_get_upstream <- function(branch = NULL) { + .Call(git2r_branch_get_upstream, branch) +} + +##' Set remote tracking branch +##' +##' Set the upstream configuration for a given local branch +##' @param branch The branch to configure +##' @param name remote-tracking or local branch to set as +##' upstream. Pass NULL to unset. +##' @return invisible NULL +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize two temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## Unset remote remote tracking branch +##' branch_get_upstream(repository_head(repo)) +##' branch_set_upstream(repository_head(repo), NULL) +##' branch_get_upstream(repository_head(repo)) +##' +##' ## Set remote tracking branch +##' branch_set_upstream(repository_head(repo), "origin/master") +##' branch_get_upstream(repository_head(repo)) +##' } +branch_set_upstream <- function(branch = NULL, name) { + if (missing(name)) + stop("Missing argument name") + .Call(git2r_branch_set_upstream, branch, name) + invisible(NULL) +} + +##' Branches +##' +##' List branches in repository +##' @template repo-param +##' @param flags Filtering flags for the branch listing. Valid values +##' are 'all', 'local' or 'remote' +##' @return list of branches in repository +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config first user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## List branches +##' branches(repo) +##' } +branches <- function(repo = ".", flags=c("all", "local", "remote")) { + flags <- switch(match.arg(flags), + local = 1L, + remote = 2L, + all = 3L) + + .Call(git2r_branch_list, lookup_repository(repo), flags) +} + +##' Check if branch is head +##' +##' @param branch The branch \code{object} to check if it's head. +##' @return \code{TRUE} if branch is head, else \code{FALSE}. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## List branches +##' branches(repo) +##' +##' ## Check that 'master' is_head +##' master <- branches(repo)[[1]] +##' is_head(master) +##' +##' ## Create and checkout 'dev' branch +##' checkout(repo, "dev", create = TRUE) +##' +##' ## List branches +##' branches(repo) +##' +##' ## Check that 'master' is no longer head +##' is_head(master) +##' } +is_head <- function(branch = NULL) { + .Call(git2r_branch_is_head, branch) +} + +##' Check if branch is local +##' +##' @param branch The branch \code{object} to check if it's local +##' @return \code{TRUE} if branch is local, else \code{FALSE}. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config first user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## List branches +##' branches(repo) +##' +##' ## Check if first branch is_local +##' is_local(branches(repo)[[1]]) +##' +##' ## Check if second branch is_local +##' is_local(branches(repo)[[2]]) +##' } +is_local <- function(branch) { + if (!is_branch(branch)) + stop("argument 'branch' must be a 'git_branch' object") + identical(branch$type, 1L) +} + +##' @export +print.git_branch <- function(x, ...) { + sha <- branch_target(x) + if (!is.na(sha)) { + cat(sprintf("[%s] ", substr(sha, 1 , 6))) + } + + if (is_local(x)) { + cat("(Local) ") + } else { + cat(sprintf("(%s @ %s) ", + branch_remote_name(x), + branch_remote_url(x))) + } + + if (is_head(x)) { + cat("(HEAD) ") + } + + if (is_local(x)) { + cat(sprintf("%s\n", x$name)) + } else { + cat(sprintf("%s\n", + substr(x$name, + start = nchar(branch_remote_name(x)) + 2, + stop = nchar(x$name)))) + } +} + +##' Check if object is \code{git_branch} +##' +##' @param object Check if object is of class \code{git_branch} +##' @return TRUE if object is class \code{git_branch}, else FALSE +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' branch <- branches(repo)[[1]] +##' +##' ## Check if branch +##' is_branch(branch) +##' } +is_branch <- function(object) { + inherits(object, "git_branch") +} diff -Nru r-cran-git2r-0.21.0/R/bundle_r_package.r r-cran-git2r-0.22.1/R/bundle_r_package.r --- r-cran-git2r-0.21.0/R/bundle_r_package.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/bundle_r_package.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Bundle bare repo of package -##' -##' Clone the package git repository as a bare repository to -##' \code{pkg/inst/pkg.git} -##' @rdname bundle_r_package-methods -##' @docType methods -##' @param repo The repository with package to bundle. -##' @return Invisible bundled S4 \code{\linkS4class{git_repository}} -##' object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize repository -##' path <- tempfile() -##' dir.create(path) -##' path <- file.path(path, "git2r") -##' repo <- clone("https://github.com/ropensci/git2r.git", path) -##' -##' ## Bundle bare repository in package -##' bundle_r_package(repo) -##' -##' ## Build and install bundled package -##' wd <- setwd(dirname(path)) -##' system(sprintf("R CMD build %s", path)) -##' pkg <- list.files(".", pattern = "[.]tar[.]gz$") -##' system(sprintf("R CMD INSTALL %s", pkg)) -##' setwd(wd) -##' -##' ## Reload package -##' detach("package:git2r", unload = TRUE) -##' library(git2r) -##' -##' ## Summarize last five commits of bundled repo -##' repo <- repository(system.file("git2r.git", package = "git2r")) -##' invisible(lapply(commits(repo, n = 5), summary)) -##' -##' ## Plot content of bundled repo -##' plot(repo) -##' } -setGeneric("bundle_r_package", - signature = "repo", - function(repo) - standardGeneric("bundle_r_package")) - -##' @rdname bundle_r_package-methods -##' @export -setMethod("bundle_r_package", - signature(repo = "git_repository"), - function(repo) - { - ## Check for 'inst' folder - inst <- paste0(workdir(repo), "inst", sep = "") - if (!isTRUE(file.info(inst)$isdir)) - dir.create(inst) - - ## Check for 'pkg.git' folder - local_path <- paste0(basename(workdir(repo)), ".git", sep = "") - local_path <- file.path(inst, local_path) - if (file.exists(local_path)) - stop("Repo already exists:", local_path) - invisible(clone(workdir(repo), local_path, bare = TRUE)) - } -) diff -Nru r-cran-git2r-0.21.0/R/bundle_r_package.R r-cran-git2r-0.22.1/R/bundle_r_package.R --- r-cran-git2r-0.21.0/R/bundle_r_package.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/bundle_r_package.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,67 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Bundle bare repo of package +##' +##' Clone the package git repository as a bare repository to +##' \code{pkg/inst/pkg.git} +##' @template repo-param +##' @return Invisible bundled \code{git_repository} object +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repository +##' path <- tempfile() +##' dir.create(path) +##' path <- file.path(path, "git2r") +##' repo <- clone("https://github.com/ropensci/git2r.git", path) +##' +##' ## Bundle bare repository in package +##' bundle_r_package(repo) +##' +##' ## Build and install bundled package +##' wd <- setwd(dirname(path)) +##' system(sprintf("R CMD build %s", path)) +##' pkg <- list.files(".", pattern = "[.]tar[.]gz$") +##' system(sprintf("R CMD INSTALL %s", pkg)) +##' setwd(wd) +##' +##' ## Reload package +##' detach("package:git2r", unload = TRUE) +##' library(git2r) +##' +##' ## Summarize last five commits of bundled repo +##' repo <- repository(system.file("git2r.git", package = "git2r")) +##' invisible(lapply(commits(repo, n = 5), summary)) +##' +##' ## Plot content of bundled repo +##' plot(repo) +##' } +bundle_r_package <- function(repo = ".") { + repo <- lookup_repository(repo) + + ## Check for 'inst' folder + inst <- paste0(workdir(repo), "inst", sep = "") + if (!isTRUE(file.info(inst)$isdir)) + dir.create(inst) + + ## Check for 'pkg.git' folder + local_path <- paste0(basename(workdir(repo)), ".git", sep = "") + local_path <- file.path(inst, local_path) + if (file.exists(local_path)) + stop("Repo already exists:", local_path) + invisible(clone(workdir(repo), local_path, bare = TRUE)) +} diff -Nru r-cran-git2r-0.21.0/R/checkout.r r-cran-git2r-0.22.1/R/checkout.r --- r-cran-git2r-0.21.0/R/checkout.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/checkout.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,232 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Determine previous branch name -##' -##' @param repo The repository. -##' @noRd -previous_branch_name <- function(repo) -{ - branch <- revparse_single(repo, "@{-1}")@sha - - branch <- sapply(references(repo), function(x) { - ifelse(x@sha == branch, x@shorthand, NA_character_) - }) - branch <- branch[vapply(branch, Negate(is.na), logical(1))] - - branch <- sapply(branches(repo, "local"), function(x) { - ifelse(x@name %in% branch, x@name, NA_character_) - }) - branch <- branch[vapply(branch, Negate(is.na), logical(1))] - - if (any(!is.character(branch), !identical(length(branch), 1L))) { - stop("'branch' must be a character vector of length one") - } - - branch -} - -##' Checkout -##' -##' Update files in the index and working tree to match the content of -##' the tree pointed at by the treeish object (commit, tag or tree). -##' Checkout using the default GIT_CHECKOUT_SAFE_CREATE strategy -##' (force = FALSE) or GIT_CHECKOUT_FORCE (force = TRUE). -##' @rdname checkout-methods -##' @docType methods -##' @param object A repository, commit, tag or tree which content will -##' be used to update the working directory. -##' @param ... Additional arguments affecting the checkout -##' @param branch If object is a repository, the name of the branch to -##' check out. Default is NULL. -##' @param create If object is a repository, then branch is created if -##' doesn't exist. -##' @param force If TRUE, then make working directory match -##' target. This will throw away local changes. Default is FALSE. -##' @param path Limit the checkout operation to only certain -##' paths. This argument is only used if branch is NULL. Default is -##' NULL. -##' @return invisible NULL -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Create directories and initialize repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' repo_bare <- init(path_bare, bare = TRUE) -##' -##' ## Clone to repo 1 and config user -##' repo_1 <- clone(path_bare, path_repo_1) -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Add changes to repo 1 and push to bare -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path_repo_1, "test.txt")) -##' add(repo_1, "test.txt") -##' commit(repo_1, "First commit message") -##' push(repo_1, "origin", "refs/heads/master") -##' -##' ## Create and checkout 'dev' branch in repo 1 -##' checkout(repo_1, "dev", create = TRUE) -##' -##' ## Add changes to 'dev' branch in repo 1 and push to bare -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path_repo_1, "test.txt")) -##' add(repo_1, "test.txt") -##' commit(repo_1, "Second commit message") -##' push(repo_1, "origin", "refs/heads/dev") -##' -##' ## Clone to repo 2 -##' repo_2 <- clone(path_bare, path_repo_2) -##' config(repo_2, user.name="Bob", user.email="bob@@example.org") -##' -##' ## Read content of 'test.txt' -##' readLines(file.path(path_repo_2, "test.txt")) -##' -##' ## Checkout dev branch -##' checkout(repo_2, "dev") -##' -##' ## Read content of 'test.txt' -##' readLines(file.path(path_repo_2, "test.txt")) -##' -##' ## Edit "test.txt" in repo_2 -##' writeLines("Hello world!", con = file.path(path_repo_2, "test.txt")) -##' -##' ## Check status -##' status(repo_2) -##' -##' ## Checkout "test.txt" -##' checkout(repo_2, path = "test.txt") -##' -##' ## Check status -##' status(repo_2) -##' } -setGeneric("checkout", - signature = "object", - function(object, ...) - standardGeneric("checkout") -) - -##' @rdname checkout-methods -##' @export -setMethod("checkout", - signature(object = "git_repository"), - function(object, - branch = NULL, - create = FALSE, - force = FALSE, - path = NULL, - ...) - { - if (!is.null(branch)) { - if (any(!is.character(branch), !identical(length(branch), 1L))) - stop("'branch' must be a character vector of length one") - - if (is_empty(object)) { - if (!isTRUE(create)) - stop(sprintf("'%s' did not match any branch", branch)) - ref_name <- paste0("refs/heads/", branch) - .Call(git2r_repository_set_head, object, ref_name) - } else { - if (identical(branch, "-")) - branch <- previous_branch_name(object) - - ## Check if branch exists in a local branch - lb <- branches(object, "local") - lb <- lb[vapply(lb, slot, character(1), "name") == branch] - if (length(lb)) { - checkout(lb[[1]], force = force) - } else { - ## Check if there exists exactly one remote - ## branch with a matching name. - rb <- branches(object, "remote") - - ## Split remote/name to check for a unique name - name <- vapply(rb, function(x) { - remote <- strsplit(x@name, "/")[[1]][1] - sub(paste0("^", remote, "/"), "", x@name) - }, - character(1)) - i <- which(name == branch) - if (identical(length(i), 1L)) { - ## Create branch and track remote - commit <- lookup(object, branch_target(rb[[i]])) - branch <- branch_create(commit, branch) - branch_set_upstream(branch, rb[[i]]@name) - checkout(branch, force = force) - } else { - if (!isTRUE(create)) - stop(sprintf("'%s' did not match any branch", branch)) - - ## Create branch - commit <- lookup(object, branch_target(head(object))) - checkout(branch_create(commit, branch), force = force) - } - } - } - } else if (!is.null(path)) { - .Call(git2r_checkout_path, object, path) - } else { - stop("missing 'branch' or 'path' argument") - } - - invisible(NULL) - } -) - -##' @rdname checkout-methods -##' @export -setMethod("checkout", - signature(object = "git_branch"), - function(object, force = FALSE) - { - ref_name <- paste0("refs/heads/", object@name) - .Call(git2r_checkout_tree, object@repo, ref_name, force) - .Call(git2r_repository_set_head, object@repo, ref_name) - invisible(NULL) - } -) - -##' @rdname checkout-methods -##' @export -setMethod("checkout", - signature(object = "git_commit"), - function(object, force = FALSE) - { - .Call(git2r_checkout_tree, object@repo, object@sha, force) - .Call(git2r_repository_set_head_detached, object) - invisible(NULL) - } -) - -##' @rdname checkout-methods -##' @export -setMethod("checkout", - signature(object = "git_tag"), - function(object, force = FALSE) - { - .Call(git2r_checkout_tree, object@repo, object@target, force) - .Call(git2r_repository_set_head_detached, - lookup(object@repo, object@target)) - invisible(NULL) - } -) diff -Nru r-cran-git2r-0.21.0/R/checkout.R r-cran-git2r-0.22.1/R/checkout.R --- r-cran-git2r-0.21.0/R/checkout.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/checkout.R 2018-07-09 19:28:04.000000000 +0000 @@ -0,0 +1,230 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Determine previous branch name +##' +##' @param repo The repository. +##' @noRd +previous_branch_name <- function(repo) +{ + branch <- revparse_single(repo, "@{-1}")$sha + + branch <- sapply(references(repo), function(x) { + ifelse(x$sha == branch, x$shorthand, NA_character_) + }) + branch <- branch[vapply(branch, Negate(is.na), logical(1))] + + branch <- sapply(branches(repo, "local"), function(x) { + ifelse(x$name %in% branch, x$name, NA_character_) + }) + branch <- branch[vapply(branch, Negate(is.na), logical(1))] + + if (any(!is.character(branch), !identical(length(branch), 1L))) { + stop("'branch' must be a character vector of length one") + } + + branch +} + +checkout_branch <- function(object, force) { + ref_name <- paste0("refs/heads/", object$name) + .Call(git2r_checkout_tree, object$repo, ref_name, force) + .Call(git2r_repository_set_head, object$repo, ref_name) +} + +checkout_commit <- function(object, force) { + .Call(git2r_checkout_tree, object$repo, object$sha, force) + .Call(git2r_repository_set_head_detached, object) +} + +checkout_tag <- function(object, force) { + .Call(git2r_checkout_tree, object$repo, object$target, force) + .Call(git2r_repository_set_head_detached, lookup(object$repo, object$target)) +} + +checkout_git_object <- function(object, force) { + if (is_branch(object)) { + checkout_branch(object, force) + return(TRUE) + } + + if (is_commit(object)) { + checkout_commit(object, force) + return(TRUE) + } + + if (is_tag(object)) { + checkout_tag(object, force) + return(TRUE) + } + + FALSE +} + +##' Checkout +##' +##' Update files in the index and working tree to match the content of +##' the tree pointed at by the treeish object (commit, tag or tree). +##' The default checkout strategy (\code{force = FALSE}) will only +##' make modifications that will not lose changes. Use \code{force = +##' TRUE} to force working directory to look like index. +##' @param object A path to a repository, or a \code{git_repository} +##' object, or a \code{git_commit} object, or a \code{git_tag} +##' object, or a \code{git_tree} object. +##' @param branch name of the branch to check out. Only used if object +##' is a path to a repository or a \code{git_repository} object. +##' @param create create branch if it doesn't exist. Only used if +##' object is a path to a repository or a \code{git_repository} +##' object. +##' @param force If \code{TRUE}, then make working directory match +##' target. This will throw away local changes. Default is +##' \code{FALSE}. +##' @param path Limit the checkout operation to only certain +##' paths. This argument is only used if branch is NULL. Default +##' is \code{NULL}. +##' @param ... Additional arguments. Not used. +##' @return invisible NULL +##' @export +##' @examples +##' \dontrun{ +##' ## Create directories and initialize repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' repo_bare <- init(path_bare, bare = TRUE) +##' +##' ## Clone to repo 1 and config user +##' repo_1 <- clone(path_bare, path_repo_1) +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Add changes to repo 1 and push to bare +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path_repo_1, "test.txt")) +##' add(repo_1, "test.txt") +##' commit(repo_1, "First commit message") +##' push(repo_1, "origin", "refs/heads/master") +##' +##' ## Create and checkout 'dev' branch in repo 1 +##' checkout(repo_1, "dev", create = TRUE) +##' +##' ## Add changes to 'dev' branch in repo 1 and push to bare +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' con = file.path(path_repo_1, "test.txt")) +##' add(repo_1, "test.txt") +##' commit(repo_1, "Second commit message") +##' push(repo_1, "origin", "refs/heads/dev") +##' +##' ## Clone to repo 2 +##' repo_2 <- clone(path_bare, path_repo_2) +##' config(repo_2, user.name="Bob", user.email="bob@@example.org") +##' +##' ## Read content of 'test.txt' +##' readLines(file.path(path_repo_2, "test.txt")) +##' +##' ## Checkout dev branch +##' checkout(repo_2, "dev") +##' +##' ## Read content of 'test.txt' +##' readLines(file.path(path_repo_2, "test.txt")) +##' +##' ## Edit "test.txt" in repo_2 +##' writeLines("Hello world!", con = file.path(path_repo_2, "test.txt")) +##' +##' ## Check status +##' status(repo_2) +##' +##' ## Checkout "test.txt" +##' checkout(repo_2, path = "test.txt") +##' +##' ## Check status +##' status(repo_2) +##' } +checkout <- function(object = NULL, + branch = NULL, + create = FALSE, + force = FALSE, + path = NULL, + ...) +{ + if (checkout_git_object(object, force)) + return(invisible(NULL)) + + object <- lookup_repository(object) + if (is.null(branch)) { + if (is.null(path)) + stop("missing 'branch' or 'path' argument") + .Call(git2r_checkout_path, object, path) + return(invisible(NULL)) + } + + if (!is.character(branch) || !identical(length(branch), 1L)) + stop("'branch' must be a character vector of length one") + + if (is_empty(object)) { + if (!isTRUE(create)) + stop(sprintf("'%s' did not match any branch", branch)) + ref_name <- paste0("refs/heads/", branch) + .Call(git2r_repository_set_head, object, ref_name) + return(invisible(NULL)) + } + + if (identical(branch, "-")) + branch <- previous_branch_name(object) + + ## Check if branch exists in a local branch + lb <- branches(object, "local") + lb <- lb[vapply(lb, "[[", character(1), "name") == branch] + if (length(lb)) { + checkout_branch(lb[[1]], force) + return(invisible(NULL)) + } + + ## Check if there exists exactly one remote branch with a matching + ## name. + rb <- branches(object, "remote") + + ## Split remote/name to check for a unique name + name <- vapply(rb, function(x) { + remote <- strsplit(x$name, "/")[[1]][1] + sub(paste0("^", remote, "/"), "", x$name) + }, character(1)) + i <- which(name == branch) + if (identical(length(i), 1L)) { + ## Create branch and track remote + commit <- lookup(object, branch_target(rb[[i]])) + branch <- branch_create(commit, branch) + branch_set_upstream(branch, rb[[i]]$name) + checkout_branch(branch, force) + return(invisible(NULL)) + } + + if (isTRUE(create)) { + ## Create branch + commit <- lookup(object, branch_target(repository_head(object))) + checkout_branch(branch_create(commit, branch), force) + return(invisible(NULL)) + } + + ## Check if branch object is specified by revision. + if (checkout_git_object(revparse_single(object, branch), force)) + return(invisible(NULL)) + + stop(sprintf("'%s' did not match any branch", branch)) +} diff -Nru r-cran-git2r-0.21.0/R/commit.r r-cran-git2r-0.22.1/R/commit.r --- r-cran-git2r-0.21.0/R/commit.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/commit.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,717 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Ahead Behind -##' -##' Count the number of unique commits between two commit objects. -##' @rdname ahead_behind-methods -##' @docType methods -##' @param local a S4 class git_commit \code{object}. -##' @param upstream a S4 class git_commit \code{object}. -##' @return An integer vector of length 2 with number of commits that -##' the upstream commit is ahead and behind the local commit -##' @keywords methods -##' @examples \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' # Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit_2 <- commit(repo, "Commit message 2") -##' -##' ahead_behind(commit_1, commit_2) -##' } -setGeneric("ahead_behind", - signature = c("local", "upstream"), - function(local, upstream) - standardGeneric("ahead_behind")) - -##' @rdname ahead_behind-methods -##' @export -setMethod("ahead_behind", - signature(local = "git_commit", upstream = "git_commit"), - function(local, upstream) - { - stopifnot(identical(local@repo, upstream@repo)) - .Call(git2r_graph_ahead_behind, local, upstream) - } -) - -##' Add sessionInfo to message -##' -##' @param message The message. -##' @return message with appended sessionInfo -##' @importFrom utils capture.output -##' @importFrom utils sessionInfo -##' @keywords internal -add_session_info <- function(message) -{ - paste0(message, "\n\nsessionInfo:\n", - paste0(utils::capture.output(utils::sessionInfo()), - collapse="\n")) -} - -##' Commit -##' -##' @rdname commit-methods -##' @docType methods -##' @param repo The repository \code{object}. -##' @param message The commit message. -##' @param all Stage modified and deleted files. Files not added to -##' Git are not affected. -##' @param session Add sessionInfo to commit message. Default is -##' FALSE. -##' @param reference Name of the reference that will be updated to -##' point to this commit. -##' @param author Signature with author and author time of commit. -##' @param committer Signature with committer and commit time of commit. -##' @return \code{\linkS4class{git_commit}} object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' } -setGeneric("commit", - signature = "repo", - function(repo, - message = NULL, - all = FALSE, - session = FALSE, - reference = "HEAD", - author = default_signature(repo), - committer = default_signature(repo)) - standardGeneric("commit")) - -##' @rdname commit-methods -##' @export -setMethod("commit", - signature(repo = "git_repository"), - function(repo, - message, - all, - session, - reference, - author, - committer) - { - ## Argument checking - stopifnot(is.character(message), - identical(length(message), 1L), - is.logical(all), - identical(length(all), 1L), - is.logical(session), - identical(length(session), 1L)) - - if (!nchar(message[1])) - stop("Aborting commit due to empty commit message.") - - if (all) { - s <- status(repo, - unstaged = TRUE, - staged = FALSE, - untracked = FALSE, - ignored = FALSE) - - # Convert list of lists to character vector - unstaged <- unlist(s$unstaged) - for (i in seq_along(unstaged)) { - if (names(unstaged)[i] == "modified") { - ## Stage modified files - add(repo, unstaged[i]) - } else if (names(unstaged)[i] == "deleted") { - ## Stage deleted files - .Call(git2r_index_remove_bypath, repo, unstaged[i]) - } - } - - } - - if (session) - message <- add_session_info(message) - - .Call(git2r_commit, repo, message, author, committer) - } -) - -##' Commits -##' -##' @rdname commits-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @param ... Additional arguments to commits. -##' @param topological Sort the commits in topological order (parents -##' before children); can be combined with time sorting. Default is -##' TRUE. -##' @param time Sort the commits by commit time; Can be combined with -##' topological sorting. Default is TRUE. -##' @param reverse Sort the commits in reverse order; can be combined -##' with topological and/or time sorting. Default is FALSE. -##' @param n The upper limit of the number of commits to output. The -##' defualt is NULL for unlimited number of commits. -##' @return list of commits in repository -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Second commit message") -##' -##' ## Change file again and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", -##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Third commit message") -##' -##' ## List commits in repository -##' commits(repo) -##' } -setGeneric("commits", - signature = "repo", - function(repo, ...) - standardGeneric("commits")) - -##' @rdname commits-methods -##' @export -setMethod("commits", - signature(repo = "missing"), - function(topological = TRUE, - time = TRUE, - reverse = FALSE, - n = NULL, - ...) - { - callGeneric(repo = lookup_repository(), - topological = topological, - time = time, - reverse = reverse, - n = n, - ...) - } -) - -##' @rdname commits-methods -##' @include S4_classes.r -##' @export -setMethod("commits", - signature(repo = "git_repository"), - function(repo, - topological = TRUE, - time = TRUE, - reverse = FALSE, - n = NULL, - ...) - { - ## Check limit in number of commits - if (is.null(n)) { - n <- -1L - } else if (is.numeric(n)) { - if (!identical(length(n), 1L)) - stop("'n' must be integer") - if (abs(n - round(n)) >= .Machine$double.eps^0.5) - stop("'n' must be integer") - n <- as.integer(n) - } else { - stop("'n' must be integer") - } - - if (is_shallow(repo)) { - ## FIXME: Remove this if-statement when libgit2 - ## supports shallow clones, see #219. Note: This - ## workaround does not use the 'topological', 'time' - ## and 'reverse' flags. - - ## List to hold result - result <- list() - - ## Get latest commit - x <- lookup(repo, branch_target(head(repo))) - - ## Repeat until no more parent commits - repeat { - if (n == 0) { - break - } else if (n > 0) { - n <- n - 1 - } - - if (is.null(x)) - break - result <- append(result, x) - - ## Get parent to commit - x <- tryCatch(parents(x)[[1]], error = function(e) NULL) - } - - return(result) - } - - .Call(git2r_revwalk_list, repo, topological, time, reverse, n) - } -) - -##' Descendant -##' -##' Determine if a commit is the descendant of another commit -##' @rdname descendant_of-methods -##' @docType methods -##' @param commit a S4 class git_commit \code{object}. -##' @param ancestor a S4 class git_commit \code{object} to check if -##' ancestor to \code{commit}. -##' @return TRUE if commit is descendant of \code{ancestor}, else -##' FALSE -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' # Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit_2 <- commit(repo, "Commit message 2") -##' -##' descendant_of(commit_1, commit_2) -##' descendant_of(commit_2, commit_1) -##' } -setGeneric("descendant_of", - signature = c("commit", "ancestor"), - function(commit, ancestor) - standardGeneric("descendant_of")) - -##' @rdname descendant_of-methods -##' @export -setMethod("descendant_of", - signature(commit = "git_commit", ancestor = "git_commit"), - function(commit, ancestor) - { - stopifnot(identical(commit@repo, ancestor@repo)) - .Call(git2r_graph_descendant_of, commit, ancestor) - } -) - -##' Check if object is S4 class git_commit -##' -##' @param object Check if object is S4 class git_commit -##' @return TRUE if object is S4 class git_commit, else FALSE -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' -##' ## Check if commit -##' is_commit(commit_1) -##' } -is_commit <- function(object) { - is(object = object, class2 = "git_commit") -} - -##' Is merge -##' -##' Determine if a commit is a merge commit, i.e. has more than one -##' parent. -##' @rdname is_merge-methods -##' @docType methods -##' @param commit a S4 class git_commit \code{object}. -##' @return TRUE if commit has more than one parent, else FALSE -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines(c("First line in file 1.", "Second line in file 1."), -##' file.path(path, "example-1.txt")) -##' add(repo, "example-1.txt") -##' commit(repo, "First commit message") -##' -##' ## Create and add one more file -##' writeLines(c("First line in file 2.", "Second line in file 2."), -##' file.path(path, "example-2.txt")) -##' add(repo, "example-2.txt") -##' commit(repo, "Second commit message") -##' -##' ## Create a new branch 'fix' -##' checkout(repo, "fix", create = TRUE) -##' -##' ## Update 'example-1.txt' (swap words in first line) and commit -##' writeLines(c("line First in file 1.", "Second line in file 1."), -##' file.path(path, "example-1.txt")) -##' add(repo, "example-1.txt") -##' commit(repo, "Third commit message") -##' -##' checkout(repo, "master") -##' -##' ## Update 'example-2.txt' (swap words in second line) and commit -##' writeLines(c("First line in file 2.", "line Second in file 2."), -##' file.path(path, "example-2.txt")) -##' add(repo, "example-2.txt") -##' commit(repo, "Fourth commit message") -##' -##' ## Merge 'fix' -##' merge(repo, "fix") -##' -##' ## Display parents of last commit -##' parents(lookup(repo, branch_target(head(repo)))) -##' -##' ## Check that last commit is a merge -##' is_merge(lookup(repo, branch_target(head(repo)))) -##' } -setGeneric("is_merge", - signature = c("commit"), - function(commit) - standardGeneric("is_merge")) - -##' @rdname is_merge-methods -##' @export -setMethod("is_merge", - signature(commit = "git_commit"), - function(commit) - { - length(parents(commit)) > 1 - } -) - -##' Parents -##' -##' Get parents of a commit. -##' @rdname parents-methods -##' @docType methods -##' @param object a S4 class git_commit \code{object}. -##' @return list of S4 git_commit objects -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("First line.", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' -##' ## commit_1 has no parents -##' parents(commit_1) -##' -##' ## Update 'example.txt' and commit -##' writeLines(c("First line.", "Second line."), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_2 <- commit(repo, "Second commit message") -##' -##' ## commit_2 has commit_1 as parent -##' parents(commit_2) -##' } -setGeneric("parents", - signature = "object", - function(object) - standardGeneric("parents")) - -##' @rdname parents-methods -##' @export -setMethod("parents", - signature(object = "git_commit"), - function(object) - { - .Call(git2r_commit_parent_list, object) - } -) - -##' Brief summary of commit -##' -##' Displays the first seven characters of the sha, the date and the -##' summary of the commit message: -##' \code{[shortened sha] yyyy-mm-dd: summary} -##' @aliases show,git_commit-methods -##' @docType methods -##' @param object The commit \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @include S4_classes.r -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Brief summary of commit in repository -##' show(commits(repo)[[1]]) -##' } -setMethod("show", - signature(object = "git_commit"), - function(object) - { - cat(sprintf("[%s] %s: %s\n", - substring(object@sha, 1, 7), - substring(as(object@author@when, "character"), 1, 10), - object@summary)) - } -) - -##' Summary of commit -##' -##' @aliases summary,git_commit-methods -##' @docType methods -##' @param object The commit \code{object} -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Summary of commit in repository -##' summary(commits(repo)[[1]]) -##' } -setMethod("summary", - signature(object = "git_commit"), - function(object, ...) - { - is_merge_commit <- is_merge(object) - po <- parents(object) - - cat(sprintf("Commit: %s\n", object@sha)) - - if (is_merge_commit) { - sha <- vapply(po, slot, character(1), "sha") - cat(sprintf("Merge: %s\n", sha[1])) - cat(paste0(" ", sha[-1]), sep="\n") - } - - cat(sprintf(paste0("Author: %s <%s>\n", - "When: %s\n\n"), - object@author@name, - object@author@email, - as(object@author@when, "character"))) - - msg <- paste0(" ", readLines(textConnection(object@message))) - cat("", sprintf("%s\n", msg)) - - if (is_merge_commit) { - cat("\n") - lapply(po, function(parent) { - cat("Commit message: ", parent@sha, "\n") - msg <- paste0(" ", - readLines(textConnection(parent@message))) - cat("", sprintf("%s\n", msg), "\n") - }) - } - - if (identical(length(po), 1L)) { - df <- diff(tree(po[[1]]), tree(object)) - if (length(df) > 0) { - if (length(df) > 1) { - cat(sprintf("%i files changed, ", length(df))) - } else { - cat("1 file changed, ") - } - - cat(sprintf("%i insertions, %i deletions\n", - sum(vapply(lines_per_file(df), "[[", numeric(1), "add")), - sum(vapply(lines_per_file(df), "[[", numeric(1), "del")))) - - plpf <- print_lines_per_file(df) - hpf <- hunks_per_file(df) - hunk_txt <- ifelse(hpf > 1, " hunks", - ifelse(hpf > 0, " hunk", - " hunk (binary file)")) - phpf <- paste0(" in ", format(hpf), hunk_txt) - cat(paste0(plpf, phpf), sep="\n") - } - - cat("\n") - } - - invisible(NULL) - } -) - -##' Coerce a commit to a \code{data.frame} -##' -##' The commit is coerced to a \code{data.frame} -##' -##' -##' The \code{data.frame} have the following columns: -##' \describe{ -##' -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' -##' \item{summary}{ -##' the short "summary" of the git commit message. -##' } -##' -##' \item{message}{ -##' the full message of a commit -##' } -##' -##' \item{author}{ -##' full name of the author -##' } -##' -##' \item{email}{ -##' email of the author -##' } -##' -##' \item{when}{ -##' time when the commit happened -##' } -##' -##' } -##' @name coerce-git_commit-method -##' @aliases coerce,git_commit,data.frame-method -##' @docType methods -##' @param from The commit \code{object} -##' @return \code{data.frame} -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file and commit -##' writeLines("Example file", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' c1 <- commit(repo, "Commit message") -##' -##' ## Coerce the commit to a data.frame -##' df <- as(c1, "data.frame") -##' df -##' } -setAs(from = "git_commit", - to = "data.frame", - def = function(from) - { - data.frame(sha = from@sha, - summary = from@summary, - message = from@message, - author = from@author@name, - email = from@author@email, - when = as(from@author@when, "POSIXct"), - stringsAsFactors = FALSE) - } -) diff -Nru r-cran-git2r-0.21.0/R/commit.R r-cran-git2r-0.22.1/R/commit.R --- r-cran-git2r-0.21.0/R/commit.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/commit.R 2018-07-01 21:27:09.000000000 +0000 @@ -0,0 +1,538 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Ahead Behind +##' +##' Count the number of unique commits between two commit objects. +##' @param local a git_commit object. +##' @param upstream a git_commit object. +##' @return An integer vector of length 2 with number of commits that +##' the upstream commit is ahead and behind the local commit +##' @export +##' @examples \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' # Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit_2 <- commit(repo, "Commit message 2") +##' +##' ahead_behind(commit_1, commit_2) +##' } +ahead_behind <- function(local = NULL, upstream = NULL) { + .Call(git2r_graph_ahead_behind, local, upstream) +} + +##' Add sessionInfo to message +##' +##' @param message The message. +##' @return message with appended sessionInfo +##' @importFrom utils capture.output +##' @importFrom utils sessionInfo +##' @noRd +add_session_info <- function(message) { + paste0(message, "\n\nsessionInfo:\n", + paste0(utils::capture.output(utils::sessionInfo()), + collapse="\n")) +} + +##' Commit +##' +##' @template repo-param +##' @param message The commit message. +##' @param all Stage modified and deleted files. Files not added to +##' Git are not affected. +##' @param session Add sessionInfo to commit message. Default is +##' FALSE. +##' @param author Signature with author and author time of commit. +##' @param committer Signature with committer and commit time of +##' commit. +##' @return A list of class \code{git_commit} with entries: +##' \describe{ +##' \item{sha}{ +##' The 40 character hexadecimal string of the SHA-1 +##' } +##' \item{author}{ +##' An author signature +##' } +##' \item{committer}{ +##' The committer signature +##' } +##' \item{summary}{ +##' The short "summary" of a git commit message, comprising the first +##' paragraph of the message with whitespace trimmed and squashed. +##' } +##' \item{message}{ +##' The message of a commit +##' } +##' \item{repo}{ +##' The \code{git_repository} object that contains the commit +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' } +commit <- function(repo = ".", + message = NULL, + all = FALSE, + session = FALSE, + author = NULL, + committer = NULL) +{ + repo <- lookup_repository(repo) + if (is.null(author)) + author <- default_signature(repo) + if (is.null(committer)) + committer <- default_signature(repo) + + stopifnot(is.character(message), identical(length(message), 1L)) + if (!nchar(message[1])) + stop("Aborting commit due to empty commit message.") + + if (isTRUE(all)) { + s <- status(repo, + unstaged = TRUE, + staged = FALSE, + untracked = FALSE, + ignored = FALSE) + + ## Convert list of lists to character vector + unstaged <- unlist(s$unstaged) + for (i in seq_along(unstaged)) { + if (names(unstaged)[i] == "modified") { + ## Stage modified files + add(repo, unstaged[i]) + } else if (names(unstaged)[i] == "deleted") { + ## Stage deleted files + .Call(git2r_index_remove_bypath, repo, unstaged[i]) + } + } + + } + + if (isTRUE(session)) + message <- add_session_info(message) + + .Call(git2r_commit, repo, message, author, committer) +} + +##' Commits +##' +##' @template repo-param +##' @param topological Sort the commits in topological order (parents +##' before children); can be combined with time sorting. Default +##' is TRUE. +##' @param time Sort the commits by commit time; Can be combined with +##' topological sorting. Default is TRUE. +##' @param reverse Sort the commits in reverse order; can be combined +##' with topological and/or time sorting. Default is FALSE. +##' @param n The upper limit of the number of commits to output. The +##' defualt is NULL for unlimited number of commits. +##' @return list of commits in repository +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Second commit message") +##' +##' ## Change file again and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", +##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Third commit message") +##' +##' ## List commits in repository +##' commits(repo) +##' } +commits <- function(repo = ".", + topological = TRUE, + time = TRUE, + reverse = FALSE, + n = NULL) +{ + ## Check limit in number of commits + if (is.null(n)) { + n <- -1L + } else if (is.numeric(n)) { + if (!identical(length(n), 1L)) + stop("'n' must be integer") + if (abs(n - round(n)) >= .Machine$double.eps^0.5) + stop("'n' must be integer") + n <- as.integer(n) + } else { + stop("'n' must be integer") + } + + repo <- lookup_repository(repo) + if (is_shallow(repo)) { + ## FIXME: Remove this if-statement when libgit2 supports + ## shallow clones, see #219. Note: This workaround does not + ## use the 'topological', 'time' and 'reverse' flags. + + ## List to hold result + result <- list() + + ## Get latest commit + x <- lookup(repo, branch_target(repository_head(repo))) + + ## Repeat until no more parent commits + repeat { + if (n == 0) { + break + } else if (n > 0) { + n <- n - 1 + } + + if (is.null(x)) + break + result <- append(result, x) + + ## Get parent to commit + x <- tryCatch(parents(x)[[1]], error = function(e) NULL) + } + + return(result) + } + + .Call(git2r_revwalk_list, repo, topological, time, reverse, n) +} + +##' Last commit +##' +##' Get last commit in the current branch. +##' @template repo-param +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Get last commit +##' last_commit(repo) +##' last_commit(path) +##' +##' ## Coerce the last commit to a data.frame +##' as.data.frame(last_commit(path), "data.frame") +##' +##' ## Summary of last commit in repository +##' summary(last_commit(repo)) +##' } +last_commit <- function(repo = ".") { + commits(lookup_repository(repo), n = 1)[[1]] +} + +##' Descendant +##' +##' Determine if a commit is the descendant of another commit +##' @param commit a git_commit object. +##' @param ancestor a git_commit object to check if ancestor to +##' \code{commit}. +##' @return TRUE if \code{commit} is descendant of \code{ancestor}, +##' else FALSE +##' @export +##' @examples +##' \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' # Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit_2 <- commit(repo, "Commit message 2") +##' +##' descendant_of(commit_1, commit_2) +##' descendant_of(commit_2, commit_1) +##' } +descendant_of <- function(commit = NULL, ancestor = NULL) { + .Call(git2r_graph_descendant_of, commit, ancestor) +} + +##' Check if object is a git_commit object +##' +##' @param object Check if object is a git_commit object +##' @return TRUE if object is a git_commit, else FALSE +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' +##' ## Check if commit +##' is_commit(commit_1) +##' } +is_commit <- function(object) { + inherits(object, "git_commit") +} + +##' Is merge +##' +##' Determine if a commit is a merge commit, i.e. has more than one +##' parent. +##' @param commit a git_commit object. +##' @return TRUE if commit has more than one parent, else FALSE +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines(c("First line in file 1.", "Second line in file 1."), +##' file.path(path, "example-1.txt")) +##' add(repo, "example-1.txt") +##' commit(repo, "First commit message") +##' +##' ## Create and add one more file +##' writeLines(c("First line in file 2.", "Second line in file 2."), +##' file.path(path, "example-2.txt")) +##' add(repo, "example-2.txt") +##' commit(repo, "Second commit message") +##' +##' ## Create a new branch 'fix' +##' checkout(repo, "fix", create = TRUE) +##' +##' ## Update 'example-1.txt' (swap words in first line) and commit +##' writeLines(c("line First in file 1.", "Second line in file 1."), +##' file.path(path, "example-1.txt")) +##' add(repo, "example-1.txt") +##' commit(repo, "Third commit message") +##' +##' checkout(repo, "master") +##' +##' ## Update 'example-2.txt' (swap words in second line) and commit +##' writeLines(c("First line in file 2.", "line Second in file 2."), +##' file.path(path, "example-2.txt")) +##' add(repo, "example-2.txt") +##' commit(repo, "Fourth commit message") +##' +##' ## Merge 'fix' +##' merge(repo, "fix") +##' +##' ## Display parents of last commit +##' parents(lookup(repo, branch_target(repository_head(repo)))) +##' +##' ## Check that last commit is a merge +##' is_merge(lookup(repo, branch_target(repository_head(repo)))) +##' } +is_merge <- function(commit = NULL) { + length(parents(commit)) > 1 +} + +##' Parents +##' +##' Get parents of a commit. +##' @param object a git_commit object. +##' @return list of git_commit objects +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("First line.", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' +##' ## commit_1 has no parents +##' parents(commit_1) +##' +##' ## Update 'example.txt' and commit +##' writeLines(c("First line.", "Second line."), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_2 <- commit(repo, "Second commit message") +##' +##' ## commit_2 has commit_1 as parent +##' parents(commit_2) +##' } +parents <- function(object = NULL) { + .Call(git2r_commit_parent_list, object) +} + +##' @export +format.git_commit <- function(x, ...) { + sprintf("[%s] %s: %s\n", + substring(x$sha, 1, 7), + substring(as.character(x$author$when), 1, 10), + x$summary) +} + +##' @export +print.git_commit <- function(x, ...) { + cat(format(x, ...), "\n", sep = "") +} + +##' @export +summary.git_commit <- function(object, ...) +{ + is_merge_commit <- is_merge(object) + po <- parents(object) + + cat(sprintf("Commit: %s\n", object$sha)) + + if (is_merge_commit) { + sha <- vapply(po, "[[", character(1), "sha") + cat(sprintf("Merge: %s\n", sha[1])) + cat(paste0(" ", sha[-1]), sep="\n") + } + + cat(sprintf(paste0("Author: %s <%s>\n", + "When: %s\n\n"), + object$author$name, + object$author$email, + as.character(object$author$when))) + + msg <- paste0(" ", readLines(textConnection(object$message))) + cat("", sprintf("%s\n", msg)) + + if (is_merge_commit) { + cat("\n") + lapply(po, function(parent) { + cat("Commit message: ", parent$sha, "\n") + msg <- paste0(" ", + readLines(textConnection(parent$message))) + cat("", sprintf("%s\n", msg), "\n") + }) + } + + if (identical(length(po), 1L)) { + df <- diff(tree(po[[1]]), tree(object)) + if (length(df) > 0) { + if (length(df) > 1) { + cat(sprintf("%i files changed, ", length(df))) + } else { + cat("1 file changed, ") + } + + cat(sprintf("%i insertions, %i deletions\n", + sum(vapply(lines_per_file(df), "[[", numeric(1), "add")), + sum(vapply(lines_per_file(df), "[[", numeric(1), "del")))) + + plpf <- print_lines_per_file(df) + hpf <- hunks_per_file(df) + hunk_txt <- ifelse(hpf > 1, " hunks", + ifelse(hpf > 0, " hunk", + " hunk (binary file)")) + phpf <- paste0(" in ", format(hpf), hunk_txt) + cat(paste0(plpf, phpf), sep="\n") + } + + cat("\n") + } + + invisible(NULL) +} + +##' @export +as.data.frame.git_commit <- function(x, ...) { + data.frame(sha = x$sha, + summary = x$summary, + message = x$message, + author = x$author$name, + email = x$author$email, + when = as.POSIXct(x$author$when), + stringsAsFactors = FALSE) +} diff -Nru r-cran-git2r-0.21.0/R/config.r r-cran-git2r-0.22.1/R/config.r --- r-cran-git2r-0.21.0/R/config.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/config.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Config -##' -##' Config file management. To display the configuration variables, -##' call method \code{config} without the \code{user.name}, -##' \code{user.email} or \code{...} options. -##' -##' There are two ways git2r can find the local repository when -##' writing local options (1) Use the \code{repo} argument. (2) If the -##' \code{repo} argument is \code{NULL} but the current working -##' directory is inside the local repository, then \code{git2r} uses -##' that repository. -##' @param repo The \code{repository}. Default is NULL. -##' @param global Write option(s) to global configuration -##' file. Default is FALSE. -##' @param user.name The user name. Use NULL to delete the entry -##' @param user.email The e-mail address. Use NULL to delete the entry -##' @param ... Additional options to write or delete from the -##' configuration. -##' @return S3 class \code{git_config}. When writing options, the -##' configuration is returned invisible. -##' @export -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern = "git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Set user name and email. -##' config(repo, user.name = "Alice", user.email = "alice@@example.org") -##' -##' ## Display configuration -##' config(repo) -##' -##' ## Delete user email. -##' config(repo, user.email = NULL) -##' -##' ## Display configuration -##' config(repo) -##' } -config <- function(repo = NULL, global = FALSE, user.name, user.email, ...) -{ - if (is.null(repo)) { - repo <- discover_repository(getwd()) - if (!is.null(repo)) - repo <- repository(repo) - } - - ## Check that 'global' is either TRUE or FALSE - stopifnot(any(identical(global, TRUE), identical(global, FALSE))) - - variables <- list(...) - if (!missing(user.name)) - variables <- c(variables, list(user.name = user.name)) - - if (!missing(user.email)) - variables <- c(variables, list(user.email = user.email)) - - if (length(variables)) { - for (i in seq_len(length(variables))) { - if (!is.null(variables[[i]])) { - if (!is.character(variables[[i]])) { - stop("'", names(variables)[i], "' must be a character vector") - } - } - } - - if (isTRUE(global)) { - repo <- NULL - } else if (is.null(repo)) { - stop("Unable to locate local repository") - } - - .Call(git2r_config_set, repo, variables) - } - - cfg <- .Call(git2r_config_get, repo) - - ## Sort the variables within levels by name - cfg <- structure(lapply(cfg, function(x) x[order(names(x))]), - class = "git_config") - - if (length(variables)) { - invisible(cfg) - } else { - return(cfg) - } -} - -##' @export -print.git_config <- function(x, ...) { - lapply(names(x), function(level) { - cat(sprintf("%s:\n", level)) - lapply(names(x[[level]]), function(entry) { - cat(sprintf(" %s=%s\n", entry, x[[level]][[entry]][1])) - }) - }) -} diff -Nru r-cran-git2r-0.21.0/R/config.R r-cran-git2r-0.22.1/R/config.R --- r-cran-git2r-0.21.0/R/config.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/config.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,180 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Config +##' +##' Config file management. To display the configuration variables, +##' call method \code{config} without the \code{user.name}, +##' \code{user.email} or \code{...} options. +##' +##' There are two ways git2r can find the local repository when +##' writing local options (1) Use the \code{repo} argument. (2) If the +##' \code{repo} argument is \code{NULL} but the current working +##' directory is inside the local repository, then \code{git2r} uses +##' that repository. +##' @param repo The \code{repository}. Default is NULL. +##' @param global Write option(s) to global configuration +##' file. Default is FALSE. +##' @param user.name The user name. Use NULL to delete the entry +##' @param user.email The e-mail address. Use NULL to delete the entry +##' @param ... Additional options to write or delete from the +##' configuration. +##' @return S3 class \code{git_config}. When writing options, the +##' configuration is returned invisible. +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern = "git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Set user name and email. +##' config(repo, user.name = "Alice", user.email = "alice@@example.org") +##' +##' ## Display configuration +##' config(repo) +##' +##' ## Delete user email. +##' config(repo, user.email = NULL) +##' +##' ## Display configuration +##' config(repo) +##' } +config <- function(repo = NULL, global = FALSE, user.name, user.email, ...) +{ + if (is.null(repo)) { + repo <- discover_repository(getwd()) + if (!is.null(repo)) + repo <- repository(repo) + } + + ## Check that 'global' is either TRUE or FALSE + stopifnot(any(identical(global, TRUE), identical(global, FALSE))) + + variables <- list(...) + if (!missing(user.name)) + variables <- c(variables, list(user.name = user.name)) + + if (!missing(user.email)) + variables <- c(variables, list(user.email = user.email)) + + if (length(variables)) { + for (i in seq_len(length(variables))) { + if (!is.null(variables[[i]])) { + if (!is.character(variables[[i]])) { + stop("'", names(variables)[i], "' must be a character vector") + } + } + } + + if (isTRUE(global)) { + repo <- NULL + if (.Platform$OS.type == "windows") { + # Ensure that git2r writes the config file to the root of the + # user's home directory by first creating an empty file. Otherwise + # it may be written to the user's Documents/ directory. Only + # create the empty file if the user has specified configuration + # options to set and no global config file exists. + if (is.na(git_config_files()$global) && length(variables) > 0) { + file.create(file.path(home_dir(), ".gitconfig")) + } + } + } else if (is.null(repo)) { + stop("Unable to locate local repository") + } + + .Call(git2r_config_set, repo, variables) + } + + cfg <- .Call(git2r_config_get, repo) + + ## Sort the variables within levels by name + cfg <- structure(lapply(cfg, function(x) x[order(names(x))]), + class = "git_config") + + if (length(variables)) { + invisible(cfg) + } else { + return(cfg) + } +} + +##' @export +print.git_config <- function(x, ...) { + lapply(names(x), function(level) { + cat(sprintf("%s:\n", level)) + lapply(names(x[[level]]), function(entry) { + cat(sprintf(" %s=%s\n", entry, x[[level]][[entry]][1])) + }) + }) +} + +##' Locate the path to configuration files +##' +##' Potential configuration files: +##' \describe{ +##' \item{system}{ +##' Locate the path to the system configuration file. If +##' '/etc/gitconfig' doesn't exist, it will look for +##' '\%PROGRAMFILES\%'. +##' } +##' \item{xdg}{ +##' Locate the path to the global xdg compatible configuration +##' file. The xdg compatible configuration file is usually located +##' in '$HOME/.config/git/config'. This method will try to guess +##' the full path to that file, if the file exists. +##' } +##' \item{global}{ +##' The user or global configuration file is usually located in +##' '$HOME/.gitconfig'. This method will try to guess the full +##' path to that file, if the file exists. +##' } +##' \item{local}{ +##' Locate the path to the repository specific configuration file, +##' if the file exists. +##' } +##' } +##' @template repo-param +##' @return a named list with one item per potential configuration +##' file where \code{NA} means not found. +##' @export +git_config_files <- function(repo = ".") { + ## Lookup repository + if (inherits(repo, "git_repository")) { + repo <- repo$path + } else if (is.null(repo)) { + repo <- discover_repository(getwd()) + } else if (is.character(repo) && (length(repo) == 1) && + !is.na(repo) && dir.exists(repo)) { + repo <- discover_repository(repo) + } else { + repo <- NULL + } + + ## Find local configuration file + if (is.null(repo)) { + path <- NA_character_ + } else { + path <- file.path(normalizePath(repo), "config") + if (!isTRUE(!file.info(path)$isdir)) + path <- NA_character_ + } + + list(system = .Call(git2r_config_find_file, "system"), + xdg = .Call(git2r_config_find_file, "xdg"), + global = .Call(git2r_config_find_file, "global"), + local = path) +} diff -Nru r-cran-git2r-0.21.0/R/contributions.r r-cran-git2r-0.22.1/R/contributions.r --- r-cran-git2r-0.21.0/R/contributions.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/contributions.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Contributions -##' -##' See contributions to a Git repo -##' @rdname contributions-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @param breaks Default is \code{month}. Change to year, quarter, -##' week or day as necessary. -##' @param by Contributions by "commits" or "author". Default is "commits". -##' @return A \code{data.frame} with contributions. -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Create directories and initialize repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' repo_bare <- init(path_bare, bare = TRUE) -##' -##' ## Clone to repo 1 and config user -##' repo_1 <- clone(path_bare, path_repo_1) -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Add changes to repo 1 and push to bare -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path_repo_1, "test.txt")) -##' add(repo_1, "test.txt") -##' commit(repo_1, "First commit message") -##' -##' ## Add more changes to repo 1 -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path_repo_1, "test.txt")) -##' add(repo_1, "test.txt") -##' commit(repo_1, "Second commit message") -##' -##' ## Push to bare -##' push(repo_1, "origin", "refs/heads/master") -##' -##' ## Clone to repo 2 -##' repo_2 <- clone(path_bare, path_repo_2) -##' config(repo_2, user.name="Bob", user.email="bob@@example.org") -##' -##' ## Add changes to repo 2 -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", -##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), -##' con = file.path(path_repo_2, "test.txt")) -##' add(repo_2, "test.txt") -##' commit(repo_2, "Third commit message") -##' -##' ## Push to bare -##' push(repo_2, "origin", "refs/heads/master") -##' -##' ## Pull changes to repo 1 -##' pull(repo_1) -##' -##' ## View contributions by day -##' contributions(repo_1) -##' -##' ## View contributions by author and day -##' contributions(repo_1, by = "author") -##' } -setGeneric("contributions", - signature = "repo", - function(repo, - breaks = c("month", "year", "quarter", "week", "day"), - by = c("commits", "author")) - standardGeneric("contributions")) - -##' @rdname contributions-methods -##' @export -setMethod("contributions", - signature(repo = "missing"), - function(breaks, by) - { - callGeneric(repo = lookup_repository(), - breaks = breaks, - by = by) - } -) - -##' @rdname contributions-methods -##' @export -setMethod("contributions", - signature(repo = "character"), - function(repo, breaks, by) - { - contributions(repository(repo), breaks = breaks, by = by) - } -) - -##' @rdname contributions-methods -##' @export -setMethod("contributions", - signature(repo = "git_repository"), - function(repo, breaks, by) - { - breaks <- match.arg(breaks) - by <- match.arg(by) - - ctbs <- .Call( - git2r_revwalk_contributions, repo, TRUE, TRUE, FALSE) - ctbs$when <- as.POSIXct(ctbs$when, origin="1970-01-01", tz="GMT") - ctbs$when <- as.POSIXct(cut(ctbs$when, breaks = breaks)) - - if (identical(by, "commits")) { - ctbs <- as.data.frame(table(ctbs$when)) - names(ctbs) <- c("when", "n") - ctbs$when <- as.Date(ctbs$when) - } else { - ## Create an index and tabulate - ctbs$index <- paste0(ctbs$when, ctbs$author, ctbs$email) - count <- as.data.frame(table(ctbs$index), - stringsAsFactors=FALSE) - names(count) <- c("index", "n") - - ## Match counts and clean result - ctbs <- as.data.frame(ctbs) - ctbs$n <- count$n[match(ctbs$index, count$index)] - ctbs <- unique(ctbs[, c("when", "author", "n")]) - ctbs$when <- as.Date(substr(as.character(ctbs$when), 1, 10)) - ctbs <- ctbs[order(ctbs$when, ctbs$author),] - row.names(ctbs) <- NULL - } - - ctbs - } -) diff -Nru r-cran-git2r-0.21.0/R/contributions.R r-cran-git2r-0.22.1/R/contributions.R --- r-cran-git2r-0.21.0/R/contributions.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/contributions.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,114 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Contributions +##' +##' See contributions to a Git repo +##' @template repo-param +##' @param breaks Default is \code{month}. Change to year, quarter, +##' week or day as necessary. +##' @param by Contributions by "commits" or "author". Default is "commits". +##' @return A \code{data.frame} with contributions. +##' @export +##' @examples +##' \dontrun{ +##' ## Create directories and initialize repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' repo_bare <- init(path_bare, bare = TRUE) +##' +##' ## Clone to repo 1 and config user +##' repo_1 <- clone(path_bare, path_repo_1) +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Add changes to repo 1 and push to bare +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path_repo_1, "test.txt")) +##' add(repo_1, "test.txt") +##' commit(repo_1, "First commit message") +##' +##' ## Add more changes to repo 1 +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' con = file.path(path_repo_1, "test.txt")) +##' add(repo_1, "test.txt") +##' commit(repo_1, "Second commit message") +##' +##' ## Push to bare +##' push(repo_1, "origin", "refs/heads/master") +##' +##' ## Clone to repo 2 +##' repo_2 <- clone(path_bare, path_repo_2) +##' config(repo_2, user.name="Bob", user.email="bob@@example.org") +##' +##' ## Add changes to repo 2 +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", +##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), +##' con = file.path(path_repo_2, "test.txt")) +##' add(repo_2, "test.txt") +##' commit(repo_2, "Third commit message") +##' +##' ## Push to bare +##' push(repo_2, "origin", "refs/heads/master") +##' +##' ## Pull changes to repo 1 +##' pull(repo_1) +##' +##' ## View contributions by day +##' contributions(repo_1) +##' +##' ## View contributions by author and day +##' contributions(repo_1, by = "author") +##' } +contributions <- function(repo = ".", + breaks = c("month", "year", "quarter", "week", "day"), + by = c("commits", "author")) +{ + breaks <- match.arg(breaks) + by <- match.arg(by) + + ctbs <- .Call(git2r_revwalk_contributions, lookup_repository(repo), + TRUE, TRUE, FALSE) + ctbs$when <- as.POSIXct(ctbs$when, origin="1970-01-01", tz="GMT") + ctbs$when <- as.POSIXct(cut(ctbs$when, breaks = breaks)) + + if (identical(by, "commits")) { + ctbs <- as.data.frame(table(ctbs$when)) + names(ctbs) <- c("when", "n") + ctbs$when <- as.Date(ctbs$when) + } else { + ## Create an index and tabulate + ctbs$index <- paste0(ctbs$when, ctbs$author, ctbs$email) + count <- as.data.frame(table(ctbs$index), + stringsAsFactors=FALSE) + names(count) <- c("index", "n") + + ## Match counts and clean result + ctbs <- as.data.frame(ctbs) + ctbs$n <- count$n[match(ctbs$index, count$index)] + ctbs <- unique(ctbs[, c("when", "author", "n")]) + ctbs$when <- as.Date(substr(as.character(ctbs$when), 1, 10)) + ctbs <- ctbs[order(ctbs$when, ctbs$author),] + row.names(ctbs) <- NULL + } + + ctbs +} diff -Nru r-cran-git2r-0.21.0/R/credential.r r-cran-git2r-0.22.1/R/credential.r --- r-cran-git2r-0.21.0/R/credential.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/credential.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013 - 2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Create a new environmental credential object -##' -##' Environmental variables can be written to the file -##' \code{.Renviron}. This file is read by \emph{R} during startup, -##' see \code{\link[base]{Startup}}. -##' @rdname cred_env-methods -##' @family git credential functions -##' @param username The name of the environmental variable that holds -##' the username for the authentication. -##' @param password The name of the environmental variable that holds -##' the password for the authentication. -##' @return A S4 \code{cred_env} object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create an environmental credential object for the username and -##' ## password. -##' cred <- cred_env("NAME_OF_ENV_VARIABLE_WITH_USERNAME", -##' "NAME_OF_ENV_VARIABLE_WITH_PASSWORD") -##' repo <- repository("git2r") -##' push(repo, credentials = cred) -##' } -setGeneric("cred_env", - signature = c("username", "password"), - function(username, password) - standardGeneric("cred_env")) - -##' @rdname cred_env-methods -##' @export -setMethod("cred_env", - signature(username = "character", - password = "character"), - function(username, password) - { - new("cred_env", - username = username, - password = password) - } -) - -##' Create a new personal access token credential object -##' -##' The personal access token is stored in an envrionmental variable. -##' Environmental variables can be written to the file -##' \code{.Renviron}. This file is read by \emph{R} during startup, -##' see \code{\link[base]{Startup}}. On GitHub, personal access tokens -##' function like ordinary OAuth access tokens. They can be used -##' instead of a password for Git over HTTPS, see -##' \url{https://help.github.com/articles/creating-an-access-token-for-command-line-use/} -##' @family git credential functions -##' @param token The name of the environmental variable that holds the -##' personal access token for the authentication. Defualt is -##' \code{GITHUB_PAT}. -##' @return A S4 \code{cred_token} object -##' @export -##' @examples -##' \dontrun{ -##' ## Create a personal access token credential object. -##' ## This example assumes that the token is stored in -##' ## the 'GITHUB_PAT' environmental variable. -##' repo <- repository("git2r") -##' cred <- cred_token() -##' push(repo, credentials = cred) -##' } -cred_token <- function(token = "GITHUB_PAT") -{ - new("cred_token", token = token) -} - -##' Create a new plain-text username and password credential object -##' -##' @rdname cred_user_pass-methods -##' @family git credential functions -##' @param username The username of the credential -##' @param password The password of the credential -##' @return A S4 \code{cred_user_pass} object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create a plain-text username and password credential object -##' cred_user_pass("Random Developer", "SecretPassword") -##' } -setGeneric("cred_user_pass", - signature = c("username", "password"), - function(username, password) - standardGeneric("cred_user_pass")) - -##' @rdname cred_user_pass-methods -##' @export -setMethod("cred_user_pass", - signature(username = "character", - password = "character"), - function(username, password) - { - new("cred_user_pass", - username = username, - password = password) - } -) - -##' Create a new passphrase-protected ssh key credential object -##' -##' @family git credential functions -##' @param publickey The path to the public key of the -##' credential. Default is \code{'~/.ssh/id_rsa.pub'} -##' @param privatekey The path to the private key of the -##' credential. Default is \code{'~/.ssh/id_rsa'} -##' @param passphrase The passphrase of the credential. Default is -##' \code{character(0)}. If getPass is installed and private key is -##' passphrase protected \code{getPass::getPass()} will be called -##' to allow for interactive and obfuscated interactive input of -##' the passphrase. -##' @return A S4 \code{cred_ssh_key} object -##' @export -##' @examples -##' \dontrun{ -##' ## Create a ssh key credential object. It can optionally be -##' ## passphrase-protected -##' cred <- cred_ssh_key("~/.ssh/id_rsa.pub", "~/.ssh/id_rsa") -##' repo <- repository("git2r") -##' push(repo, credentials = cred) -##' } -cred_ssh_key <- function (publickey = "~/.ssh/id_rsa.pub", - privatekey = "~/.ssh/id_rsa", - passphrase = character(0)) -{ - publickey = normalizePath(publickey, mustWork = TRUE) - privatekey = normalizePath(privatekey, mustWork = TRUE) - - if (length(passphrase) == 0) { - if (ssh_key_needs_passphrase(privatekey)) { - if (requireNamespace("getPass", quietly = TRUE)) { - passphrase <- getPass::getPass() - } - } - } - - new("cred_ssh_key", - publickey = publickey, - privatekey = privatekey, - passphrase = passphrase) -} - -##' Check if private key is passphrase protected -##' @param privatekey The path to the private key of the -##' credential. Default is \code{'~/.ssh/id_rsa'} -##' @keywords internal -ssh_key_needs_passphrase <- function(privatekey = "~/.ssh/id_rsa"){ - private_content <- readLines(privatekey, n=3) - contains_encrypted <- grepl("encrypted", private_content , ignore.case = TRUE) - return( - any(contains_encrypted) - ) -} diff -Nru r-cran-git2r-0.21.0/R/credential.R r-cran-git2r-0.22.1/R/credential.R --- r-cran-git2r-0.21.0/R/credential.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/credential.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,210 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013 - 2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Create a new environmental credential object +##' +##' Environmental variables can be written to the file +##' \code{.Renviron}. This file is read by \emph{R} during startup, +##' see \code{\link[base]{Startup}}. +##' @family git credential functions +##' @param username The name of the environmental variable that holds +##' the username for the authentication. +##' @param password The name of the environmental variable that holds +##' the password for the authentication. +##' @return A list of class \code{cred_env} with entries: +##' \describe{ +##' \item{username}{ +##' The name of the environmental variable that holds +##' the username for the authentication. +##' } +##' \item{password}{ +##' The name of the environmental variable that holds +##' the password for the authentication. +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Create an environmental credential object for the username and +##' ## password. +##' cred <- cred_env("NAME_OF_ENV_VARIABLE_WITH_USERNAME", +##' "NAME_OF_ENV_VARIABLE_WITH_PASSWORD") +##' repo <- repository("git2r") +##' push(repo, credentials = cred) +##' } +cred_env <- function(username = NULL, password = NULL) { + structure(list(username = username, password = password), + class = "cred_env") +} + +##' Create a new personal access token credential object +##' +##' The personal access token is stored in an envrionmental variable. +##' Environmental variables can be written to the file +##' \code{.Renviron}. This file is read by \emph{R} during startup, +##' see \code{\link[base]{Startup}}. On GitHub, personal access tokens +##' function like ordinary OAuth access tokens. They can be used +##' instead of a password for Git over HTTPS, see +##' \url{https://help.github.com/articles/creating-an-access-token-for-command-line-use/} +##' @family git credential functions +##' @param token The name of the environmental variable that holds the +##' personal access token for the authentication. Defualt is +##' \code{GITHUB_PAT}. +##' @return A list of class \code{cred_token} with entry: +##' \describe{ +##' \item{token}{ +##' The name of the environmental variable that holds +##' the personal access token for the authentication. +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Create a personal access token credential object. +##' ## This example assumes that the token is stored in +##' ## the 'GITHUB_PAT' environmental variable. +##' repo <- repository("git2r") +##' cred <- cred_token() +##' push(repo, credentials = cred) +##' } +cred_token <- function(token = "GITHUB_PAT") { + structure(list(token = token), class = "cred_token") +} + +##' Create a new plain-text username and password credential object +##' +##' @family git credential functions +##' @param username The username of the credential +##' @param password The password of the credential +##' @return A list of class \code{cred_user_pass} with entries: +##' \describe{ +##' \item{username}{ +##' The username of the credential +##' } +##' \item{password}{ +##' The password of the credential +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Create a plain-text username and password credential object +##' cred_user_pass("Random Developer", "SecretPassword") +##' } +cred_user_pass <- function(username = NULL, password = NULL) { + structure(list(username = username, password = password), + class = "cred_user_pass") +} + +##' Create a new passphrase-protected ssh key credential object +##' +##' @family git credential functions +##' @param publickey The path to the public key of the +##' credential. Default is \code{ssh_path("id_rsa.pub")} +##' @param privatekey The path to the private key of the +##' credential. Default is \code{ssh_path("id_rsa")} +##' @param passphrase The passphrase of the credential. Default is +##' \code{character(0)}. If getPass is installed and private key +##' is passphrase protected \code{getPass::getPass()} will be +##' called to allow for interactive and obfuscated interactive +##' input of the passphrase. +##' @return A list of class \code{cred_ssh_key} with entries: +##' \describe{ +##' \item{publickey}{ +##' The path to the public key of the credential +##' } +##' \item{privatekey}{ +##' The path to the private key of the credential +##' } +##' \item{passphrase}{ +##' The passphrase of the credential +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Create a ssh key credential object. It can optionally be +##' ## passphrase-protected +##' cred <- cred_ssh_key(ssh_path("id_rsa.pub"), ssh_path("id_rsa")) +##' repo <- repository("git2r") +##' push(repo, credentials = cred) +##' } +cred_ssh_key <- function (publickey = ssh_path("id_rsa.pub"), + privatekey = ssh_path("id_rsa"), + passphrase = character(0)) +{ + publickey = normalizePath(publickey, mustWork = TRUE) + privatekey = normalizePath(privatekey, mustWork = TRUE) + + if (length(passphrase) == 0) { + if (ssh_key_needs_passphrase(privatekey)) { + if (requireNamespace("getPass", quietly = TRUE)) { + passphrase <- getPass::getPass() + } + } + } + + structure(list(publickey = publickey, + privatekey = privatekey, + passphrase = passphrase), + class = "cred_ssh_key") +} + +##' Check if private key is passphrase protected +##' @param privatekey The path to the private key of the +##' credential. Default is \code{ssh_path("id_rsa")} +##' @noRd +ssh_key_needs_passphrase <- function(privatekey = ssh_path("id_rsa")) { + private_content <- readLines(privatekey, n = 3) + contains_encrypted <- grepl("encrypted", private_content, ignore.case = TRUE) + any(contains_encrypted) +} + +##' Compose usual path to ssh keys +##' +##' This function provides a consistent means across OS-types to access the +##' \code{.ssh} directory. +##' +##' On Windows-based systems, +##' \code{path.expand("~")} returns \code{"C:/Users/username/Documents"}, +##' whereas the usual path to the \code{.ssh} directory is +##' \code{"C:/Users/username"}. +##' +##' On other operating systems, \code{path.expand("~")} returns the usual path +##' to the \code{.ssh} directory. +##' +##' Calling \code{ssh_path()} with no arguments will return the usual path to +##' the \code{.ssh} directory. +##' +##' @param file basename of file for which path is requested +##' @return Full path to the file +##' @export +##' @examples +##' ssh_path() +##' ssh_path("is_rsa.pub") +ssh_path <- function(file = "") { + file.path(home_dir(), ".ssh", file) +} + +# Return the user's home directory regardless of operating system +home_dir <- function() { + if (.Platform$OS.type == "windows") { + home <- Sys.getenv("USERPROFILE") + } else { + home <- path.expand("~") + } + return(home) +} diff -Nru r-cran-git2r-0.21.0/R/diff.r r-cran-git2r-0.22.1/R/diff.r --- r-cran-git2r-0.21.0/R/diff.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/diff.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,355 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -#' Number of files in git_diff object -#' -#' @docType methods -#' @param x The git_diff \code{object} -#' @return a non-negative integer -#' @keywords methods -#' @export -setMethod("length", - signature(x = "git_diff"), - function(x) - { - length(x@files) - } -) - -##' Show a diff -##' -##' @aliases show,git_diff-methods -##' @docType methods -##' @param object The diff \code{object}. -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add, commit -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Commit message") -##' -##' ## Change the file -##' writeLines(c("Hello again!", "Here is a second line", "And a third"), -##' file.path(path, "test.txt")) -##' -##' ## Brief summary of diff between index and workdir -##' diff(repo) -##' } -setMethod("show", - signature(object = "git_diff"), - function(object) - { - cat("Old: ") - if (is.character(object@old)) { - cat(object@old, "\n") - } else if (is(object@old, "git_tree")) { - show(object@old) - } else { - cat("\n") - show(object@old) - } - cat("New: ") - if (is.character(object@new)) { - cat(object@new, "\n") - } else if (is(object@new, "git_tree")) { - show(object@new) - } else { - cat("\n") - show(object@new) - } - } -) - -lines_per_file <- function(diff) { - lapply(diff@files, function(x) { - del <- add <- 0 - for (h in x@hunks) { - for (l in h@lines) { - if (l@origin == 45) { - del <- del + l@num_lines - } else if (l@origin == 43) { - add <- add + l@num_lines - } - } - } - list(file=x@new_file, del=del, add=add) - }) -} - -print_lines_per_file <- function(diff) { - lpf <- lines_per_file(diff) - files <- vapply(lpf, function(x) x$file, character(1)) - del <- vapply(lpf, function(x) x$del, numeric(1)) - add <- vapply(lpf, function(x) x$add, numeric(1)) - paste0(format(files), " | ", "-", format(del), " +", format(add)) -} - -hunks_per_file <- function(diff) { - vapply(diff@files, function(x) length(x@hunks), numeric(1)) -} - -##' Show the summary of a diff -##' -##' @aliases summary,git_diff-methods -##' @docType methods -##' @param object The diff \code{object}. -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add, commit -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Commit message") -##' -##' ## Change the file -##' writeLines(c("Hello again!", "Here is a second line", "And a third"), -##' file.path(path, "test.txt")) -##' -##' ## diff between index and workdir -##' diff_1 <- diff(repo) -##' summary(diff_1) -##' -##' ## Diff between index and HEAD is empty -##' diff_2 <- diff(repo, index=TRUE) -##' summary(diff_2) -##' -##' ## Diff between tree and working dir, same as diff_1 -##' diff_3 <- diff(tree(commits(repo)[[1]])) -##' summary(diff_3) -##' -##' ## Add changes, diff between index and HEAD is the same as diff_1 -##' add(repo, "test.txt") -##' diff_4 <- diff(repo, index=TRUE) -##' summary(diff_4) -##' -##' ## Diff between tree and index -##' diff_5 <- diff(tree(commits(repo)[[1]]), index=TRUE) -##' summary(diff_5) -##' -##' ## Diff between two trees -##' commit(repo, "Second commit") -##' tree_1 <- tree(commits(repo)[[2]]) -##' tree_2 <- tree(commits(repo)[[1]]) -##' diff_6 <- diff(tree_1, tree_2) -##' summary(diff_6) -##' -##' ## Binary files -##' set.seed(42) -##' writeBin(as.raw((sample(0:255, 1000, replace=TRUE))), -##' con=file.path(path, "test.bin")) -##' add(repo, "test.bin") -##' diff_7 <- diff(repo, index=TRUE) -##' summary(diff_7) -##' } -setMethod("summary", - signature(object = "git_diff"), - function(object, ...) - { - show(object) - if (length(object) > 0) { - plpf <- print_lines_per_file(object) - hpf <- hunks_per_file(object) - hunk_txt <- ifelse(hpf > 1, " hunks", - ifelse(hpf > 0, " hunk", - " hunk (binary file)")) - phpf <- paste0(" in ", format(hpf), hunk_txt) - cat("Summary:", paste0(plpf, phpf), sep="\n") - } else { - cat("No changes.\n") - } - } -) - -#' Changes between commits, trees, working tree, etc. -#' -#' @rdname diff-methods -#' @export -#' @docType methods -#' @param x A \code{git_repository} object or the old -#' \code{git_tree} object to compare to. -#' @param index \describe{ -#' \item{\emph{When object equals a git_repository}}{ -#' Whether to compare the index to HEAD. If FALSE (the default), -#' then the working tree is compared to the index. -#' } -#' \item{\emph{When object equals a git_tree}}{ -#' Whether to use the working directory (by default), or the index -#' (if set to TRUE) in the comparison to \code{object}. -#' } -#' } -#' @param as_char logical: should the result be converted to a -#' character string?. Default is FALSE. -#' @param filename If as_char is TRUE, then the diff can be written to -#' a file with name filename (the file is overwritten if it -#' exists). Default is NULL. -#' @param ... Additional arguments affecting the diff produced -#' @return A \code{\linkS4class{git_diff}} object if as_char is -#' FALSE. If as_char is TRUE and filename is NULL, a character string, -#' else NULL. -#' @keywords methods -#' @examples -#' \dontrun{ -#' ## Initialize a repository -#' path <- tempfile(pattern="git2r-") -#' dir.create(path) -#' repo <- init(path) -#' -#' ## Config user -#' config(repo, user.name="Alice", user.email="alice@@example.org") -#' -#' ## Create a file, add, commit -#' writeLines("Hello world!", file.path(path, "test.txt")) -#' add(repo, "test.txt") -#' commit(repo, "Commit message") -#' -#' ## Change the file -#' writeLines(c("Hello again!", "Here is a second line", "And a third"), -#' file.path(path, "test.txt")) -#' -#' ## diff between index and workdir -#' diff_1 <- diff(repo) -#' summary(diff_1) -#' cat(diff(repo, as_char=TRUE)) -#' -#' ## Diff between index and HEAD is empty -#' diff_2 <- diff(repo, index=TRUE) -#' summary(diff_2) -#' cat(diff(repo, index=TRUE, as_char=TRUE)) -#' -#' ## Diff between tree and working dir, same as diff_1 -#' diff_3 <- diff(tree(commits(repo)[[1]])) -#' summary(diff_3) -#' cat(diff(tree(commits(repo)[[1]]), as_char=TRUE)) -#' -#' ## Add changes, diff between index and HEAD is the same as diff_1 -#' add(repo, "test.txt") -#' diff_4 <- diff(repo, index=TRUE) -#' summary(diff_4) -#' cat(diff(repo, index=TRUE, as_char=TRUE)) -#' -#' ## Diff between tree and index -#' diff_5 <- diff(tree(commits(repo)[[1]]), index=TRUE) -#' summary(diff_5) -#' cat(diff(tree(commits(repo)[[1]]), index=TRUE, as_char=TRUE)) -#' -#' ## Diff between two trees -#' commit(repo, "Second commit") -#' tree_1 <- tree(commits(repo)[[2]]) -#' tree_2 <- tree(commits(repo)[[1]]) -#' diff_6 <- diff(tree_1, tree_2) -#' summary(diff_6) -#' cat(diff(tree_1, tree_2, as_char=TRUE)) -#' -#' ## Binary files -#' set.seed(42) -#' writeBin(as.raw((sample(0:255, 1000, replace=TRUE))), -#' con=file.path(path, "test.bin")) -#' add(repo, "test.bin") -#' diff_7 <- diff(repo, index=TRUE) -#' summary(diff_7) -#' cat(diff(repo, index=TRUE, as_char=TRUE)) -#' } -setMethod("diff", - signature(x = "git_repository"), - function(x, - index = FALSE, - as_char = FALSE, - filename = NULL, - ...) - { - if (as_char) { - ## Make sure filename is character(0) to write to a - ## character vector or a character vector with path in - ## order to write to a file. - filename <- as.character(filename) - if (any(identical(filename, NA_character_), - identical(nchar(filename), 0L))) { - filename <- character(0) - } else if (length(filename)) { - filename <- normalizePath(filename, mustWork = FALSE) - } - } else { - ## Make sure filename is NULL - filename <- NULL - } - - .Call(git2r_diff, x, NULL, NULL, index, filename) - } -) - -#' @rdname diff-methods -#' @param new_tree The new git_tree object to compare, or NULL. -#' If NULL, then we use the working directory or the index (see -#' the \code{index} argument). -#' @export -setMethod("diff", - signature(x = "git_tree"), - function(x, - new_tree = NULL, - index = FALSE, - as_char = FALSE, - filename = NULL, - ...) - { - if (as_char) { - ## Make sure filename is character(0) to write to a - ## character vector or a character vector with path in - ## order to write to a file. - filename <- as.character(filename) - if (any(identical(filename, NA_character_), - identical(nchar(filename), 0L))) { - filename <- character(0) - } else if (length(filename)) { - filename <- normalizePath(filename, mustWork = FALSE) - } - } else { - ## Make sure filename is NULL - filename <- NULL - } - - if (!is.null(new_tree)) { - if (! is(new_tree, "git_tree")) { - stop("Not a git tree") - } - if (x@repo@path != new_tree@repo@path) { - stop("Cannot compare trees in different repositories") - } - } - - .Call(git2r_diff, NULL, x, new_tree, index, filename) - } -) diff -Nru r-cran-git2r-0.21.0/R/diff.R r-cran-git2r-0.22.1/R/diff.R --- r-cran-git2r-0.21.0/R/diff.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/diff.R 2018-07-01 20:59:27.000000000 +0000 @@ -0,0 +1,244 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Number of files in git_diff object +##' +##' @param x The git_diff \code{object} +##' @return a non-negative integer +##' @export +length.git_diff <- function(x) { + length(x$files) +} + +##' @export +print.git_diff <- function(x, ...) { + cat("Old: ") + if (is.character(x$old)) { + cat(x$old, "\n") + } else if (inherits(x$old, "git_tree")) { + print(x$old) + } else { + cat("\n") + print(x$old) + } + cat("New: ") + if (is.character(x$new)) { + cat(x$new, "\n") + } else if (inherits(x$new, "git_tree")) { + print(x$new) + } else { + cat("\n") + print(x$new) + } +} + +lines_per_file <- function(diff) { + lapply(diff$files, function(x) { + del <- add <- 0 + for (h in x$hunks) { + for (l in h$lines) { + if (l$origin == 45) { + del <- del + l$num_lines + } else if (l$origin == 43) { + add <- add + l$num_lines + } + } + } + list(file=x$new_file, del=del, add=add) + }) +} + +print_lines_per_file <- function(diff) { + lpf <- lines_per_file(diff) + files <- vapply(lpf, function(x) x$file, character(1)) + del <- vapply(lpf, function(x) x$del, numeric(1)) + add <- vapply(lpf, function(x) x$add, numeric(1)) + paste0(format(files), " | ", "-", format(del), " +", format(add)) +} + +hunks_per_file <- function(diff) { + vapply(diff$files, function(x) length(x$hunks), numeric(1)) +} + +##' @export +summary.git_diff <- function(object, ...) { + print(object) + if (length(object) > 0) { + plpf <- print_lines_per_file(object) + hpf <- hunks_per_file(object) + hunk_txt <- ifelse(hpf > 1, " hunks", + ifelse(hpf > 0, " hunk", + " hunk (binary file)")) + phpf <- paste0(" in ", format(hpf), hunk_txt) + cat("Summary:", paste0(plpf, phpf), sep="\n") + } else { + cat("No changes.\n") + } +} + +##' Changes between commits, trees, working tree, etc. +##' +##' @rdname diff-methods +##' @export +##' @param x A \code{git_repository} object or the old \code{git_tree} +##' object to compare to. +##' @param index \describe{ +##' \item{\emph{When object equals a git_repository}}{ +##' Whether to compare the index to HEAD. If FALSE (the default), +##' then the working tree is compared to the index. +##' } +##' \item{\emph{When object equals a git_tree}}{ +##' Whether to use the working directory (by default), or the index +##' (if set to TRUE) in the comparison to \code{object}. +##' } +##' } +##' @param as_char logical: should the result be converted to a +##' character string?. Default is FALSE. +##' @param filename If as_char is TRUE, then the diff can be written +##' to a file with name filename (the file is overwritten if it +##' exists). Default is NULL. +##' @param ... Additional arguments affecting the diff produced +##' @return A \code{git_diff} object if as_char is FALSE. If as_char +##' is TRUE and filename is NULL, a character string, else NULL. +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add, commit +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "Commit message") +##' +##' ## Change the file +##' writeLines(c("Hello again!", "Here is a second line", "And a third"), +##' file.path(path, "test.txt")) +##' +##' ## diff between index and workdir +##' diff_1 <- diff(repo) +##' summary(diff_1) +##' cat(diff(repo, as_char=TRUE)) +##' +##' ## Diff between index and HEAD is empty +##' diff_2 <- diff(repo, index=TRUE) +##' summary(diff_2) +##' cat(diff(repo, index=TRUE, as_char=TRUE)) +##' +##' ## Diff between tree and working dir, same as diff_1 +##' diff_3 <- diff(tree(commits(repo)[[1]])) +##' summary(diff_3) +##' cat(diff(tree(commits(repo)[[1]]), as_char=TRUE)) +##' +##' ## Add changes, diff between index and HEAD is the same as diff_1 +##' add(repo, "test.txt") +##' diff_4 <- diff(repo, index=TRUE) +##' summary(diff_4) +##' cat(diff(repo, index=TRUE, as_char=TRUE)) +##' +##' ## Diff between tree and index +##' diff_5 <- diff(tree(commits(repo)[[1]]), index=TRUE) +##' summary(diff_5) +##' cat(diff(tree(commits(repo)[[1]]), index=TRUE, as_char=TRUE)) +##' +##' ## Diff between two trees +##' commit(repo, "Second commit") +##' tree_1 <- tree(commits(repo)[[2]]) +##' tree_2 <- tree(commits(repo)[[1]]) +##' diff_6 <- diff(tree_1, tree_2) +##' summary(diff_6) +##' cat(diff(tree_1, tree_2, as_char=TRUE)) +##' +##' ## Binary files +##' set.seed(42) +##' writeBin(as.raw((sample(0:255, 1000, replace=TRUE))), +##' con=file.path(path, "test.bin")) +##' add(repo, "test.bin") +##' diff_7 <- diff(repo, index=TRUE) +##' summary(diff_7) +##' cat(diff(repo, index=TRUE, as_char=TRUE)) +##' } +diff.git_repository <- function(x, + index = FALSE, + as_char = FALSE, + filename = NULL, + ...) +{ + if (as_char) { + ## Make sure filename is character(0) to write to a + ## character vector or a character vector with path in + ## order to write to a file. + filename <- as.character(filename) + if (any(identical(filename, NA_character_), + identical(nchar(filename), 0L))) { + filename <- character(0) + } else if (length(filename)) { + filename <- normalizePath(filename, mustWork = FALSE) + } + } else { + ## Make sure filename is NULL + filename <- NULL + } + + .Call(git2r_diff, x, NULL, NULL, index, filename) +} + +##' @rdname diff-methods +##' @param new_tree The new git_tree object to compare, or NULL. If +##' NULL, then we use the working directory or the index (see the +##' \code{index} argument). +##' @export +diff.git_tree <- function(x, + new_tree = NULL, + index = FALSE, + as_char = FALSE, + filename = NULL, + ...) +{ + if (as_char) { + ## Make sure filename is character(0) to write to a character + ## vector or a character vector with path in order to write to + ## a file. + filename <- as.character(filename) + if (any(identical(filename, NA_character_), + identical(nchar(filename), 0L))) { + filename <- character(0) + } else if (length(filename)) { + filename <- normalizePath(filename, mustWork = FALSE) + } + } else { + ## Make sure filename is NULL + filename <- NULL + } + + if (!is.null(new_tree)) { + if (!inherits(new_tree, "git_tree")) { + stop("Not a git tree") + } + if (x$repo$path != new_tree$repo$path) { + stop("Cannot compare trees in different repositories") + } + } + + .Call(git2r_diff, NULL, x, new_tree, index, filename) +} + +##' @export +base::diff diff -Nru r-cran-git2r-0.21.0/R/fetch.r r-cran-git2r-0.22.1/R/fetch.r --- r-cran-git2r-0.21.0/R/fetch.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/fetch.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Fetch new data and update tips -##' -##' @rdname fetch-methods -##' @docType methods -##' @param repo the repository -##' @param name the remote's name -##' @param credentials The credentials for remote repository -##' access. Default is NULL. To use and query an ssh-agent for the -##' ssh key credentials, let this parameter be NULL (the default). -##' @param verbose Print information each time a reference is updated -##' locally. Default is \code{TRUE}. -##' @param refspec The refs to fetch and which local refs to update, -##' see examples. Pass NULL to use the -##' \code{remote..fetch} variable. Default is -##' \code{NULL}. -##' @return invisible \code{\linkS4class{git_transfer_progress}} -##' object -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize three temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' -##' dir.create(path_bare) -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' -##' bare_repo <- init(path_bare, bare = TRUE) -##' repo_1 <- clone(path_bare, path_repo_1) -##' repo_2 <- clone(path_bare, path_repo_2) -##' -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' config(repo_2, user.name="Bob", user.email="bob@@example.org") -##' -##' ## Add changes to repo 1 -##' writeLines("Lorem ipsum dolor sit amet", -##' con = file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Commit message") -##' -##' ## Push changes from repo 1 to origin (bare_repo) -##' push(repo_1, "origin", "refs/heads/master") -##' -##' ## Fetch changes from origin (bare_repo) to repo 2 -##' fetch(repo_2, "origin") -##' -##' ## List updated heads -##' fetch_heads(repo_2) -##' -##' ## Checking out GitHub pull requests locally -##' path <- tempfile(pattern="ghit-") -##' repo <- clone("https://github.com/leeper/ghit", path) -##' fetch(repo, "origin", refspec = "pull/13/head:refs/heads/BRANCHNAME") -##' checkout(repo, "BRANCHNAME") -##' summary(repo) -##' } -setGeneric("fetch", - signature = "repo", - function(repo, - name, - credentials = NULL, - verbose = TRUE, - refspec = NULL) - standardGeneric("fetch")) - -##' @rdname fetch-methods -##' @export -setMethod("fetch", - signature(repo = "git_repository"), - function(repo, name, credentials, verbose, refspec) - { - result <- .Call( - git2r_remote_fetch, - repo, - name, - credentials, - "fetch", - verbose, - refspec) - - invisible(result) - } -) - -##' Get updated heads during the last fetch. -##' -##' @rdname fetch_heads-methods -##' @docType methods -##' @param repo the repository -##' @return list with the S4 class \code{\linkS4class{git_fetch_head}} -##' entries. NULL if there is no FETCH_HEAD file. -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize three temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' -##' dir.create(path_bare) -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' -##' bare_repo <- init(path_bare, bare = TRUE) -##' repo_1 <- clone(path_bare, path_repo_1) -##' repo_2 <- clone(path_bare, path_repo_2) -##' -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' config(repo_2, user.name="Bob", user.email="bob@@example.org") -##' -##' ## Add changes to repo 1 -##' writeLines("Lorem ipsum dolor sit amet", -##' con = file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Commit message") -##' -##' ## Push changes from repo 1 to origin (bare_repo) -##' push(repo_1, "origin", "refs/heads/master") -##' -##' ## Fetch changes from origin (bare_repo) to repo 2 -##' fetch(repo_2, "origin") -##' -##' ## List updated heads -##' fetch_heads(repo_2) -##' } -setGeneric("fetch_heads", - signature = "repo", - function(repo) - standardGeneric("fetch_heads")) - -##' @rdname fetch_heads-methods -##' @export -setMethod("fetch_heads", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_repository_fetch_heads, repo) - } -) diff -Nru r-cran-git2r-0.21.0/R/fetch.R r-cran-git2r-0.22.1/R/fetch.R --- r-cran-git2r-0.21.0/R/fetch.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/fetch.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,145 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Fetch new data and update tips +##' +##' @template repo-param +##' @param name the remote's name +##' @param credentials The credentials for remote repository +##' access. Default is NULL. To use and query an ssh-agent for the +##' ssh key credentials, let this parameter be NULL (the default). +##' @param verbose Print information each time a reference is updated +##' locally. Default is \code{TRUE}. +##' @param refspec The refs to fetch and which local refs to update, +##' see examples. Pass NULL to use the +##' \code{remote..fetch} variable. Default is +##' \code{NULL}. +##' @return invisible list of class \code{git_transfer_progress} +##' with statistics from the fetch operation: +##' \describe{ +##' \item{total_objects}{ +##' Number of objects in the packfile being downloaded +##' } +##' \item{indexed_objects}{ +##' Received objects that have been hashed +##' } +##' \item{received_objects}{ +##' Objects which have been downloaded +##' } +##' \item{total_deltas}{ +##' Total number of deltas in the pack +##' } +##' \item{indexed_deltas}{ +##' Deltas which have been indexed +##' } +##' \item{local_objects}{ +##' Locally-available objects that have been injected in order to +##' fix a thin pack +##' } +##' \item{received_bytes}{ +##' Size of the packfile received up to now +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize three temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' +##' dir.create(path_bare) +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' +##' bare_repo <- init(path_bare, bare = TRUE) +##' repo_1 <- clone(path_bare, path_repo_1) +##' repo_2 <- clone(path_bare, path_repo_2) +##' +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' config(repo_2, user.name="Bob", user.email="bob@@example.org") +##' +##' ## Add changes to repo 1 +##' writeLines("Lorem ipsum dolor sit amet", +##' con = file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Commit message") +##' +##' ## Push changes from repo 1 to origin (bare_repo) +##' push(repo_1, "origin", "refs/heads/master") +##' +##' ## Fetch changes from origin (bare_repo) to repo 2 +##' fetch(repo_2, "origin") +##' +##' ## List updated heads +##' fetch_heads(repo_2) +##' +##' ## Checking out GitHub pull requests locally +##' path <- tempfile(pattern="ghit-") +##' repo <- clone("https://github.com/leeper/ghit", path) +##' fetch(repo, "origin", refspec = "pull/13/head:refs/heads/BRANCHNAME") +##' checkout(repo, "BRANCHNAME") +##' summary(repo) +##' } +fetch <- function(repo = ".", name = NULL, credentials = NULL, + verbose = TRUE, refspec = NULL) +{ + invisible(.Call(git2r_remote_fetch, lookup_repository(repo), + name, credentials, "fetch", verbose, refspec)) +} + +##' Get updated heads during the last fetch. +##' +##' @template repo-param +##' @return list with \code{git_fetch_head} entries. NULL if there is +##' no FETCH_HEAD file. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize three temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' +##' dir.create(path_bare) +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' +##' bare_repo <- init(path_bare, bare = TRUE) +##' repo_1 <- clone(path_bare, path_repo_1) +##' repo_2 <- clone(path_bare, path_repo_2) +##' +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' config(repo_2, user.name="Bob", user.email="bob@@example.org") +##' +##' ## Add changes to repo 1 +##' writeLines("Lorem ipsum dolor sit amet", +##' con = file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Commit message") +##' +##' ## Push changes from repo 1 to origin (bare_repo) +##' push(repo_1, "origin", "refs/heads/master") +##' +##' ## Fetch changes from origin (bare_repo) to repo 2 +##' fetch(repo_2, "origin") +##' +##' ## List updated heads +##' fetch_heads(repo_2) +##' } +fetch_heads <- function(repo = ".") { + .Call(git2r_repository_fetch_heads, lookup_repository(repo)) +} diff -Nru r-cran-git2r-0.21.0/R/git2r.r r-cran-git2r-0.22.1/R/git2r.r --- r-cran-git2r-0.21.0/R/git2r.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/git2r.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' git2r: R bindings to the libgit2 library -##' -##' @docType package -##' @name git2r -##' @import methods -##' @useDynLib git2r, .registration=TRUE -NULL - -##' Unload hook function -##' -##' @param libpath A character string giving the complete path to the -##' package. -##' @keywords internal -.onUnload <- function(libpath) -{ - library.dynam.unload("git2r", libpath) -} diff -Nru r-cran-git2r-0.21.0/R/git2r.R r-cran-git2r-0.22.1/R/git2r.R --- r-cran-git2r-0.21.0/R/git2r.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/git2r.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,31 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' git2r: R bindings to the libgit2 library +##' +##' @docType package +##' @name git2r +##' @useDynLib git2r, .registration=TRUE +NULL + +##' Unload hook function +##' +##' @param libpath A character string giving the complete path to the +##' package. +##' @noRd +.onUnload <- function(libpath) { + library.dynam.unload("git2r", libpath) +} diff -Nru r-cran-git2r-0.21.0/R/index.r r-cran-git2r-0.22.1/R/index.r --- r-cran-git2r-0.21.0/R/index.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/index.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,289 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Add file(s) to index -##' -##' @rdname add-methods -##' @docType methods -##' @param repo The repository \code{object}. -##' @param path Character vector with file names or shell glob -##' patterns that will matched against files in the repository's -##' working directory. Each file that matches will be added to the -##' index (either updating an existing entry or adding a new entry). -##' @param ... Additional arguments to the method -##' @param force Add ignored files. Default is FALSE. -##' @return invisible(NULL) -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file -##' writeLines("a", file.path(path, "a.txt")) -##' -##' ## Add file to repository and view status -##' add(repo, "a.txt") -##' status(repo) -##' -##' ## Add file with a leading './' when the repository working -##' ## directory is the current working directory -##' setwd(path) -##' writeLines("b", file.path(path, "b.txt")) -##' add(repo, "./b.txt") -##' status(repo) -##' -##' ## Add a file in a sub-folder with sub-folder as the working -##' ## directory. Create a file in the root of the repository -##' ## working directory that will remain untracked. -##' dir.create(file.path(path, "sub_dir")) -##' setwd("./sub_dir") -##' writeLines("c", file.path(path, "c.txt")) -##' writeLines("c", file.path(path, "sub_dir/c.txt")) -##' add(repo, "c.txt") -##' status(repo) -##' -##' ## Add files with glob expansion when the current working -##' ## directory is outside the repository's working directory. -##' setwd(tempdir()) -##' dir.create(file.path(path, "glob_dir")) -##' writeLines("d", file.path(path, "glob_dir/d.txt")) -##' writeLines("e", file.path(path, "glob_dir/e.txt")) -##' writeLines("f", file.path(path, "glob_dir/f.txt")) -##' writeLines("g", file.path(path, "glob_dir/g.md")) -##' add(repo, "glob_dir/*txt") -##' status(repo) -##' -##' ## Add file with glob expansion with a relative path when -##' ## the current working directory is inside the repository's -##' ## working directory. -##' setwd(path) -##' add(repo, "./glob_dir/*md") -##' status(repo) -##' } -setGeneric("add", - signature = c("repo", "path"), - function(repo, path, ...) - standardGeneric("add")) - -##' @rdname add-methods -##' @export -setMethod("add", - signature(repo = "git_repository", - path = "character"), - function(repo, path, force = FALSE) - { - ## Documentation for the pathspec argument in the - ## libgit2 function 'git_index_add_all' that git2r use - ## internally: - ## - ## The pathspec is a list of file names or shell glob - ## patterns that will matched against files in the - ## repository's working directory. Each file that - ## matches will be added to the index (either updating - ## an existing entry or adding a new entry). - - repo_wd <- normalizePath(workdir(repo), winslash = "/") - if (!length(grep("/$", repo_wd))) - repo_wd <- paste0(repo_wd, "/") - - path <- vapply(path, function(p) { - np <- suppressWarnings(normalizePath(p, winslash = "/")) - - ## Check if the normalized path is a non-file e.g. a - ## glob. - if (!file.exists(np)) { - ## Check if the normalized path starts with a - ## leading './' - if (length(grep("^[.]/", np))) { - nd <- suppressWarnings(normalizePath(dirname(p), - winslash = "/")) - if (!length(grep("/$", nd))) - nd <- paste0(nd, "/") - np <- paste0(nd, basename(np)) - } - } - - ## Check if the file is in the repository's working - ## directory, else let libgit2 handle this path - ## unmodified. - if (!length(grep(paste0("^", repo_wd), np))) - return(p) - - ## Change the path to be relative to the repository's - ## working directory. Substitute common prefix with "" - sub(paste0("^", repo_wd), "", np) - }, - character(1)) - - .Call(git2r_index_add_all, repo, path, force) - - invisible(NULL) - } -) - -##' Remove files from the working tree and from the index -##' -##' @rdname rm_file-methods -##' @docType methods -##' @param repo The repository \code{object}. -##' @param path character vector with filenames to remove. The path -##' must be relative to the repository's working folder. Only files -##' known to Git are removed. -##' @return invisible(NULL) -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file -##' writeLines("Hello world!", file.path(path, "file-to-remove.txt")) -##' -##' ## Add file to repository -##' add(repo, "file-to-remove.txt") -##' commit(repo, "First commit message") -##' -##' ## Remove file -##' rm_file(repo, "file-to-remove.txt") -##' -##' ## View status of repository -##' status(repo) -##' } -##' -setGeneric("rm_file", - signature = c("repo", "path"), - function(repo, path) - standardGeneric("rm_file")) - -##' @rdname rm_file-methods -##' @export -setMethod("rm_file", - signature(repo = "git_repository", - path = "character"), - function(repo, path) - { - if (length(path)) { - ## Check that files exists and are known to Git - if (!all(file.exists(paste0(workdir(repo), path)))) { - stop(sprintf("pathspec '%s' did not match any files. ", - path[!file.exists(paste0(workdir(repo), path))])) - } - - if (any(file.info(paste0(workdir(repo), path))$isdir)) { - stop(sprintf("pathspec '%s' did not match any files. ", - path[exists(paste0(workdir(repo), path))])) - } - - s <- status(repo, staged = TRUE, unstaged = TRUE, - untracked = TRUE, ignored = TRUE) - if (any(path %in% c(s$ignored, s$untracked))) { - stop(sprintf("pathspec '%s' did not match any files. ", - path[path %in% c(s$ignored, s$untracked)])) - } - - if (any(path %in% s$staged)) { - stop(sprintf("'%s' has changes staged in the index. ", - path[path %in% s$staged])) - } - - if (any(path %in% s$unstaged)) { - stop(sprintf("'%s' has local modifications. ", - path[path %in% s$unstaged])) - } - - ## Remove and stage files - lapply(path, function(x) { - file.remove(paste0(workdir(repo), x)) - .Call(git2r_index_remove_bypath, repo, x) - }) - } - - invisible(NULL) - } -) - -##' Remove an index entry corresponding to a file on disk -##' -##' @rdname index_remove_bypath-methods -##' @docType methods -##' @param repo The repository \code{object}. -##' @param path character vector with filenames to remove. The path -##' must be relative to the repository's working folder. It may -##' exist. If this file currently is the result of a merge -##' conflict, this file will no longer be marked as -##' conflicting. The data about the conflict will be moved to the -##' "resolve undo" (REUC) section. -##' @return invisible(NULL) -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file -##' writeLines("Hello world!", file.path(path, "file-to-remove.txt")) -##' -##' ## Add file to repository -##' add(repo, "file-to-remove.txt") -##' -##' ## View status of repository -##' status(repo) -##' -##' ## Remove file -##' index_remove_bypath(repo, "file-to-remove.txt") -##' -##' ## View status of repository -##' status(repo) -##' } -##' -setGeneric("index_remove_bypath", - signature = c("repo", "path"), - function(repo, path) - standardGeneric("index_remove_bypath")) - -##' @rdname index_remove_bypath-methods -##' @export -setMethod("index_remove_bypath", - signature(repo = "git_repository", - path = "character"), - function(repo, path) - { - if (length(path)) { - .Call(git2r_index_remove_bypath, repo, path) - } - - invisible(NULL) - } -) diff -Nru r-cran-git2r-0.21.0/R/index.R r-cran-git2r-0.22.1/R/index.R --- r-cran-git2r-0.21.0/R/index.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/index.R 2018-04-25 06:25:16.000000000 +0000 @@ -0,0 +1,244 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Add file(s) to index +##' +##' @template repo-param +##' @param path Character vector with file names or shell glob +##' patterns that will matched against files in the repository's +##' working directory. Each file that matches will be added to the +##' index (either updating an existing entry or adding a new +##' entry). +##' @param force Add ignored files. Default is FALSE. +##' @return invisible(NULL) +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file +##' writeLines("a", file.path(path, "a.txt")) +##' +##' ## Add file to repository and view status +##' add(repo, "a.txt") +##' status(repo) +##' +##' ## Add file with a leading './' when the repository working +##' ## directory is the current working directory +##' setwd(path) +##' writeLines("b", file.path(path, "b.txt")) +##' add(repo, "./b.txt") +##' status(repo) +##' +##' ## Add a file in a sub-folder with sub-folder as the working +##' ## directory. Create a file in the root of the repository +##' ## working directory that will remain untracked. +##' dir.create(file.path(path, "sub_dir")) +##' setwd("./sub_dir") +##' writeLines("c", file.path(path, "c.txt")) +##' writeLines("c", file.path(path, "sub_dir/c.txt")) +##' add(repo, "c.txt") +##' status(repo) +##' +##' ## Add files with glob expansion when the current working +##' ## directory is outside the repository's working directory. +##' setwd(tempdir()) +##' dir.create(file.path(path, "glob_dir")) +##' writeLines("d", file.path(path, "glob_dir/d.txt")) +##' writeLines("e", file.path(path, "glob_dir/e.txt")) +##' writeLines("f", file.path(path, "glob_dir/f.txt")) +##' writeLines("g", file.path(path, "glob_dir/g.md")) +##' add(repo, "glob_dir/*txt") +##' status(repo) +##' +##' ## Add file with glob expansion with a relative path when +##' ## the current working directory is inside the repository's +##' ## working directory. +##' setwd(path) +##' add(repo, "./glob_dir/*md") +##' status(repo) +##' } +add <- function(repo = ".", path = NULL, force = FALSE) +{ + ## Documentation for the pathspec argument in the libgit2 function + ## 'git_index_add_all' that git2r use internally: + ## + ## The pathspec is a list of file names or shell glob patterns + ## that will matched against files in the repository's working + ## directory. Each file that matches will be added to the index + ## (either updating an existing entry or adding a new entry). + + if (is.null(path) || !is.character(path)) + stop("'path' must be a character vector") + + repo <- lookup_repository(repo) + repo_wd <- normalizePath(workdir(repo), winslash = "/") + if (!length(grep("/$", repo_wd))) + repo_wd <- paste0(repo_wd, "/") + + path <- vapply(path, function(p) { + np <- suppressWarnings(normalizePath(p, winslash = "/")) + + ## Check if the normalized path is a non-file e.g. a glob. + if (!file.exists(np)) { + ## Check if the normalized path starts with a leading './' + if (length(grep("^[.]/", np))) { + nd <- suppressWarnings(normalizePath(dirname(p), winslash = "/")) + if (!length(grep("/$", nd))) + nd <- paste0(nd, "/") + np <- paste0(nd, basename(np)) + } + } + + ## Check if the file is in the repository's working directory, + ## else let libgit2 handle this path unmodified. + if (!length(grep(paste0("^", repo_wd), np))) + return(p) + + ## Change the path to be relative to the repository's working + ## directory. Substitute common prefix with "" + sub(paste0("^", repo_wd), "", np) + }, character(1)) + + .Call(git2r_index_add_all, repo, path, isTRUE(force)) + + invisible(NULL) +} + +##' Remove files from the working tree and from the index +##' +##' @template repo-param +##' @param path character vector with filenames to remove. The path +##' must be relative to the repository's working folder. Only +##' files known to Git are removed. +##' @return invisible(NULL) +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file +##' writeLines("Hello world!", file.path(path, "file-to-remove.txt")) +##' +##' ## Add file to repository +##' add(repo, "file-to-remove.txt") +##' commit(repo, "First commit message") +##' +##' ## Remove file +##' rm_file(repo, "file-to-remove.txt") +##' +##' ## View status of repository +##' status(repo) +##' } +rm_file <- function(repo = ".", path = NULL) { + if (is.null(path) || !is.character(path)) + stop("'path' must be a character vector") + + repo <- lookup_repository(repo) + + if (length(path)) { + wd <- workdir(repo) + + ## Check that files exists and are known to Git + if (!all(file.exists(file.path(wd, path)))) { + stop(sprintf("pathspec '%s' did not match any files. ", + path[!file.exists(file.path(wd, path))])) + } + + if (any(file.info(file.path(wd, path))$isdir)) { + stop(sprintf("pathspec '%s' did not match any files. ", + path[exists(file.path(wd, path))])) + } + + s <- status(repo, staged = TRUE, unstaged = TRUE, + untracked = TRUE, ignored = TRUE) + if (any(path %in% c(s$ignored, s$untracked))) { + stop(sprintf("pathspec '%s' did not match any files. ", + path[path %in% c(s$ignored, s$untracked)])) + } + + if (any(path %in% s$staged)) { + stop(sprintf("'%s' has changes staged in the index. ", + path[path %in% s$staged])) + } + + if (any(path %in% s$unstaged)) { + stop(sprintf("'%s' has local modifications. ", + path[path %in% s$unstaged])) + } + + ## Remove and stage files + lapply(path, function(x) { + file.remove(file.path(wd, x)) + .Call(git2r_index_remove_bypath, repo, x) + }) + } + + invisible(NULL) +} + +##' Remove an index entry corresponding to a file on disk +##' +##' @template repo-param +##' @param path character vector with filenames to remove. The path +##' must be relative to the repository's working folder. It may +##' exist. If this file currently is the result of a merge +##' conflict, this file will no longer be marked as +##' conflicting. The data about the conflict will be moved to the +##' "resolve undo" (REUC) section. +##' @return invisible(NULL) +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file +##' writeLines("Hello world!", file.path(path, "file-to-remove.txt")) +##' +##' ## Add file to repository +##' add(repo, "file-to-remove.txt") +##' +##' ## View status of repository +##' status(repo) +##' +##' ## Remove file +##' index_remove_bypath(repo, "file-to-remove.txt") +##' +##' ## View status of repository +##' status(repo) +##' } +index_remove_bypath <- function(repo = ".", path = NULL) { + .Call(git2r_index_remove_bypath, lookup_repository(repo), path) + invisible(NULL) +} diff -Nru r-cran-git2r-0.21.0/R/libgit2.r r-cran-git2r-0.22.1/R/libgit2.r --- r-cran-git2r-0.21.0/R/libgit2.r 2018-01-02 10:53:09.000000000 +0000 +++ r-cran-git2r-0.22.1/R/libgit2.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Compile time options for libgit2. -##' -##' @return A list with threads, https and ssh set to TRUE/FALSE. -##' @keywords methods -##' @export -##' @examples -##' libgit2_features() -libgit2_features <- function() { - .Call(git2r_libgit2_features) -} - -##' Version of the libgit2 library -##' -##' Version of the libgit2 library that the bundled source code is -##' based on -##' @return A list with major, minor and rev -##' @keywords methods -##' @export -##' @examples -##' libgit2_version() -libgit2_version <- function() { - .Call(git2r_libgit2_version) -} - -##' SHA of the libgit2 library -##' -##' SHA of the libgit2 library that the bundled source code is based -##' on -##' @return The 40 character hexadecimal string of the SHA-1 -##' @keywords methods -##' @export -##' @examples -##' libgit2_sha() -libgit2_sha <- function() "15e119375018fba121cf58e02a9f17fe22df0df8" - -##' Set the SSL certificate-authority locations -##' -##' @note Either parameter may be 'NULL', but not both. -##' @param filename Location of a file containing several certificates -##' concatenated together. Default NULL. -##' @param path Location of a directory holding several certificates, -##' one per file. Default NULL. -##' @return invisible(NULL) -##' @keywords methods -##' @export -ssl_cert_locations <- function(filename = NULL, path = NULL) -{ - invisible(.Call(git2r_ssl_cert_locations, filename, path)) -} diff -Nru r-cran-git2r-0.21.0/R/libgit2.R r-cran-git2r-0.22.1/R/libgit2.R --- r-cran-git2r-0.21.0/R/libgit2.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/libgit2.R 2018-06-02 05:02:38.000000000 +0000 @@ -0,0 +1,54 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Compile time options for libgit2. +##' +##' @return A list with threads, https and ssh set to TRUE/FALSE. +##' @keywords methods +##' @export +##' @examples +##' libgit2_features() +libgit2_features <- function() { + .Call(git2r_libgit2_features) +} + +##' Version of the libgit2 library +##' +##' Version of the libgit2 library that the bundled source code is +##' based on +##' @return A list with major, minor and rev +##' @keywords methods +##' @export +##' @examples +##' libgit2_version() +libgit2_version <- function() { + .Call(git2r_libgit2_version) +} + +##' Set the SSL certificate-authority locations +##' +##' @note Either parameter may be 'NULL', but not both. +##' @param filename Location of a file containing several certificates +##' concatenated together. Default NULL. +##' @param path Location of a directory holding several certificates, +##' one per file. Default NULL. +##' @return invisible(NULL) +##' @keywords methods +##' @export +ssl_cert_locations <- function(filename = NULL, path = NULL) { + .Call(git2r_ssl_cert_locations, filename, path) + invisible(NULL) +} diff -Nru r-cran-git2r-0.21.0/R/merge.r r-cran-git2r-0.22.1/R/merge.r --- r-cran-git2r-0.21.0/R/merge.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/merge.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,274 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Find a merge base between two commits -##' -##' @rdname merge_base-methods -##' @docType methods -##' @param one One of the commits -##' @param two The other commit -##' @return S4 class git_commit -##' @keywords methods -##' @include S4_classes.r -##' @examples \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Master branch", file.path(path, "master_branch.txt")) -##' add(repo, "master_branch.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' ## Create first branch, checkout, add file and commit -##' branch_1 <- branch_create(commit_1, "branch_1") -##' checkout(branch_1) -##' writeLines("Branch 1", file.path(path, "branch_1.txt")) -##' add(repo, "branch_1.txt") -##' commit_2 <- commit(repo, "Commit message branch_1") -##' -##' ## Create second branch, checkout, add file and commit -##' branch_2 <- branch_create(commit_1, "branch_2") -##' checkout(branch_2) -##' writeLines("Branch 2", file.path(path, "branch_2.txt")) -##' add(repo, "branch_2.txt") -##' commit_3 <- commit(repo, "Commit message branch_2") -##' -##' ## Check that merge base equals commit_1 -##' stopifnot(identical(merge_base(commit_2, commit_3), commit_1)) -##' } -setGeneric("merge_base", - signature = c("one", "two"), - function(one, two) - standardGeneric("merge_base")) - -##' @rdname merge_base-methods -##' @export -setMethod("merge_base", - signature(one = "git_commit", - two = "git_commit"), - function(one, two) - { - stopifnot(identical(one@repo, two@repo)) - .Call(git2r_merge_base, one, two) - } -) - -##' Merge branch into HEAD -##' -##' @param branch The branch -##' @param commit_on_success If there are no conflicts written to the -##' index, the merge commit will be committed. -##' @param merger Who made the merge. -##' @return A \code{\linkS4class{git_merge_result}} object. -##' @keywords internal -merge_branch <- function(branch, commit_on_success, merger) -{ - .Call(git2r_merge_branch, branch, merger, commit_on_success) -} - -##' Merge named branch into HEAD -##' -##' @param repo The repository -##' @param branch Name of branch -##' @param commit_on_success If there are no conflicts written to the -##' index, the merge commit will be committed. -##' @param merger Who made the merge. -##' @return A \code{\linkS4class{git_merge_result}} object. -##' @keywords internal -merge_named_branch <- function(repo, branch, commit_on_success, merger) -{ - ## Check branch argument - if (missing(branch)) - stop("missing 'branch' argument") - if (any(!is.character(branch), !identical(length(branch), 1L))) - stop("'branch' must be a character vector of length one") - - b <- branches(repo) - b <- b[vapply(b, slot, character(1), "name") == branch][[1]] - - merge_branch(b, commit_on_success, merger) -} - -##' Merge a branch into HEAD -##' -##' @rdname merge-methods -##' @export -##' @docType methods -##' @param x A \code{\linkS4class{git_branch}} or -##' \code{\linkS4class{git_repository}} object. -##' @param y If \code{x} is a \code{\linkS4class{git_repository}}, the -##' name of the branch to merge into HEAD. Not used if \code{x} is a -##' \code{\linkS4class{git_branch}}. -##' @param ... Additional arguments affecting the merge -##' @param commit_on_success If there are no conflicts written to the -##' index, the merge commit will be committed. Default is TRUE. -##' @param merger Who made the merge. -##' @return A \code{\linkS4class{git_merge_result}} object. -##' @keywords methods -##' @include S4_classes.r -##' @examples \dontrun{ -##' ## Create a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email = "alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' ## Create first branch, checkout, add file and commit -##' checkout(repo, "branch1", create = TRUE) -##' writeLines("Branch 1", file.path(path, "branch-1.txt")) -##' add(repo, "branch-1.txt") -##' commit(repo, "Commit message branch 1") -##' -##' ## Create second branch, checkout, add file and commit -##' b_2 <- branch_create(commit_1, "branch2") -##' checkout(b_2) -##' writeLines("Branch 2", file.path(path, "branch-2.txt")) -##' add(repo, "branch-2.txt") -##' commit(repo, "Commit message branch 2") -##' -##' ## Make a change to 'test.txt' -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Second commit message branch 2") -##' -##' ## Checkout master -##' checkout(repo, "master", force = TRUE) -##' -##' ## Merge branch 1 -##' merge(repo, "branch1") -##' -##' ## Merge branch 2 -##' merge(repo, "branch2") -##' -##' ## Create third branch, checkout, change file and commit -##' checkout(repo, "branch3", create=TRUE) -##' writeLines(c("Lorem ipsum dolor amet sit, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Commit message branch 3") -##' -##' ## Checkout master and create a change that creates a merge conflict -##' checkout(repo, "master", force=TRUE) -##' writeLines(c("Lorem ipsum dolor sit amet, adipisicing consectetur elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Some commit message branch 1") -##' -##' ## Merge branch 3 -##' merge(repo, "branch3") -##' -##' ## Check status; Expect to have one unstaged unmerged conflict. -##' status(repo) -##' } -setMethod("merge", - signature(x = "git_repository", y = "character"), - function(x, - y, - ..., - commit_on_success = TRUE, - merger = default_signature(x)) - { - merge_named_branch(x, y, commit_on_success, merger) - } -) - -##' @rdname merge-methods -##' @export -setMethod("merge", - signature(x = "git_branch", y = "missing"), - function(x, - ..., - commit_on_success = TRUE, - merger = default_signature(x@repo)) - { - merge_branch(x, commit_on_success, merger) - } -) - -##' Brief summary of merge result -##' -##' @aliases show,git_merge_result-methods -##' @docType methods -##' @param object The \code{\linkS4class{git_merge_result}} \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @include S4_classes.r -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("First line.", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create and checkout a new branch. Update 'example.txt' and commit -##' checkout(repo, "new_branch", create=TRUE) -##' writeLines(c("First line.", "Second line."), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Second commit message") -##' -##' ## Checkout 'master' branch -##' checkout(repo, "master", force = TRUE) -##' -##' ## Display 'example.txt' -##' readLines(file.path(path, "example.txt")) -##' -##' ## Merge and display brief summary of the fast-forward merge -##' merge(repo, "new_branch") -##' -##' ## Display 'example.txt' -##' readLines(file.path(path, "example.txt")) -##' } -setMethod("show", - signature(object = "git_merge_result"), - function(object) - { - if (isTRUE(object@up_to_date)) { - cat("Already up-to-date") - } else if (isTRUE(object@conflicts)) { - cat("Merge: Conflicts") - } else if (isTRUE(object@fast_forward)) { - cat("Merge: Fast-forward") - } else { - cat("Merge") - } - - cat("\n") - } -) diff -Nru r-cran-git2r-0.21.0/R/merge.R r-cran-git2r-0.22.1/R/merge.R --- r-cran-git2r-0.21.0/R/merge.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/merge.R 2018-07-01 21:27:09.000000000 +0000 @@ -0,0 +1,125 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Find a merge base between two commits +##' +##' @param one One of the commits +##' @param two The other commit +##' @return git_commit +##' @export +##' @examples \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Master branch", file.path(path, "master_branch.txt")) +##' add(repo, "master_branch.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' ## Create first branch, checkout, add file and commit +##' branch_1 <- branch_create(commit_1, "branch_1") +##' checkout(branch_1) +##' writeLines("Branch 1", file.path(path, "branch_1.txt")) +##' add(repo, "branch_1.txt") +##' commit_2 <- commit(repo, "Commit message branch_1") +##' +##' ## Create second branch, checkout, add file and commit +##' branch_2 <- branch_create(commit_1, "branch_2") +##' checkout(branch_2) +##' writeLines("Branch 2", file.path(path, "branch_2.txt")) +##' add(repo, "branch_2.txt") +##' commit_3 <- commit(repo, "Commit message branch_2") +##' +##' ## Check that merge base equals commit_1 +##' stopifnot(identical(merge_base(commit_2, commit_3), commit_1)) +##' } +merge_base <- function(one = NULL, two = NULL) { + .Call(git2r_merge_base, one, two) +} + +##' Merge a branch into HEAD +##' +##' @rdname merge +##' @param x A path (default '.') to a repository, or a +##' \code{git_repository} object, or a \code{git_branch}. +##' @param y If \code{x} is a \code{git_repository}, the name of the +##' branch to merge into HEAD. Not used if \code{x} is a +##' \code{git_branch}. +##' @param commit_on_success If there are no conflicts written to the +##' index, the merge commit will be committed. Default is TRUE. +##' @param merger Who made the merge. The default (\code{NULL}) is to +##' use \code{default_signature} for the repository. +##' @param fail If a conflict occurs, exit immediately instead of +##' attempting to continue resolving conflicts. Default is +##' \code{FALSE}. +##' @param ... Additional arguments (unused). +##' @template return-git_merge_result +##' @export +##' @template merge-example +merge.git_branch <- function(x, y = NULL, commit_on_success = TRUE, + merger = NULL, fail = FALSE, ...) +{ + if (is.null(merger)) + merger <- default_signature(x$repo) + .Call(git2r_merge_branch, x, merger, commit_on_success, fail) +} + +##' @export +##' @rdname merge +merge.git_repository <- function(x, y = NULL, commit_on_success = TRUE, + merger = NULL, fail = FALSE, ...) +{ + ## Check branch argument + if (is.null(y) || !is.character(y) || !identical(length(y), 1L)) + stop("'branch' must be a character vector of length one") + b <- branches(x) + b <- b[vapply(b, "[[", character(1), "name") == y][[1]] + merge.git_branch(b, commit_on_success = commit_on_success, + merger = merger, fail = fail) +} + +##' @export +##' @rdname merge +merge.character <- function(x = ".", y = NULL, commit_on_success = TRUE, + merger = NULL, fail = FALSE, ...) +{ + x <- lookup_repository(x) + merge.git_repository(x, y, commit_on_success, merger, fail) +} + +##' @export +base::merge + +##' @export +format.git_merge_result <- function(x, ...) { + if (isTRUE(x$up_to_date)) + return("Already up-to-date") + if (isTRUE(x$conflicts)) + return("Merge: Conflicts") + if (isTRUE(x$fast_forward)) + return("Merge: Fast-forward") + return("Merge") +} + +##' @export +print.git_merge_result <- function(x, ...) { + cat(format(x, ...), "\n", sep = "") +} diff -Nru r-cran-git2r-0.21.0/R/note.r r-cran-git2r-0.22.1/R/note.r --- r-cran-git2r-0.21.0/R/note.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/note.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,348 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Default notes reference -##' -##' Get the default notes reference for a repository -##' @rdname note_default_ref-methods -##' @docType methods -##' @param repo The repository -##' @return Character vector of length one with name of default notes -##' reference -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## View default notes reference -##' note_default_ref(repo) -##' } -setGeneric("note_default_ref", - signature = "repo", - function(repo) - standardGeneric("note_default_ref")) - -##' @rdname note_default_ref-methods -##' @export -setMethod("note_default_ref", - signature = "git_repository", - function(repo) - { - .Call(git2r_note_default_ref, repo) - } -) - -##' Add note for a object -##' -##' @rdname note_create-methods -##' @docType methods -##' @param object The object to annotate -##' @param message Content of the note to add -##' @param ref Canonical name of the reference to use. Default is -##' \code{note_default_ref}. -##' @param author Signature of the notes note author -##' @param committer Signature of the notes note committer -##' @param force Overwrite existing note. Default is FALSE -##' @return S4 class git_note -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' ## Create another commit -##' writeLines(c("Hello world!", -##' "HELLO WORLD!"), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_2 <- commit(repo, "Commit message 2") -##' -##' ## Check that notes is an empty list -##' notes(repo) -##' -##' ## Create note in default namespace -##' note_create(commit_1, "Note-1") -##' -##' ## Create note in named (review) namespace -##' note_create(commit_1, "Note-2", ref="refs/notes/review") -##' note_create(commit_2, "Note-3", ref="review") -##' -##' ## Create note on blob and tree -##' note_create(tree(commit_1), "Note-4") -##' note_create(tree(commit_1)["example.txt"], "Note-5") -##' } -setGeneric("note_create", - signature = "object", - function(object, - message, - ref = note_default_ref(object@repo), - author = default_signature(object@repo), - committer = default_signature(object@repo), - force = FALSE) - standardGeneric("note_create")) - -##' @rdname note_create-methods -##' @export -setMethod("note_create", - signature = "git_blob", - function(object, - message, - ref, - author, - committer, - force) - { - stopifnot(is.character(ref)) - stopifnot(identical(length(ref), 1L)) - if (!length(grep("^refs/notes/", ref))) - ref <- paste0("refs/notes/", ref) - .Call(git2r_note_create, - object@repo, - object@sha, - message, - ref, - author, - committer, - force) - } -) - -##' @rdname note_create-methods -##' @export -setMethod("note_create", - signature = "git_commit", - function(object, - message, - ref, - author, - committer, - force) - { - stopifnot(is.character(ref)) - stopifnot(identical(length(ref), 1L)) - if (!length(grep("^refs/notes/", ref))) - ref <- paste0("refs/notes/", ref) - .Call(git2r_note_create, - object@repo, - object@sha, - message, - ref, - author, - committer, - force) - } -) - -##' @rdname note_create-methods -##' @export -setMethod("note_create", - signature = "git_tree", - function(object, - message, - ref, - author, - committer, - force) - { - stopifnot(is.character(ref)) - stopifnot(identical(length(ref), 1L)) - if (!length(grep("^refs/notes/", ref))) - ref <- paste0("refs/notes/", ref) - .Call(git2r_note_create, - object@repo, - object@sha, - message, - ref, - author, - committer, - force) - } -) - -##' List notes -##' -##' List all the notes within a specified namespace. -##' @rdname notes-methods -##' @docType methods -##' @param repo The repository -##' @param ref Reference to read from. Default is -##' "refs/notes/commits". -##' @return list with S4 class git_note objects -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' ## Create another commit -##' writeLines(c("Hello world!", -##' "HELLO WORLD!"), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_2 <- commit(repo, "Commit message 2") -##' -##' ## Create note in default namespace -##' note_create(commit_1, "Note-1") -##' note_create(commit_1, "Note-2", force = TRUE) -##' -##' ## Create note in named (review) namespace -##' note_create(commit_1, "Note-3", ref="refs/notes/review") -##' note_create(commit_2, "Note-4", ref="review") -##' -##' ## Create note on blob and tree -##' note_create(tree(commit_1), "Note-5") -##' note_create(tree(commit_1)["example.txt"], "Note-6") -##' -##' ## List notes in default namespace -##' notes(repo) -##' -##' ## List notes in 'review' namespace -##' notes(repo, "review") -##' } -setGeneric("notes", - signature = c("repo", "ref"), - function(repo, - ref = note_default_ref(repo)) - standardGeneric("notes")) - -##' @rdname notes-methods -##' @export -setMethod("notes", - signature = "git_repository", - function(repo, ref) - { - stopifnot(is.character(ref), identical(length(ref), 1L)) - if (!length(grep("^refs/notes/", ref))) - ref <- paste0("refs/notes/", ref) - .Call(git2r_notes, repo, ref) - } -) - -##' Remove the note for an object -##' -##' @rdname note_remove-methods -##' @docType methods -##' @param note The note to remove -##' @param author Signature of the notes commit author. -##' @param committer Signature of the notes commit committer. -##' @return invisible NULL -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' -##' ## Create note in default namespace -##' note_1 <- note_create(commit_1, "Note-1") -##' -##' ## Create note in named (review) namespace -##' note_2 <- note_create(commit_1, "Note-2", ref="refs/notes/review") -##' -##' ## List notes in default namespace -##' notes(repo) -##' -##' ## List notes in 'review' namespace -##' notes(repo, "review") -##' -##' ## Remove notes -##' note_remove(note_1) -##' note_remove(note_2) -##' -##' ## List notes in default namespace -##' notes(repo) -##' -##' ## List notes in 'review' namespace -##' notes(repo, "review") -##' } -setGeneric("note_remove", - signature = "note", - function(note, - author = default_signature(note@repo), - committer = default_signature(note@repo)) - standardGeneric("note_remove")) - -##' @rdname note_remove-methods -##' @export -setMethod("note_remove", - signature = "git_note", - function(note, - author, - committer) - { - invisible(.Call(git2r_note_remove, note, author, committer)) - } -) - -##' Brief summary of note -##' -##' @aliases show,git_note-methods -##' @docType methods -##' @param object The \linkS4class{git_note} \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create note -##' note_create(commits(repo)[[1]], "My note") -##' } -setMethod("show", - signature(object = "git_note"), - function(object) - { - cat(sprintf("note: %s\n", object@sha)) - } -) diff -Nru r-cran-git2r-0.21.0/R/note.R r-cran-git2r-0.22.1/R/note.R --- r-cran-git2r-0.21.0/R/note.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/note.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,232 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Default notes reference +##' +##' Get the default notes reference for a repository +##' @template repo-param +##' @return Character vector of length one with name of default notes +##' reference +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## View default notes reference +##' note_default_ref(repo) +##' } +note_default_ref <- function(repo = ".") { + .Call(git2r_note_default_ref, lookup_repository(repo)) +} + +##' Add note for a object +##' +##' @param object The object to annotate (git_blob, git_commit or +##' git_tree). +##' @param message Content of the note to add +##' @param ref Canonical name of the reference to use. Default is +##' \code{note_default_ref}. +##' @param author Signature of the notes note author +##' @param committer Signature of the notes note committer +##' @param force Overwrite existing note. Default is FALSE +##' @return git_note +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' ## Create another commit +##' writeLines(c("Hello world!", +##' "HELLO WORLD!"), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_2 <- commit(repo, "Commit message 2") +##' +##' ## Check that notes is an empty list +##' notes(repo) +##' +##' ## Create note in default namespace +##' note_create(commit_1, "Note-1") +##' +##' ## Create note in named (review) namespace +##' note_create(commit_1, "Note-2", ref="refs/notes/review") +##' note_create(commit_2, "Note-3", ref="review") +##' +##' ## Create note on blob and tree +##' note_create(tree(commit_1), "Note-4") +##' note_create(tree(commit_1)["example.txt"], "Note-5") +##' } +note_create <- function(object = NULL, + message = NULL, + ref = NULL, + author = NULL, + committer = NULL, + force = FALSE) +{ + if (is.null(object)) + stop("'object' is missing") + if (!any(is_blob(object), is_commit(object), is_tree(object))) + stop("'object' must be a 'git_blob', 'git_commit' or 'git_tree' object") + + repo <- object$repo + sha <- object$sha + if (is.null(ref)) + ref <- note_default_ref(repo) + stopifnot(is.character(ref), identical(length(ref), 1L)) + if (!length(grep("^refs/notes/", ref))) + ref <- paste0("refs/notes/", ref) + if(is.null(author)) + author <- default_signature(repo) + if (is.null(committer)) + committer <- default_signature(repo) + .Call(git2r_note_create, repo, sha, message, ref, author, committer, force) +} + +##' List notes +##' +##' List all the notes within a specified namespace. +##' @template repo-param +##' @param ref Reference to read from. Default (ref = NULL) is to call +##' \code{note_default_ref}. +##' @return list with git_note objects +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' ## Create another commit +##' writeLines(c("Hello world!", +##' "HELLO WORLD!"), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_2 <- commit(repo, "Commit message 2") +##' +##' ## Create note in default namespace +##' note_create(commit_1, "Note-1") +##' note_create(commit_1, "Note-2", force = TRUE) +##' +##' ## Create note in named (review) namespace +##' note_create(commit_1, "Note-3", ref="refs/notes/review") +##' note_create(commit_2, "Note-4", ref="review") +##' +##' ## Create note on blob and tree +##' note_create(tree(commit_1), "Note-5") +##' note_create(tree(commit_1)["example.txt"], "Note-6") +##' +##' ## List notes in default namespace +##' notes(repo) +##' +##' ## List notes in 'review' namespace +##' notes(repo, "review") +##' } +notes <- function(repo = ".", ref = NULL) { + repo <- lookup_repository(repo) + if (is.null(ref)) + ref = note_default_ref(repo) + stopifnot(is.character(ref), identical(length(ref), 1L)) + if (!length(grep("^refs/notes/", ref))) + ref <- paste0("refs/notes/", ref) + .Call(git2r_notes, repo, ref) +} + +##' Remove the note for an object +##' +##' @param note The note to remove +##' @param author Signature of the notes commit author. +##' @param committer Signature of the notes commit committer. +##' @return invisible NULL +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' +##' ## Create note in default namespace +##' note_1 <- note_create(commit_1, "Note-1") +##' +##' ## Create note in named (review) namespace +##' note_2 <- note_create(commit_1, "Note-2", ref="refs/notes/review") +##' +##' ## List notes in default namespace +##' notes(repo) +##' +##' ## List notes in 'review' namespace +##' notes(repo, "review") +##' +##' ## Remove notes +##' note_remove(note_1) +##' note_remove(note_2) +##' +##' ## List notes in default namespace +##' notes(repo) +##' +##' ## List notes in 'review' namespace +##' notes(repo, "review") +##' } +note_remove <- function(note = NULL, + author = NULL, + committer = NULL) +{ + if (!inherits(note, "git_note")) + stop("'note' is not a git_note") + if (is.null(author)) + author <- default_signature(note$repo) + if (is.null(committer)) + committer <- default_signature(note$repo) + .Call(git2r_note_remove, note, author, committer) + invisible(NULL) +} + +##' @export +format.git_note <- function(x, ...) { + sprintf("note: %s", x$sha) +} + +##' @export +print.git_note <- function(x, ...) { + cat(format(x, ...), "\n", sep = "") +} diff -Nru r-cran-git2r-0.21.0/R/odb.r r-cran-git2r-0.22.1/R/odb.r --- r-cran-git2r-0.21.0/R/odb.r 2018-01-02 13:29:01.000000000 +0000 +++ r-cran-git2r-0.22.1/R/odb.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Blobs in the object database -##' -##' List all blobs reachable from the commits in the object -##' database. For each commit, list blob's in the commit tree and -##' sub-trees. -##' @rdname odb_blobs-methods -##' @docType methods -##' @param repo The repository -##' @return A data.frame with the following columns: -##' \describe{ -##' \item{sha}{The sha of the blob} -##' \item{path}{The path to the blob from the tree and sub-trees} -##' \item{name}{The name of the blob from the tree that contains the blob} -##' \item{len}{The length of the blob} -##' \item{commit}{The sha of the commit} -##' \item{author}{The author of the commit} -##' \item{when}{The timestamp of the author signature in the commit} -##' } -##' @note A blob sha can have several entries -##' @keywords methods -##' @examples \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Commit message 1") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Commit message 2") -##' -##' ## Commit same content under different name in a sub-directory -##' dir.create(file.path(path, "sub-directory")) -##' file.copy(file.path(path, "test.txt"), file.path(path, "sub-directory", "copy.txt")) -##' add(repo, "sub-directory/copy.txt") -##' commit(repo, "Commit message 3") -##' -##' ## List blobs -##' odb_blobs(repo) -##' } -setGeneric("odb_blobs", - signature = "repo", - function(repo) - standardGeneric("odb_blobs")) - -##' @rdname odb_blobs-methods -##' @export -setMethod("odb_blobs", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname odb_blobs-methods -##' @export -setMethod("odb_blobs", - signature(repo = "git_repository"), - function(repo) - { - blobs <- data.frame(.Call(git2r_odb_blobs, repo), - stringsAsFactors = FALSE) - blobs <- blobs[order(blobs$when),] - index <- paste0(blobs$sha, ":", blobs$path, "/", blobs$name) - blobs <- blobs[!duplicated(index),] - rownames(blobs) <- NULL - blobs$when <- as.POSIXct(blobs$when, origin="1970-01-01", tz="GMT") - blobs - } -) - -##' List all objects available in the database -##' -##' @rdname odb_objects-methods -##' @docType methods -##' @param repo The repository -##' @return A data.frame with the following columns: -##' \describe{ -##' \item{sha}{The sha of the object} -##' \item{type}{The type of the object} -##' \item{len}{The length of the object} -##' } -##' @keywords methods -##' @examples \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Commit message 1") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' ## List objects in repository -##' odb_objects(repo) -##' } -setGeneric("odb_objects", - signature = "repo", - function(repo) - standardGeneric("odb_objects")) - -##' @rdname odb_objects-methods -##' @export -setMethod("odb_objects", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname odb_objects-methods -##' @export -setMethod("odb_objects", - signature(repo = "git_repository"), - function(repo) - { - data.frame(.Call(git2r_odb_objects, repo), - stringsAsFactors = FALSE) - } -) diff -Nru r-cran-git2r-0.21.0/R/odb.R r-cran-git2r-0.22.1/R/odb.R --- r-cran-git2r-0.21.0/R/odb.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/odb.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,111 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Blobs in the object database +##' +##' List all blobs reachable from the commits in the object +##' database. For each commit, list blob's in the commit tree and +##' sub-trees. +##' @template repo-param +##' @return A data.frame with the following columns: +##' \describe{ +##' \item{sha}{The sha of the blob} +##' \item{path}{The path to the blob from the tree and sub-trees} +##' \item{name}{The name of the blob from the tree that contains the blob} +##' \item{len}{The length of the blob} +##' \item{commit}{The sha of the commit} +##' \item{author}{The author of the commit} +##' \item{when}{The timestamp of the author signature in the commit} +##' } +##' @note A blob sha can have several entries +##' @export +##' @examples \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "Commit message 1") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "Commit message 2") +##' +##' ## Commit same content under different name in a sub-directory +##' dir.create(file.path(path, "sub-directory")) +##' file.copy(file.path(path, "test.txt"), file.path(path, "sub-directory", "copy.txt")) +##' add(repo, "sub-directory/copy.txt") +##' commit(repo, "Commit message 3") +##' +##' ## List blobs +##' odb_blobs(repo) +##' } +odb_blobs <- function(repo = ".") { + blobs <- .Call(git2r_odb_blobs, lookup_repository(repo)) + blobs <- data.frame(blobs, stringsAsFactors = FALSE) + blobs <- blobs[order(blobs$when),] + index <- paste0(blobs$sha, ":", blobs$path, "/", blobs$name) + blobs <- blobs[!duplicated(index),] + rownames(blobs) <- NULL + blobs$when <- as.POSIXct(blobs$when, origin="1970-01-01", tz="GMT") + blobs +} + +##' List all objects available in the database +##' +##' @template repo-param +##' @return A data.frame with the following columns: +##' \describe{ +##' \item{sha}{The sha of the object} +##' \item{type}{The type of the object} +##' \item{len}{The length of the object} +##' } +##' @export +##' @examples \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "Commit message 1") +##' +##' ## Create tag +##' tag(repo, "Tagname", "Tag message") +##' +##' ## List objects in repository +##' odb_objects(repo) +##' } +odb_objects <- function(repo = ".") { + data.frame(.Call(git2r_odb_objects, lookup_repository(repo)), + stringsAsFactors = FALSE) +} diff -Nru r-cran-git2r-0.21.0/R/plot.r r-cran-git2r-0.22.1/R/plot.r --- r-cran-git2r-0.21.0/R/plot.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/plot.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Plot commits over time -##' -##' @rdname plot-methods -##' @aliases plot -##' @aliases plot-methods -##' @docType methods -##' @param x The repository to plot -##' @param breaks Default is \code{month}. Change to year, quarter, -##' week or day as necessary. -##' @param main Default title for the plot is "Commits on repo:" and -##' repository workdir basename. Supply a new title if you desire one. -##' @param ... Additional arguments affecting the plot -##' @keywords methods -##' @include S4_classes.r -##' @importFrom graphics axis -##' @importFrom graphics barplot -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- clone("https://github.com/ropensci/git2r.git", path) -##' -##' ## Plot commits -##' plot(repo) -##' } -setMethod("plot", - signature(x = "git_repository"), - function(x, - breaks = c("month", "year", "quarter", "week", "day"), - main = NULL, - ...) - { - breaks = match.arg(breaks) - - df <- contributions(x, breaks = breaks, by = "commits") - tmp <- data.frame(when = seq(from = min(df$when), - to = max(df$when), - by = breaks), - n = 0) - i <- match(df$when, tmp$when) - tmp$n[i] <- df$n - df <- tmp - - xlab <- sprintf("Time [%s]", breaks) - ylab <- "Number of commits" - if (is.null(main)) { - if (is_bare(x)) { - main <- "Commits" - } else { - main <- sprintf("Commits on repository: %s", - basename(workdir(x))) - } - } - - mp <- graphics::barplot(df$n, xlab = xlab, ylab = ylab, - main = main, ...) - graphics::axis(1, at = mp, labels = seq(min(df$when), - max(df$when), breaks)) - } -) diff -Nru r-cran-git2r-0.21.0/R/plot.R r-cran-git2r-0.22.1/R/plot.R --- r-cran-git2r-0.21.0/R/plot.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/plot.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,67 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Plot commits over time +##' +##' @param x The repository to plot +##' @param breaks Default is \code{month}. Change to year, quarter, +##' week or day as necessary. +##' @param main Default title for the plot is "Commits on repo:" and +##' repository workdir basename. Supply a new title if you desire one. +##' @param ... Additional arguments affecting the plot +##' @importFrom graphics axis +##' @importFrom graphics barplot +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- clone("https://github.com/ropensci/git2r.git", path) +##' +##' ## Plot commits +##' plot(repo) +##' } +plot.git_repository <- function(x, + breaks = c("month", "year", "quarter", "week", "day"), + main = NULL, + ...) +{ + breaks = match.arg(breaks) + + df <- contributions(x, breaks = breaks, by = "commits") + tmp <- data.frame(when = seq(from = min(df$when), + to = max(df$when), + by = breaks), + n = 0) + i <- match(df$when, tmp$when) + tmp$n[i] <- df$n + df <- tmp + + xlab <- sprintf("Time [%s]", breaks) + ylab <- "Number of commits" + if (is.null(main)) { + if (is_bare(x)) { + main <- "Commits" + } else { + main <- sprintf("Commits on repository: %s", + basename(workdir(x))) + } + } + + mp <- barplot(df$n, xlab = xlab, ylab = ylab, main = main, ...) + axis(1, at = mp, labels = seq(min(df$when), max(df$when), breaks)) +} diff -Nru r-cran-git2r-0.21.0/R/pull.r r-cran-git2r-0.22.1/R/pull.r --- r-cran-git2r-0.21.0/R/pull.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/pull.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Pull -##' -##' @rdname pull-methods -##' @docType methods -##' @param repo the repository -##' @param credentials The credentials for remote repository -##' access. Default is NULL. To use and query an ssh-agent for the ssh -##' key credentials, let this parameter be NULL (the default). -##' @param merger Who made the merge, if the merge is non-fast forward -##' merge that creates a merge commit. -##' @return invisible(NULL) -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo_1 <- clone(path_bare, path_repo_1) -##' -##' ## Config first user and commit a file -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "First commit message") -##' -##' ## Push commits from first repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo_1, "origin", "refs/heads/master") -##' -##' ## Clone to second repository -##' repo_2 <- clone(path_bare, path_repo_2) -##' config(repo_2, user.name="Bob", user.email="bob@@example.org") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Second commit message") -##' -##' ## Push commits from first repository to bare repository -##' push(repo_1) -##' -##' ## Pull changes to repo_2 -##' pull(repo_2) -##' -##' ## Change file again and commit. This time in repository 2 -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", -##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), -##' file.path(path_repo_2, "example.txt")) -##' add(repo_2, "example.txt") -##' commit(repo_2, "Third commit message") -##' -##' ## Push commits from second repository to bare repository -##' push(repo_2) -##' -##' ## Pull changes to repo_1 -##' pull(repo_1) -##' -##' ## List commits in repositories -##' commits(repo_1) -##' commits(repo_2) -##' commits(repo_bare) -##' } -setGeneric("pull", - signature = "repo", - function(repo, - credentials = NULL, - merger = default_signature(repo)) - standardGeneric("pull")) - -##' @rdname pull-methods -##' @export -setMethod("pull", - signature(repo = "git_repository"), - function(repo, - credentials, - merger) - { - current_branch <- head(repo) - - if (is.null(current_branch)) - stop("'branch' is NULL") - if (!is_local(current_branch)) - stop("'branch' is not local") - upstream_branch <- branch_get_upstream(current_branch) - if (is.null(upstream_branch)) - stop("'branch' is not tracking a remote branch") - - fetch(repo = repo, - name = branch_remote_name(upstream_branch), - credentials = credentials) - - ## fetch heads marked for merge - fh <- fetch_heads(repo) - fh <- fh[vapply(fh, slot, logical(1), "is_merge")] - - if (identical(length(fh), 0L)) - stop("Remote ref was not feteched") - - .Call(git2r_merge_fetch_heads, fh, merger) - } -) diff -Nru r-cran-git2r-0.21.0/R/pull.R r-cran-git2r-0.22.1/R/pull.R --- r-cran-git2r-0.21.0/R/pull.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/pull.R 2018-05-03 21:23:51.000000000 +0000 @@ -0,0 +1,116 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Pull +##' +##' @template repo-param +##' @param credentials The credentials for remote repository +##' access. Default is NULL. To use and query an ssh-agent for the +##' ssh key credentials, let this parameter be NULL (the default). +##' @param merger Who made the merge, if the merge is non-fast forward +##' merge that creates a merge commit. The +##' \code{default_signature} for \code{repo} is used if this +##' parameter is \code{NULL}. +##' @template return-git_merge_result +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo_1 <- clone(path_bare, path_repo_1) +##' +##' ## Config first user and commit a file +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "First commit message") +##' +##' ## Push commits from first repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo_1, "origin", "refs/heads/master") +##' +##' ## Clone to second repository +##' repo_2 <- clone(path_bare, path_repo_2) +##' config(repo_2, user.name="Bob", user.email="bob@@example.org") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Second commit message") +##' +##' ## Push commits from first repository to bare repository +##' push(repo_1) +##' +##' ## Pull changes to repo_2 +##' pull(repo_2) +##' +##' ## Change file again and commit. This time in repository 2 +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", +##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), +##' file.path(path_repo_2, "example.txt")) +##' add(repo_2, "example.txt") +##' commit(repo_2, "Third commit message") +##' +##' ## Push commits from second repository to bare repository +##' push(repo_2) +##' +##' ## Pull changes to repo_1 +##' pull(repo_1) +##' +##' ## List commits in repositories +##' commits(repo_1) +##' commits(repo_2) +##' commits(repo_bare) +##' } +pull <- function(repo = ".", credentials = NULL, merger = NULL) { + repo <- lookup_repository(repo) + if (is.null(merger)) + merger <- default_signature(repo) + current_branch <- repository_head(repo) + + if (is.null(current_branch)) + stop("'branch' is NULL") + if (!is_local(current_branch)) + stop("'branch' is not local") + upstream_branch <- branch_get_upstream(current_branch) + if (is.null(upstream_branch)) + stop("'branch' is not tracking a remote branch") + + fetch(repo = repo, + name = branch_remote_name(upstream_branch), + credentials = credentials) + + ## fetch heads marked for merge + fh <- fetch_heads(repo) + fh <- fh[vapply(fh, "[[", logical(1), "is_merge")] + + if (identical(length(fh), 0L)) + stop("Remote ref was not feteched") + + .Call(git2r_merge_fetch_heads, fh, merger) +} diff -Nru r-cran-git2r-0.21.0/R/punch_card.r r-cran-git2r-0.22.1/R/punch_card.r --- r-cran-git2r-0.21.0/R/punch_card.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/punch_card.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Punch card -##' -##' @rdname punch_card-methods -##' @docType methods -##' @param repo The repository -##' @param main Default title for the plot is "Punch card on repo:" -##' and repository workdir basename. Supply a new title if you desire -##' one. -##' @param ... Additional arguments affecting the plot -##' @return invisible NULL -##' @keywords methods -##' @include S4_classes.r -##' @importFrom graphics axis -##' @importFrom graphics par -##' @importFrom graphics plot.new -##' @importFrom graphics plot.window -##' @importFrom graphics symbols -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- clone("https://github.com/ropensci/git2r.git", path) -##' -##' ## Plot -##' punch_card(repo) -##' } -setGeneric("punch_card", - signature = "repo", - function(repo, main = NULL, ...) - standardGeneric("punch_card")) - -##' @rdname punch_card-methods -##' @export -setMethod("punch_card", - signature(repo = "git_repository"), - function(repo, main, ...) - { - savepar <- graphics::par(las = 1, mar = c(2.2, 6, 2, 0)) - on.exit(par(savepar)) - - wd <- c("Saturday", "Friday", "Thursday", "Wednesday", - "Tuesday", "Monday", "Sunday") - - ## Extract information from repository - df <- as(repo, "data.frame") - df$when <- as.POSIXlt(df$when) - df$hour <- df$when$hour - df$weekday <- df$when$wday - - ## Create a key and tabulate - df$key <- paste0(df$weekday, "-", df$hour) - df <- as.data.frame(table(df$key), stringsAsFactors = FALSE) - names(df) <- c("key", "Commits") - - ## Convert key to Weekday and Hour - df$Weekday <- sapply(strsplit(df$key, "-"), "[", 1) - df$Weekday <- factor(df$Weekday, - levels = c(6, 5, 4, 3, 2, 1, 0), - labels = wd) - df$Hour <- as.integer(sapply(strsplit(df$key, "-"), "[", 2)) - df$key <- paste0(df$Weekday, "-", df$Hour) - - ## Scale - df$Commits <- sqrt((df$Commits / max(df$Commits)) / pi) - - graphics::plot.new() - graphics::plot.window(xlim = c(0, 23), ylim = c(0.8, 7.2)) - graphics::symbols(df$Hour, df$Weekday, circles = df$Commits, - xaxt = "n", yaxt = "n", inches = FALSE, - fg = "white", bg = "black", add = TRUE, ...) - h <- 0:23 - h <- paste0(ifelse(h > 9, as.character(h), - paste0("0", as.character(h))), ":00") - graphics::axis(1, at = 0:23, labels = h) - graphics::axis(2, at = 1:7, labels = wd) - - if (is.null(main)) { - if (is_bare(repo)) { - main <- "Punch card" - } else { - main <- sprintf("Punch card on repository: %s", - basename(workdir(repo))) - } - } - - graphics::title(main) - - invisible(NULL) - } -) diff -Nru r-cran-git2r-0.21.0/R/punch_card.R r-cran-git2r-0.22.1/R/punch_card.R --- r-cran-git2r-0.21.0/R/punch_card.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/punch_card.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,92 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Punch card +##' +##' @template repo-param +##' @param main Default title for the plot is "Punch card on repo:" +##' and repository workdir basename. Supply a new title if you +##' desire one. +##' @param ... Additional arguments affecting the plot +##' @return invisible NULL +##' @importFrom graphics axis +##' @importFrom graphics par +##' @importFrom graphics plot.new +##' @importFrom graphics plot.window +##' @importFrom graphics symbols +##' @importFrom graphics title +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- clone("https://github.com/ropensci/git2r.git", path) +##' +##' ## Plot +##' punch_card(repo) +##' } +punch_card <- function(repo = ".", main = NULL, ...) { + savepar <- graphics::par(las = 1, mar = c(2.2, 6, 2, 0)) + on.exit(par(savepar)) + + wd <- c("Saturday", "Friday", "Thursday", "Wednesday", "Tuesday", + "Monday", "Sunday") + + ## Extract information from repository + repo <- lookup_repository(repo) + df <- as.data.frame(repo) + df$when <- as.POSIXlt(df$when) + df$hour <- df$when$hour + df$weekday <- df$when$wday + + ## Create a key and tabulate + df$key <- paste0(df$weekday, "-", df$hour) + df <- as.data.frame(table(df$key), stringsAsFactors = FALSE) + names(df) <- c("key", "Commits") + + ## Convert key to Weekday and Hour + df$Weekday <- sapply(strsplit(df$key, "-"), "[", 1) + df$Weekday <- factor(df$Weekday, levels = c(6, 5, 4, 3, 2, 1, 0), labels = wd) + df$Hour <- as.integer(sapply(strsplit(df$key, "-"), "[", 2)) + df$key <- paste0(df$Weekday, "-", df$Hour) + + ## Scale + df$Commits <- sqrt((df$Commits / max(df$Commits)) / pi) + + plot.new() + plot.window(xlim = c(0, 23), ylim = c(0.8, 7.2)) + symbols(df$ Hour, df$Weekday, circles = df$Commits, + xaxt = "n", yaxt = "n", inches = FALSE, + fg = "white", bg = "black", add = TRUE, ...) + h <- 0:23 + h <- paste0(ifelse(h > 9, as.character(h), paste0("0", as.character(h))), ":00") + axis(1, at = 0:23, labels = h) + axis(2, at = 1:7, labels = wd) + + if (is.null(main)) { + if (is_bare(repo)) { + main <- "Punch card" + } else { + main <- sprintf("Punch card on repository: %s", + basename(workdir(repo))) + } + } + + title(main) + + invisible(NULL) +} diff -Nru r-cran-git2r-0.21.0/R/push.r r-cran-git2r-0.22.1/R/push.r --- r-cran-git2r-0.21.0/R/push.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/push.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Push -##' -##' @rdname push-methods -##' @docType methods -##' @param object S4 class \code{git_repository} or \code{git_branch}. -##' @param ... Additional arguments affecting the push. -##' @param force Force your local revision to the remote repo. Use it -##' with care. Default is FALSE. -##' @param credentials The credentials for remote repository -##' access. Default is NULL. To use and query an ssh-agent for the ssh -##' key credentials, let this parameter be NULL (the default). -##' @return invisible(NULL) -##' @seealso \code{\linkS4class{cred_user_pass}}, -##' \code{\linkS4class{cred_ssh_key}} -##' @keywords methods -##' @include refspec.r -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize two temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Second commit message") -##' -##' ## Push commits from repository to bare repository -##' push(repo) -##' -##' ## List commits in repository and bare repository -##' commits(repo) -##' commits(repo_bare) -##' } -setGeneric("push", - signature = "object", - function(object, ...) - standardGeneric("push")) - -##' @rdname push-methods -##' @export -setMethod("push", - signature(object = "git_branch"), - function(object, - force = FALSE, - credentials = NULL) - { - upstream <- branch_get_upstream(object) - if (is.null(upstream)) { - stop("The branch '", object@name, "' that you are ", - "trying to push does not track an upstream branch.") - } - - src <- .Call(git2r_branch_canonical_name, object) - dst <- .Call(git2r_branch_upstream_canonical_name, object) - - push(object = object@repo, - name = branch_remote_name(upstream), - refspec = paste0(src, ":", dst), - force = force, - credentials = credentials) - } -) - -##' @rdname push-methods -##' @param name The remote's name. Default is NULL. -##' @param refspec The refspec to be pushed. Default is NULL. -##' @export -setMethod("push", - signature(object = "git_repository"), - function(object, - name = NULL, - refspec = NULL, - force = FALSE, - credentials = NULL) - { - if (all(is.null(name), is.null(refspec))) { - b <- head(object) - upstream <- branch_get_upstream(b) - if (is.null(upstream)) { - stop("The branch '", b@name, "' that you are ", - "trying to push does not track an upstream branch.") - } - - src <- .Call(git2r_branch_canonical_name, b) - dst <- .Call(git2r_branch_upstream_canonical_name, b) - name <- branch_remote_name(upstream) - refspec <- paste0(src, ":", dst) - - if (isTRUE(force)) - refspec <- paste0("+", refspec) - } else { - opts <- list(force = force) - tmp <- get_refspec(object, name, refspec, opts) - name <- tmp$remote - refspec <- tmp$refspec - } - - result <- .Call(git2r_push, object, name, refspec, credentials) - - invisible(result) - } -) diff -Nru r-cran-git2r-0.21.0/R/push.R r-cran-git2r-0.22.1/R/push.R --- r-cran-git2r-0.21.0/R/push.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/push.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,113 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Push +##' +##' @param object path to repository, or a \code{git_repository} or +##' \code{git_branch}. +##' @param name The remote's name. Default is NULL. +##' @param refspec The refspec to be pushed. Default is NULL. +##' @param force Force your local revision to the remote repo. Use it +##' with care. Default is FALSE. +##' @param credentials The credentials for remote repository +##' access. Default is NULL. To use and query an ssh-agent for the +##' ssh key credentials, let this parameter be NULL (the default). +##' @return invisible(NULL) +##' @seealso \code{\link{cred_user_pass}}, \code{\link{cred_ssh_key}} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize two temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Second commit message") +##' +##' ## Push commits from repository to bare repository +##' push(repo) +##' +##' ## List commits in repository and bare repository +##' commits(repo) +##' commits(repo_bare) +##' } +push <- function(object = ".", + name = NULL, + refspec = NULL, + force = FALSE, + credentials = NULL) +{ + if (is_branch(object)) { + upstream <- branch_get_upstream(object) + if (is.null(upstream)) { + stop("The branch '", object@name, "' that you are ", + "trying to push does not track an upstream branch.") + } + name <- branch_remote_name(upstream) + + src <- .Call(git2r_branch_canonical_name, object) + dst <- .Call(git2r_branch_upstream_canonical_name, object) + refspec <- paste0(src, ":", dst) + object <- object@repo + } else { + object <- lookup_repository(object) + } + + if (all(is.null(name), is.null(refspec))) { + b <- repository_head(object) + upstream <- branch_get_upstream(b) + if (is.null(upstream)) { + stop("The branch '", b@name, "' that you are ", + "trying to push does not track an upstream branch.") + } + + src <- .Call(git2r_branch_canonical_name, b) + dst <- .Call(git2r_branch_upstream_canonical_name, b) + name <- branch_remote_name(upstream) + refspec <- paste0(src, ":", dst) + + if (isTRUE(force)) + refspec <- paste0("+", refspec) + } else { + opts <- list(force = force) + tmp <- get_refspec(object, name, refspec, opts) + name <- tmp$remote + refspec <- tmp$refspec + } + + invisible(.Call(git2r_push, object, name, refspec, credentials)) +} diff -Nru r-cran-git2r-0.21.0/R/reference.r r-cran-git2r-0.22.1/R/reference.r --- r-cran-git2r-0.21.0/R/reference.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/reference.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Get all references that can be found in a repository. -##' -##' @rdname references-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return Character vector with references -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize two temporary repositories -##' path_bare <- tempfile(pattern="git2r-") -##' path_repo <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' dir.create(path_repo) -##' repo_bare <- init(path_bare, bare = TRUE) -##' repo <- clone(path_bare, path_repo) -##' -##' ## Config user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Push commits from repository to bare repository -##' ## Adds an upstream tracking branch to branch 'master' -##' push(repo, "origin", "refs/heads/master") -##' -##' ## Add tag to HEAD -##' tag(repo, "v1.0", "First version") -##' -##' ## Create a note -##' note_create(commits(repo)[[1]], "My note") -##' -##' ## List all references in repository -##' references(repo) -##' } -##' -setGeneric("references", - signature = "repo", - function(repo) standardGeneric("references")) - -##' @rdname references-methods -##' @include S4_classes.r -##' @export -setMethod("references", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname references-methods -##' @include S4_classes.r -##' @export -setMethod("references", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_reference_list, repo) - } -) - -##' Brief summary of reference -##' -##' @aliases show,git_reference-methods -##' @docType methods -##' @param object The reference \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @include S4_classes.r -##' @export -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Brief summary of reference -##' references(repo)[[1]] -##' } -setMethod("show", - signature(object = "git_reference"), - function(object) - { - if (identical(object@type, 1L)) { - cat(sprintf("[%s] %s\n", - substr(object@sha, 1 , 6), - object@shorthand)) - } else if (identical(object@type, 2L)) { - cat(sprintf("%s => %s\n", - object@name, - object@target)) - } else { - stop("Unexpected reference type") - } - } -) diff -Nru r-cran-git2r-0.21.0/R/reference.R r-cran-git2r-0.22.1/R/reference.R --- r-cran-git2r-0.21.0/R/reference.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/reference.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,71 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Get all references that can be found in a repository. +##' @template repo-param +##' @return Character vector with references +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize two temporary repositories +##' path_bare <- tempfile(pattern="git2r-") +##' path_repo <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' dir.create(path_repo) +##' repo_bare <- init(path_bare, bare = TRUE) +##' repo <- clone(path_bare, path_repo) +##' +##' ## Config user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Push commits from repository to bare repository +##' ## Adds an upstream tracking branch to branch 'master' +##' push(repo, "origin", "refs/heads/master") +##' +##' ## Add tag to HEAD +##' tag(repo, "v1.0", "First version") +##' +##' ## Create a note +##' note_create(commits(repo)[[1]], "My note") +##' +##' ## List all references in repository +##' references(repo) +##' } +##' +references <- function(repo = ".") { + .Call(git2r_reference_list, lookup_repository(repo)) +} + +##' @export +print.git_reference <- function(x, ...) { + if (identical(x$type, 1L)) { + cat(sprintf("[%s] %s\n", + substr(x$sha, 1 , 6), + x$shorthand)) + } else if (identical(x$type, 2L)) { + cat(sprintf("%s => %s\n", + x$name, + x$target)) + } else { + stop("Unexpected reference type") + } +} diff -Nru r-cran-git2r-0.21.0/R/reflog.r r-cran-git2r-0.22.1/R/reflog.r --- r-cran-git2r-0.21.0/R/reflog.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/reflog.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' List and view reflog information -##' -##' @rdname reflog-methods -##' @docType methods -##' @param repo S4 class git_repository \code{object}. -##' @param refname The name of the reference to list. 'HEAD' by -##' default. -##' @return S3 class \code{git_reflog} with git_reflog_entry objects. -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Second commit message") -##' -##' ## Change file again and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", -##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Third commit message") -##' -##' ## View reflog -##' reflog(repo) -##' } -setGeneric("reflog", - signature = c("repo", "refname"), - function(repo, refname) - standardGeneric("reflog")) - -##' @rdname reflog-methods -##' @export -setMethod("reflog", - signature(repo = "git_repository", - refname = "missing"), - function(repo) - { - callGeneric(repo = repo, refname = "HEAD") - } -) - -##' @rdname reflog-methods -##' @export -setMethod("reflog", - signature(repo = "git_repository", - refname = "character"), - function(repo, refname) - { - structure(.Call(git2r_reflog_list, repo, refname), - class = "git_reflog") - } -) - -##' @export -print.git_reflog <- function(x, ...) -{ - lapply(x, show) - invisible(NULL) -} - -##' Brief summary of a reflog entry -##' -##' @aliases show,git_reflog_entry-methods -##' @docType methods -##' @param object The reflog entry \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## View repository HEAD reflog -##' reflog(repo) -##' } -setMethod("show", - signature(object = "git_reflog_entry"), - function(object) - { - cat(sprintf("[%s] %s@{%i}: %s\n", - substring(object@sha, 1, 7), - object@refname, - object@index, - object@message)) - } -) diff -Nru r-cran-git2r-0.21.0/R/reflog.R r-cran-git2r-0.22.1/R/reflog.R --- r-cran-git2r-0.21.0/R/reflog.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/reflog.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,98 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' List and view reflog information +##' +##' @template repo-param +##' @param refname The name of the reference to list. 'HEAD' by +##' default. +##' @return S3 class \code{git_reflog} with git_reflog_entry objects. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Second commit message") +##' +##' ## Change file again and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", +##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Third commit message") +##' +##' ## View reflog +##' reflog(repo) +##' } +reflog <- function(repo = ".", refname = "HEAD") { + structure(.Call(git2r_reflog_list, lookup_repository(repo), refname), + class = "git_reflog") +} + +##' @export +print.git_reflog <- function(x, ...) +{ + lapply(x, print) + invisible(NULL) +} + +##' Print a reflog entry +##' +##' @param x The reflog entry +##' @param ... Unused +##' @return None (invisible 'NULL'). +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## View repository HEAD reflog +##' reflog(repo) +##' } +print.git_reflog_entry <- function(x, ...) { + cat(sprintf("[%s] %s@{%i}: %s\n", + substring(x$sha, 1, 7), + x$refname, + x$index, + x$message)) +} diff -Nru r-cran-git2r-0.21.0/R/refspec.r r-cran-git2r-0.22.1/R/refspec.r --- r-cran-git2r-0.21.0/R/refspec.r 2017-12-20 14:55:27.000000000 +0000 +++ r-cran-git2r-0.22.1/R/refspec.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2017 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Create push refspec from arguments -##' -##' @param repo S4 class \code{git_repository} -##' @param name The remote's name. Default is NULL. -##' @param refspec The refspec to be pushed. Default is NULL. -##' @param opts List with push options. Default is NULL. -##' @return List with remote (character vector) and refspec (character -##' vector). -##' @keywords internal -get_refspec <- function(repo = NULL, remote = NULL, spec = NULL, opts = NULL) -{ - stopifnot(is(object = repo, class2 = "git_repository")) - - if (is_detached(repo)) - stop("You are not currently on a branch.") - - ## Options: - if (!is.null(opts)) { - stopifnot(is.list(opts)) - } else { - opts <- list() - } - - ## Remote: - ## From: http://git-scm.com/docs/git-push - ## When the command line does not specify where to push with the - ## argument, branch.*.remote configuration for the - ## current branch is consulted to determine where to push. If the - ## configuration is missing, it defaults to origin. - if (!is.null(remote)) { - stopifnot(is.character(remote), identical(length(remote), 1L)) - remote <- sub("^[[:space:]]*", "", sub("[[:space:]]*$", "", remote)) - if (identical(nchar(remote), 0L)) - remote <- NULL - } - if (is.null(remote)) { - remote <- .Call(git2r_config_get_string, - repo, - paste0("branch.", git2r::head(repo)@name, ".remote")) - if (is.null(remote)) - remote <- "origin" - } - - ## Refspec: - stopifnot(is.character(spec)) - - if (isTRUE(opts$force)) - spec <- paste0("+", spec) - - list(remote = remote, refspec = spec) -} diff -Nru r-cran-git2r-0.21.0/R/refspec.R r-cran-git2r-0.22.1/R/refspec.R --- r-cran-git2r-0.21.0/R/refspec.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/refspec.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,66 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Create push refspec from arguments +##' +##' @param repo a \code{git_repository} object. +##' @param name The remote's name. Default is NULL. +##' @param refspec The refspec to be pushed. Default is NULL. +##' @param opts List with push options. Default is NULL. +##' @return List with remote (character vector) and refspec (character +##' vector). +##' @noRd +get_refspec <- function(repo = NULL, remote = NULL, spec = NULL, opts = NULL) { + stopifnot(inherits(repo, "git_repository")) + + if (is_detached(repo)) + stop("You are not currently on a branch.") + + ## Options: + if (!is.null(opts)) { + stopifnot(is.list(opts)) + } else { + opts <- list() + } + + ## Remote: + ## From: http://git-scm.com/docs/git-push + ## When the command line does not specify where to push with the + ## argument, branch.*.remote configuration for the + ## current branch is consulted to determine where to push. If the + ## configuration is missing, it defaults to origin. + if (!is.null(remote)) { + stopifnot(is.character(remote), identical(length(remote), 1L)) + remote <- sub("^[[:space:]]*", "", sub("[[:space:]]*$", "", remote)) + if (identical(nchar(remote), 0L)) + remote <- NULL + } + if (is.null(remote)) { + remote <- .Call(git2r_config_get_string, + repo, + paste0("branch.", repository_head(repo)$name, ".remote")) + if (is.null(remote)) + remote <- "origin" + } + + ## Refspec: + stopifnot(is.character(spec)) + + if (isTRUE(opts$force)) + spec <- paste0("+", spec) + + list(remote = remote, refspec = spec) +} diff -Nru r-cran-git2r-0.21.0/R/remote.r r-cran-git2r-0.22.1/R/remote.r --- r-cran-git2r-0.21.0/R/remote.r 2018-01-02 11:25:48.000000000 +0000 +++ r-cran-git2r-0.22.1/R/remote.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,398 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Get the configured remotes for a repo -##' -##' @rdname remotes-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return Character vector with remotes -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Add a remote -##' remote_add(repo, "playground", "https://example.org/git2r/playground") -##' remotes(repo) -##' remote_url(repo, "playground") -##' -##' ## Rename a remote -##' remote_rename(repo, "playground", "foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Remove a remote -##' remote_remove(repo, "foobar") -##' remotes(repo) -##' } -setGeneric("remotes", - signature = "repo", - function(repo) - standardGeneric("remotes")) - -##' @rdname remotes-methods -##' @export -setMethod("remotes", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname remotes-methods -##' @export -setMethod("remotes", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_remote_list, repo) - } -) - -##' Add a remote to a repo -##' -##' @rdname remote_add-methods -##' @docType methods -##' @param repo The repository to add the remote to -##' @param name Short name of the remote repository -##' @param url URL of the remote repository -##' @return NULL, invisibly -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Add a remote -##' remote_add(repo, "playground", "https://example.org/git2r/playground") -##' remotes(repo) -##' remote_url(repo, "playground") -##' -##' ## Rename a remote -##' remote_rename(repo, "playground", "foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Remove a remote -##' remote_remove(repo, "foobar") -##' remotes(repo) -##' } -setGeneric("remote_add", - signature = c("repo", "name", "url"), - function(repo, name, url) - standardGeneric("remote_add")) - -##' @rdname remote_add-methods -##' @export -setMethod("remote_add", - signature(repo = "git_repository", - name = "character", - url = "character"), - function(repo, name, url) - { - ret <- .Call(git2r_remote_add, repo, name, url) - invisible(ret) - } -) - -##' Rename a remote -##' -##' @rdname remote_rename-methods -##' @docType methods -##' @param repo The repository in which the remote should be renamed. -##' @param oldname Old name of the remote -##' @param newname New name of the remote -##' @return NULL, invisibly -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Add a remote -##' remote_add(repo, "playground", "https://example.org/git2r/playground") -##' remotes(repo) -##' remote_url(repo, "playground") -##' -##' ## Rename a remote -##' remote_rename(repo, "playground", "foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Remove a remote -##' remote_remove(repo, "foobar") -##' remotes(repo) -##' } -setGeneric("remote_rename", - signature = c("repo", "oldname", "newname"), - function(repo, oldname, newname) - standardGeneric("remote_rename")) - -##' @rdname remote_rename-methods -##' @export -setMethod("remote_rename", - signature(repo = "git_repository", - oldname = "character", - newname = "character"), - function(repo, oldname, newname) - { - ret <- .Call(git2r_remote_rename, repo, oldname, newname) - invisible(ret) - } -) - -##' Remove a remote -##' -##' All remote-tracking branches and configuration settings for the -##' remote will be removed. -##' @rdname remote_remove-methods -##' @docType methods -##' @param repo The repository to work on -##' @param name The name of the remote to remove -##' @return NULL, invisibly -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Add a remote -##' remote_add(repo, "playground", "https://example.org/git2r/playground") -##' remotes(repo) -##' remote_url(repo, "playground") -##' -##' ## Rename a remote -##' remote_rename(repo, "playground", "foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Remove a remote -##' remote_remove(repo, "foobar") -##' remotes(repo) -##' } -setGeneric("remote_remove", - signature = c("repo", "name"), - function(repo, name) - standardGeneric("remote_remove")) - -##' @rdname remote_remove-methods -##' @export -setMethod("remote_remove", - signature(repo = "git_repository", - name = "character"), - function(repo, name) - { - ret <- .Call(git2r_remote_remove, repo, name) - invisible(ret) - } -) - -##' Set the remote's url in the configuration -##' -##' This assumes the common case of a single-url remote and will -##' otherwise raise an error. -##' @rdname remote_set_url-methods -##' @docType methods -##' @param repo The repository in which to perform the change -##' @param name The name of the remote -##' @param url The \code{url} to set -##' @return NULL, invisibly -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Add a remote -##' remote_add(repo, "playground", "https://example.org/git2r/playground") -##' remotes(repo) -##' remote_url(repo, "playground") -##' -##' ## Rename a remote -##' remote_rename(repo, "playground", "foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Set remote url -##' remote_set_url(repo, "foobar", "https://example.org/git2r/foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Remove a remote -##' remote_remove(repo, "foobar") -##' remotes(repo) -##' } -setGeneric("remote_set_url", - signature = c("repo", "name", "url"), - function(repo, name, url) - standardGeneric("remote_set_url")) - -##' @rdname remote_set_url-methods -##' @export -setMethod("remote_set_url", - signature(repo = "git_repository", - name = "character", - url = "character"), - function(repo, name, url) - { - ret <- .Call(git2r_remote_set_url, repo, name, url) - invisible(ret) - } -) - -##' Get the remote url for remotes in a repo -##' -##' @rdname remote_url-methods -##' @docType methods -##' @param repo The repository to get remote urls from -##' @param remote Character vector with the remotes to get the url -##' from. Default is the remotes of the repository. -##' @return Character vector with remote_url for each of the remote -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Add a remote -##' remote_add(repo, "playground", "https://example.org/git2r/playground") -##' remotes(repo) -##' remote_url(repo, "playground") -##' -##' ## Rename a remote -##' remote_rename(repo, "playground", "foobar") -##' remotes(repo) -##' remote_url(repo, "foobar") -##' -##' ## Remove a remote -##' remote_remove(repo, "foobar") -##' remotes(repo) -##' } -setGeneric("remote_url", - signature = "repo", - function(repo, remote = remotes(repo)) - standardGeneric("remote_url")) - -##' @rdname remote_url-methods -##' @export -setMethod("remote_url", - signature(repo = "git_repository"), - function(repo, remote) - { - .Call(git2r_remote_url, repo, remote) - } -) - - -##' List references in a remote repository -##' -##' Displays references available in a remote repository along with the -##' associated commit IDs. Akin to the 'git ls-remote' command. -##' @rdname remote_ls-methods -##' @docType methods -##' @param name Character vector with the "remote" repository URL to query or -##' the name of the remote if a \code{repo} argument is given. -##' @param repo an optional repository object used if remotes are -##' specified by name. -##' @param credentials The credentials for remote repository -##' access. Default is NULL. To use and query an ssh-agent for the ssh -##' key credentials, let this parameter be NULL (the default). -##' @keywords methods -##' @return Character vector for each reference with the associated commit IDs. -##' @examples -##' \dontrun{ -##' remote_ls("https://github.com/ropensci/git2r") -##' } -##' @export -setGeneric("remote_ls", - signature = c("name"), - function(name, - repo = NULL, - credentials = NULL) - standardGeneric("remote_ls")) - -##' @rdname remote_ls-methods -##' @export -setMethod("remote_ls", - signature(name = "character"), - function(name, repo, credentials) - { - ## FIXME: When updating to libgit 0.26 + 1, remove this - ## and allow repo to be NULL, see 'git2r_remote_ls'. - if (is.null(repo)) { - path <- tempdir() - repo <- git2r::init(path) - on.exit(unlink(file.path(path, ".git"), recursive = TRUE)) - } - - .Call(git2r_remote_ls, name, repo, credentials) - } -) diff -Nru r-cran-git2r-0.21.0/R/remote.R r-cran-git2r-0.22.1/R/remote.R --- r-cran-git2r-0.21.0/R/remote.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/remote.R 2018-06-02 11:32:40.000000000 +0000 @@ -0,0 +1,129 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Get the configured remotes for a repo +##' +##' @template repo-param +##' @return Character vector with remotes +##' @export +##' @template remote-example +remotes <- function(repo = ".") { + .Call(git2r_remote_list, lookup_repository(repo)) +} + +##' Add a remote to a repo +##' +##' @template repo-param +##' @param name Short name of the remote repository +##' @param url URL of the remote repository +##' @return NULL, invisibly +##' @export +##' @template remote-example +remote_add <- function(repo = ".", name = NULL, url = NULL) { + .Call(git2r_remote_add, lookup_repository(repo), name, url) + invisible(NULL) +} + +##' Rename a remote +##' +##' @template repo-param +##' @param oldname Old name of the remote +##' @param newname New name of the remote +##' @return NULL, invisibly +##' @export +##' @template remote-example +remote_rename <- function(repo = ".", oldname = NULL, newname = NULL) { + .Call(git2r_remote_rename, lookup_repository(repo), oldname, newname) + invisible(NULL) +} + +##' Remove a remote +##' +##' All remote-tracking branches and configuration settings for the +##' remote will be removed. +##' @template repo-param +##' @param name The name of the remote to remove +##' @return NULL, invisibly +##' @export +##' @template remote-example +remote_remove <- function(repo = ".", name = NULL) { + .Call(git2r_remote_remove, lookup_repository(repo), name) + invisible(NULL) +} + +##' Set the remote's url in the configuration +##' +##' This assumes the common case of a single-url remote and will +##' otherwise raise an error. +##' @template repo-param +##' @param name The name of the remote +##' @param url The \code{url} to set +##' @return NULL, invisibly +##' @export +##' @template remote-example +remote_set_url <- function(repo = ".", name = NULL, url = NULL) { + .Call(git2r_remote_set_url, lookup_repository(repo), name, url) + invisible(NULL) +} + +##' Get the remote url for remotes in a repo +##' +##' @template repo-param +##' @param remote Character vector with the remotes to get the url +##' from. Default is the remotes of the repository. +##' @return Character vector with remote_url for each of the remote +##' @export +##' @template remote-example +remote_url <- function(repo = ".", remote = NULL) { + repo <- lookup_repository(repo) + if (is.null(remote)) + remote <- remotes(repo) + .Call(git2r_remote_url, repo, remote) +} + +##' List references in a remote repository +##' +##' Displays references available in a remote repository along with +##' the associated commit IDs. Akin to the 'git ls-remote' command. +##' @param name Character vector with the "remote" repository URL to +##' query or the name of the remote if a \code{repo} argument is +##' given. +##' @param repo an optional repository object used if remotes are +##' specified by name. +##' @param credentials The credentials for remote repository +##' access. Default is NULL. To use and query an ssh-agent for the +##' ssh key credentials, let this parameter be NULL (the default). +##' @return Character vector for each reference with the associated +##' commit IDs. +##' @export +##' @examples +##' \dontrun{ +##' remote_ls("https://github.com/ropensci/git2r") +##' } +remote_ls <- function(name = NULL, repo = NULL, credentials = NULL) { + if (is.null(repo)) { + ver <- libgit2_version() + if (ver$major == 0 && ver$minor < 27) { + path <- tempdir() + repo <- init(path) + on.exit(unlink(file.path(path, ".git"), recursive = TRUE)) + } + } else { + repo <- lookup_repository(repo) + } + + .Call(git2r_remote_ls, name, repo, credentials) +} diff -Nru r-cran-git2r-0.21.0/R/repository.r r-cran-git2r-0.22.1/R/repository.r --- r-cran-git2r-0.21.0/R/repository.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/repository.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,1097 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Coerce Git repository to a \code{data.frame} -##' -##' The commits in the repository are coerced to a \code{data.frame} -##' -##' -##' The \code{data.frame} have the following columns: -##' \describe{ -##' -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' -##' \item{summary}{ -##' the short "summary" of the git commit message. -##' } -##' -##' \item{message}{ -##' the full message of a commit -##' } -##' -##' \item{author}{ -##' full name of the author -##' } -##' -##' \item{email}{ -##' email of the author -##' } -##' -##' \item{when}{ -##' time when the commit happened -##' } -##' -##' } -##' @name coerce-git_repository-method -##' @aliases coerce,git_repository,data.frame-method -##' @docType methods -##' @param from The repository \code{object} -##' @return \code{data.frame} -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create three files and commit -##' writeLines("First file", file.path(path, "example-1.txt")) -##' writeLines("Second file", file.path(path, "example-2.txt")) -##' writeLines("Third file", file.path(path, "example-3.txt")) -##' add(repo, "example-1.txt") -##' commit(repo, "Commit first file") -##' add(repo, "example-2.txt") -##' commit(repo, "Commit second file") -##' add(repo, "example-3.txt") -##' commit(repo, "Commit third file") -##' -##' ## Coerce commits to a data.frame -##' df <- as(repo, "data.frame") -##' df -##' } -setAs(from="git_repository", - to="data.frame", - def=function(from) - { - do.call("rbind", lapply(commits(from), as, "data.frame")) - } -) - -##' Open a repository -##' -##' @rdname repository-methods -##' @docType methods -##' @param path A path to an existing local git repository -##' @param ... Additional arguments to \code{repository} method. -##' @param discover Discover repository from path. Default is FALSE. -##' @return A S4 \code{\linkS4class{git_repository}} object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test-1.txt")) -##' add(repo, 'test-1.txt') -##' commit_1 <- commit(repo, "Commit message") -##' -##' ## Make one more commit -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) -##' add(repo, 'test-1.txt') -##' commit(repo, "Next commit message") -##' -##' ## Create one more file -##' writeLines("Hello world!", file.path(path, "test-2.txt")) -##' -##' ## Brief summary of repository -##' repo -##' -##' ## Summary of repository -##' summary(repo) -##' -##' ## Workdir of repository -##' workdir(repo) -##' -##' ## Check if repository is bare -##' is_bare(repo) -##' -##' ## Check if repository is empty -##' is_empty(repo) -##' -##' ## Check if repository is a shallow clone -##' is_shallow(repo) -##' -##' ## List all references in repository -##' references(repo) -##' -##' ## List all branches in repository -##' branches(repo) -##' -##' ## Get HEAD of repository -##' head(repo) -##' -##' ## Check if HEAD is head -##' is_head(head(repo)) -##' -##' ## Check if HEAD is local -##' is_local(head(repo)) -##' -##' ## List all tags in repository -##' tags(repo) -##' } -setGeneric("repository", - signature = "path", - function(path, ...) - standardGeneric("repository")) - -##' @rdname repository-methods -##' @export -setMethod("repository", - signature(path = "missing"), - function() - { - callGeneric(path = getwd(), discover = TRUE) - } -) - -##' @rdname repository-methods -##' @export -setMethod("repository", - signature(path = "character"), - function(path, discover = FALSE, ...) - { - ## Argument checking - stopifnot(identical(length(path), 1L), - nchar(path) > 0, - is.logical(discover), - identical(length(discover), 1L)) - - if (discover) { - path <- discover_repository(path) - if (is.null(path)) - stop("The 'path' is not in a git repository") - } else { - path <- normalizePath(path, winslash = "/", mustWork = TRUE) - if (!file.info(path)$isdir) - stop("'path' is not a directory") - } - - new("git_repository", path = path) - } -) - -##' Init a repository -##' -##' @rdname init-methods -##' @docType methods -##' @param path A path to where to init a git repository -##' @param bare If TRUE, a Git repository without a working directory -##' is created at the pointed path. If FALSE, provided path will be -##' considered as the working directory into which the .git directory -##' will be created. -##' @return A S4 \code{\linkS4class{git_repository}} object -##' @keywords methods -##' @seealso \link{repository} -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' is_bare(repo) -##' -##' ## Initialize a bare repository -##' path_bare <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' repo_bare <- init(path_bare, bare = TRUE) -##' is_bare(repo_bare) -##' } -setGeneric("init", - signature = "path", - function(path, - bare = FALSE) - standardGeneric("init")) - -##' @rdname init-methods -##' @export -setMethod("init", - signature(path = "character"), - function(path, bare) - { - ## Argument checking - stopifnot(identical(length(path), 1L), - nchar(path) > 0, - is.logical(bare), - identical(length(bare), 1L)) - - path <- normalizePath(path, winslash = "/", mustWork = TRUE) - if (!file.info(path)$isdir) - stop("path is not a directory") - - .Call(git2r_repository_init, path, bare) - - new("git_repository", path=path) - } -) - -##' Clone a remote repository -##' -##' @rdname clone-methods -##' @docType methods -##' @param url The remote repository to clone -##' @param local_path Local directory to clone to. -##' @param bare Create a bare repository. Default is FALSE. -##' @param branch The name of the branch to checkout. Default is NULL -##' which means to use the remote's default branch. -##' @param checkout Checkout HEAD after the clone is complete. Default is TRUE. -##' @param credentials The credentials for remote repository -##' access. Default is NULL. To use and query an ssh-agent for the ssh -##' key credentials, let this parameter be NULL (the default). -##' @param progress Show progress. Default is TRUE. -##' @return A S4 \code{\linkS4class{git_repository}} object -##' @seealso \code{\linkS4class{cred_user_pass}}, -##' \code{\linkS4class{cred_ssh_key}} -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize repository -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' repo_1 <- init(path_repo_1) -##' -##' ## Config user and commit a file -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "First commit message") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Second commit message") -##' -##' ## Change file again and commit. -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", -##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Third commit message") -##' -##' ## Clone to second repository -##' repo_2 <- clone(path_repo_1, path_repo_2) -##' -##' ## List commits in repositories -##' commits(repo_1) -##' commits(repo_2) -##' } -setGeneric("clone", - signature = c("url", "local_path"), - function(url, - local_path, - bare = FALSE, - branch = NULL, - checkout = TRUE, - credentials = NULL, - progress = TRUE) - standardGeneric("clone")) - -##' @rdname clone-methods -##' @export -setMethod("clone", - signature(url = "character", - local_path = "character"), - function(url, - local_path, - bare, - branch, - checkout, - credentials, - progress) - { - .Call(git2r_clone, url, local_path, bare, - branch, checkout, credentials, progress) - - repository(local_path) - } -) - -##' Get HEAD for a repository -##' -##' @rdname head-methods -##' @docType methods -##' @param x The repository \code{x} to check head -##' @return NULL if unborn branch or not found. S4 class git_branch if -##' not a detached head. S4 class git_commit if detached head -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Commit message") -##' -##' ## Get HEAD of repository -##' head(repo) -##' } -setMethod("head", - signature(x = "git_repository"), - function(x) - { - .Call(git2r_repository_head, x) - } -) - -##' Check if repository is bare -##' -##' @rdname is_bare-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}} to check if it's bare. If the -##' \code{repo} argument is missing, the repository is searched for -##' with \code{\link{discover_repository}} in the current working -##' directory. -##' @return TRUE if bare repository, else FALSE -##' @keywords methods -##' @seealso \link{init} -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' is_bare(repo) -##' -##' ## Initialize a bare repository -##' path_bare <- tempfile(pattern="git2r-") -##' dir.create(path_bare) -##' repo_bare <- init(path_bare, bare = TRUE) -##' is_bare(repo_bare) -##' } -setGeneric("is_bare", - signature = "repo", - function(repo) - standardGeneric("is_bare")) - -##' @rdname is_bare-methods -##' @export -setMethod("is_bare", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_repository_is_bare, repo) - } -) - -##' @rdname is_bare-methods -##' @export -setMethod("is_bare", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' Check if HEAD of repository is detached -##' -##' @rdname is_detached-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return TRUE if repository HEAD is detached, else FALSE -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create and initialize a repository in a temporary directory -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "Commit message 1") -##' -##' ## Change file, add and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "Commit message 2") -##' -##' ## HEAD of repository is not detached -##' is_detached(repo) -##' -##' ## Checkout first commit -##' checkout(commit_1) -##' -##' ## HEAD of repository is detached -##' is_detached(repo) -##' } -setGeneric("is_detached", - signature = "repo", - function(repo) - standardGeneric("is_detached")) - - -##' @rdname is_detached-methods -##' @export -setMethod("is_detached", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname is_detached-methods -##' @export -setMethod("is_detached", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_repository_head_detached, repo) - } -) - -##' Check if repository is empty -##' -##' @rdname is_empty-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}} to check if it's empty. If the -##' \code{repo} argument is missing, the repository is searched for -##' with \code{\link{discover_repository}} in the current working -##' directory. -##' @return TRUE if empty else FALSE -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Check if it's an empty repository -##' is_empty(repo) -##' -##' ## Commit a file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Check if it's an empty repository -##' is_empty(repo) -##' } -setGeneric("is_empty", - signature = "repo", - function(repo) - standardGeneric("is_empty")) - - -##' @rdname is_empty-methods -##' @export -setMethod("is_empty", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname is_empty-methods -##' @export -setMethod("is_empty", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_repository_is_empty, repo) - } -) - -##' Determine if a directory is in a git repository -##' -##' The lookup start from path and walk across parent directories if -##' nothing has been found. -##' @rdname in_repository-methods -##' @docType methods -##' @param path The path to the directory. The working directory is -##' used if path is missing. -##' @return TRUE if directory is in a git repository else FALSE -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Check if path is in a git repository -##' in_repository(path) -##' -##' ## Check if working directory is in a git repository -##' setwd(path) -##' in_repository() -##' } -setGeneric("in_repository", - signature = "path", - function(path) - standardGeneric("in_repository")) - -##' @rdname in_repository-methods -##' @export -setMethod("in_repository", - signature(path = "missing"), - function() - { - callGeneric(path = getwd()) - } -) - -##' @rdname in_repository-methods -##' @export -setMethod("in_repository", - signature(path = "character"), - function(path) - { - !is.null(discover_repository(path)) - } -) - -##' Determine if the repository was a shallow clone -##' -##' @rdname is_shallow-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return TRUE if shallow clone, else FALSE -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize repository -##' path_repo_1 <- tempfile(pattern="git2r-") -##' path_repo_2 <- tempfile(pattern="git2r-") -##' dir.create(path_repo_1) -##' dir.create(path_repo_2) -##' repo_1 <- init(path_repo_1) -##' -##' ## Config user and commit a file -##' config(repo_1, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Write to a file and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "First commit message") -##' -##' ## Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Second commit message") -##' -##' ## Change file again and commit. -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", -##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), -##' file.path(path_repo_1, "example.txt")) -##' add(repo_1, "example.txt") -##' commit(repo_1, "Third commit message") -##' -##' ## Clone to second repository -##' repo_2 <- clone(path_repo_1, path_repo_2) -##' -##' ## Check if it's a shallow clone -##' is_shallow(repo_2) -##' } -setGeneric("is_shallow", - signature = "repo", - function(repo) - standardGeneric("is_shallow")) - - -##' @rdname is_shallow-methods -##' @export -setMethod("is_shallow", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname is_shallow-methods -##' @export -setMethod("is_shallow", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_repository_is_shallow, repo) - } -) - -##' Lookup -##' -##' Lookup one object in a repository. -##' @rdname lookup-methods -##' @docType methods -##' @param repo The repository. -##' @param sha The identity of the object to lookup. Must be 4 to 40 -##' characters long. -##' @return a \code{git_blob} or \code{git_commit} or \code{git_tag} -##' or \code{git_tree} object -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit_1 <- commit(repo, "First commit message") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' ## First, get SHAs to lookup in the repository -##' sha_commit <- commit_1@@sha -##' sha_tree <- tree(commit_1)@@sha -##' sha_blob <- tree(commit_1)["example.txt"]@@sha -##' sha_tag <- tags(repo)[[1]]@@sha -##' -##' ## SHAs -##' sha_commit -##' sha_tree -##' sha_blob -##' sha_tag -##' -##' ## Lookup objects -##' lookup(repo, sha_commit) -##' lookup(repo, sha_tree) -##' lookup(repo, sha_blob) -##' lookup(repo, sha_tag) -##' -##' ## Lookup objects, using only the first seven characters -##' lookup(repo, substr(sha_commit, 1, 7)) -##' lookup(repo, substr(sha_tree, 1, 7)) -##' lookup(repo, substr(sha_blob, 1, 7)) -##' lookup(repo, substr(sha_tag, 1, 7)) -##' } -setGeneric("lookup", - signature = c("repo", "sha"), - function(repo, sha) - standardGeneric("lookup")) - -##' @rdname lookup-methods -##' @export -setMethod("lookup", - signature(repo = "git_repository", - sha = "character"), - function(repo, sha) - { - .Call(git2r_object_lookup, repo, sha) - } -) - -##' Get the signature -##' -##' Get the signature according to the repository's configuration -##' @rdname default_signature-methods -##' @docType methods -##' @param repo The repository \code{object} to check signature -##' @return S4 class git_signature -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Get the default signature -##' default_signature(repo) -##' -##' ## Change user -##' config(repo, user.name="Bob", user.email="bob@@example.org") -##' -##' ## Get the default signature -##' default_signature(repo) -##' } -setGeneric("default_signature", - signature = "repo", - function(repo) - standardGeneric("default_signature")) - -##' @rdname default_signature-methods -##' @export -setMethod("default_signature", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_signature_default, repo) - } -) - -##' Brief summary of repository -##' -##' @aliases show,git_repository-methods -##' @docType methods -##' @param object The repository \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Brief summary of the repository -##' repo -##' -##' ## Create and commit a file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Brief summary of the repository -##' repo -##' } -setMethod("show", - signature(object = "git_repository"), - function(object) - { - if (any(is_empty(object), is.null(head(object)))) { - cat(sprintf("Local: %s\n", workdir(object))) - cat("Head: nothing commited (yet)\n") - } else { - if (is_detached(object)) { - cat(sprintf("Local: (detached) %s\n", workdir(object))) - - h <- git2r::head(object) - } else { - cat(sprintf("Local: %s %s\n", - head(object)@name, - workdir(object))) - - h <- head(object) - u <- branch_get_upstream(h) - if (!is.null(u)) { - rn <- branch_remote_name(u) - cat(sprintf("Remote: %s @ %s (%s)\n", - substr(u@name, nchar(rn) + 2, nchar(u@name)), - rn, - branch_remote_url(u))) - } - - h <- lookup(object, branch_target(head(object))) - } - - cat(sprintf("Head: [%s] %s: %s\n", - substring(h@sha, 1, 7), - substring(as(h@author@when, "character"), 1, 10), - h@summary)) - } - } -) - -##' Summary of repository -##' -##' @aliases summary,git_repository-methods -##' @docType methods -##' @param object The repository \code{object} -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' summary(repo) -##' -##' ## Add file -##' add(repo, "test.txt") -##' summary(repo) -##' -##' ## Commit -##' commit(repo, "First commit message") -##' summary(repo) -##' -##' ## Change the file -##' writeLines(c("Hello again!", "Here is a second line", "And a third"), -##' file.path(path, "test.txt")) -##' summary(repo) -##' -##' ## Add file and commit -##' add(repo, "test.txt") -##' commit(repo, "Second commit message") -##' summary(repo) -##'} -setMethod("summary", - signature(object = "git_repository"), - function(object, ...) - { - show(object) - cat("\n") - - n_branches <- sum(!is.na(unique(sapply(branches(object), - branch_target)))) - n_tags <- sum(!is.na(unique(vapply(tags(object), slot, character(1), "sha")))) - - work <- commits(object) - n_commits <- length(work) - n_authors <- length(unique(vapply(lapply(work, slot, "author"), - slot, character(1), "name"))) - - s <- .Call(git2r_status_list, object, TRUE, TRUE, TRUE, FALSE, TRUE) - n_ignored <- length(s$ignored) - n_untracked <- length(s$untracked) - n_unstaged <- length(s$unstaged) - n_staged <- length(s$staged) - - n_stashes <- length(stash_list(object)) - - ## Determine max characters needed to display numbers - n <- max(vapply(c(n_branches, n_tags, n_commits, n_authors, - n_stashes, n_ignored, n_untracked, - n_unstaged, n_staged), - nchar, - numeric(1))) - - fmt <- paste0("Branches: %", n, "i\n", - "Tags: %", n, "i\n", - "Commits: %", n, "i\n", - "Contributors: %", n, "i\n", - "Stashes: %", n, "i\n", - "Ignored files: %", n, "i\n", - "Untracked files: %", n, "i\n", - "Unstaged files: %", n, "i\n", - "Staged files: %", n, "i\n") - cat(sprintf(fmt, n_branches, n_tags, n_commits, n_authors, - n_stashes, n_ignored, n_untracked, n_unstaged, - n_staged)) - - cat("\nLatest commits:\n") - lapply(commits(object, n = 5), show) - - invisible(NULL) - } -) - -##' Workdir of repository -##' -##' @rdname workdir-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return Character vector with the path of the workdir. If the -##' repository is bare, \code{NULL} will be returned. -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' -##' ## Get the path of the workdir for repository -##' workdir(repo) -##' } -setGeneric("workdir", - signature = "repo", - function(repo) - standardGeneric("workdir")) - -##' @rdname workdir-methods -##' @export -setMethod("workdir", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname workdir-methods -##' @export -setMethod("workdir", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_repository_workdir, repo) - } -) - -##' Find path to repository for any file -##' -##' libgit's git_discover_repository is used to identify the location -##' of the repository. The path will therefore be terminated by a file -##' separator. -##' @rdname discover_repository-methods -##' @docType methods -##' @param path A character vector specifying the path to a file or folder -##' @param ceiling The defult is to not use the ceiling argument and -##' start the lookup from path and walk across parent -##' directories. When ceiling is 0, the lookup is only in path. When -##' ceiling is 1, the lookup is in both the path and the parent to -##' path. -##' @return Character vector with path to repository or NULL if this -##' cannot be established. -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' file.path(path, "example-1.txt")) -##' add(repo, "example-1.txt") -##' commit(repo, "First commit message") -##' -##' ## Create a second file. The file is not added for version control -##' ## in the repository. -##' dir.create(file.path(path, "example")) -##' file_2 <- file.path(path, "example/example-2.txt") -##' writeLines("Not under version control", file_2) -##' -##' ## Find the path to the repository using the path to the second file -##' discover_repository(file_2) -##' -##' ## Demonstrate the 'ceiling' argument -##' wd <- workdir(repo) -##' dir.create(file.path(wd, "temp")) -##' -##' ## Lookup repository in 'file.path(wd, "temp")'. Should return NULL -##' discover_repository(file.path(wd, "temp"), ceiling = 0) -##' -##' ## Lookup repository in parent to 'file.path(wd, "temp")'. -##' ## Should not return NULL -##' discover_repository(file.path(wd, "temp"), ceiling = 1) -##' } -setGeneric("discover_repository", - signature = c("path", "ceiling"), - function(path, ceiling) - standardGeneric("discover_repository")) - -##' @rdname discover_repository-methods -##' @export -setMethod("discover_repository", - signature(path = "character", ceiling = "missing"), - function(path) - { - callGeneric(path = path, ceiling = as.numeric(NA)) - } -) - -##' @rdname discover_repository-methods -##' @export -setMethod("discover_repository", - signature(path = "character", ceiling = "numeric"), - function(path, ceiling) - { - path <- normalizePath(path) - - if (is.na(ceiling)) { - ceiling <- NULL - } else { - ceiling <- as.integer(ceiling) - if (identical(ceiling, 0L)) { - ceiling <- dirname(path) - } else if (identical(ceiling, 1L)) { - ceiling <- dirname(dirname(path)) - } else { - stop("'ceiling' must be either 0 or 1") - } - } - - - .Call(git2r_repository_discover, path, ceiling) - } -) - -##' Lookup repository for methods with missing repo argument -##' -##' @return S4 class git_repository -##' @keywords internal -lookup_repository <- function() -{ - ## Try current working directory - repo <- discover_repository(getwd()) - if (is.null(repo)) - stop("The working directory is not in a git repository") - - repository(repo) -} diff -Nru r-cran-git2r-0.21.0/R/repository.R r-cran-git2r-0.22.1/R/repository.R --- r-cran-git2r-0.21.0/R/repository.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/repository.R 2018-05-31 16:05:01.000000000 +0000 @@ -0,0 +1,792 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Coerce Git repository to a \code{data.frame} +##' +##' The commits in the repository are coerced to a \code{data.frame} +##' +##' +##' The \code{data.frame} have the following columns: +##' \describe{ +##' +##' \item{sha}{ +##' The 40 character hexadecimal string of the SHA-1 +##' } +##' +##' \item{summary}{ +##' the short "summary" of the git commit message. +##' } +##' +##' \item{message}{ +##' the full message of a commit +##' } +##' +##' \item{author}{ +##' full name of the author +##' } +##' +##' \item{email}{ +##' email of the author +##' } +##' +##' \item{when}{ +##' time when the commit happened +##' } +##' +##' } +##' @param x The repository \code{object} +##' @param ... Additional arguments. Not used. +##' @return \code{data.frame} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create three files and commit +##' writeLines("First file", file.path(path, "example-1.txt")) +##' writeLines("Second file", file.path(path, "example-2.txt")) +##' writeLines("Third file", file.path(path, "example-3.txt")) +##' add(repo, "example-1.txt") +##' commit(repo, "Commit first file") +##' add(repo, "example-2.txt") +##' commit(repo, "Commit second file") +##' add(repo, "example-3.txt") +##' commit(repo, "Commit third file") +##' +##' ## Coerce commits to a data.frame +##' df <- as(repo, "data.frame") +##' df +##' } +as.data.frame.git_repository <- function(x, ...) { + do.call("rbind", lapply(commits(x), as.data.frame)) +} + +##' Open a repository +##' +##' @param path A path to an existing local git repository. +##' @param discover Discover repository from path. Default is TRUE. +##' @return A \code{git_repository} object with entries: +##' \describe{ +##' \item{path}{ +##' Path to a git repository +##' } +##' } +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test-1.txt")) +##' add(repo, 'test-1.txt') +##' commit_1 <- commit(repo, "Commit message") +##' +##' ## Make one more commit +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +##' add(repo, 'test-1.txt') +##' commit(repo, "Next commit message") +##' +##' ## Create one more file +##' writeLines("Hello world!", file.path(path, "test-2.txt")) +##' +##' ## Brief summary of repository +##' repo +##' +##' ## Summary of repository +##' summary(repo) +##' +##' ## Workdir of repository +##' workdir(repo) +##' +##' ## Check if repository is bare +##' is_bare(repo) +##' +##' ## Check if repository is empty +##' is_empty(repo) +##' +##' ## Check if repository is a shallow clone +##' is_shallow(repo) +##' +##' ## List all references in repository +##' references(repo) +##' +##' ## List all branches in repository +##' branches(repo) +##' +##' ## Get HEAD of repository +##' repository_head(repo) +##' +##' ## Check if HEAD is head +##' is_head(repository_head(repo)) +##' +##' ## Check if HEAD is local +##' is_local(repository_head(repo)) +##' +##' ## List all tags in repository +##' tags(repo) +##' } +repository <- function(path = ".", discover = TRUE) { + if (isTRUE(discover)) { + path <- discover_repository(path) + if (is.null(path)) + stop("The 'path' is not in a git repository") + } else { + path <- normalizePath(path, winslash = "/", mustWork = TRUE) + if (!file.info(path)$isdir) + stop("'path' is not a directory") + } + + if (!isTRUE(.Call(git2r_repository_can_open, path))) + stop("Unable to open repository at 'path'") + + structure(list(path = path), class = "git_repository") +} + +##' Init a repository +##' +##' @param path A path to where to init a git repository +##' @param bare If TRUE, a Git repository without a working directory +##' is created at the pointed path. If FALSE, provided path will +##' be considered as the working directory into which the .git +##' directory will be created. +##' @return A \code{git_repository} object +##' @export +##' @seealso \link{repository} +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' is_bare(repo) +##' +##' ## Initialize a bare repository +##' path_bare <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' repo_bare <- init(path_bare, bare = TRUE) +##' is_bare(repo_bare) +##' } +init <- function(path = ".", bare = FALSE) { + path <- normalizePath(path, winslash = "/", mustWork = TRUE) + if (!file.info(path)$isdir) + stop("'path' is not a directory") + .Call(git2r_repository_init, path, bare) + repository(path) +} + +##' Clone a remote repository +##' +##' @param url The remote repository to clone +##' @param local_path Local directory to clone to. +##' @param bare Create a bare repository. Default is FALSE. +##' @param branch The name of the branch to checkout. Default is NULL +##' which means to use the remote's default branch. +##' @param checkout Checkout HEAD after the clone is complete. Default +##' is TRUE. +##' @param credentials The credentials for remote repository +##' access. Default is NULL. To use and query an ssh-agent for the +##' ssh key credentials, let this parameter be NULL (the default). +##' @param progress Show progress. Default is TRUE. +##' @return A \code{git_repository} object. +##' @seealso \link{repository}, \code{\link{cred_user_pass}}, +##' \code{\link{cred_ssh_key}} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repository +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' repo_1 <- init(path_repo_1) +##' +##' ## Config user and commit a file +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "First commit message") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Second commit message") +##' +##' ## Change file again and commit. +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", +##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Third commit message") +##' +##' ## Clone to second repository +##' repo_2 <- clone(path_repo_1, path_repo_2) +##' +##' ## List commits in repositories +##' commits(repo_1) +##' commits(repo_2) +##' } +clone <- function(url = NULL, + local_path = NULL, + bare = FALSE, + branch = NULL, + checkout = TRUE, + credentials = NULL, + progress = TRUE) +{ + .Call(git2r_clone, url, local_path, bare, + branch, checkout, credentials, progress) + repository(local_path) +} + +##' Get HEAD for a repository +##' +##' @param x The repository \code{x} to check head +##' @param ... Additional arguments. Unused. +##' @return NULL if unborn branch or not found. A git_branch if not a +##' detached head. A git_commit if detached head +##' @importFrom utils head +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Commit message") +##' +##' ## Get HEAD of repository +##' head(repo) +##' } +head.git_repository <- function(x, ...) { + .Deprecated("repository_head") + .Call(git2r_repository_head, x) +} + +##' @export +utils::head + +##' Get HEAD for a repository +##' +##' @template repo-param +##' @return NULL if unborn branch or not found. A git_branch if not a +##' detached head. A git_commit if detached head +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Commit message") +##' +##' ## Get HEAD of repository +##' repository_head(repo) +##' } +repository_head <- function(repo = ".") { + .Call(git2r_repository_head, lookup_repository(repo)) +} + +##' Check if repository is bare +##' +##' @template repo-param +##' @return \code{TRUE} if bare repository, else \code{FALSE} +##' @seealso \link{init} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' is_bare(repo) +##' +##' ## Initialize a bare repository +##' path_bare <- tempfile(pattern="git2r-") +##' dir.create(path_bare) +##' repo_bare <- init(path_bare, bare = TRUE) +##' is_bare(repo_bare) +##' } +is_bare <- function(repo = ".") { + .Call(git2r_repository_is_bare, lookup_repository(repo)) +} + +##' Check if HEAD of repository is detached +##' +##' @template repo-param +##' @return \code{TRUE} if repository HEAD is detached, else +##' \code{FALSE}. +##' @export +##' @examples +##' \dontrun{ +##' ## Create and initialize a repository in a temporary directory +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "Commit message 1") +##' +##' ## Change file, add and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "Commit message 2") +##' +##' ## HEAD of repository is not detached +##' is_detached(repo) +##' +##' ## Checkout first commit +##' checkout(commit_1) +##' +##' ## HEAD of repository is detached +##' is_detached(repo) +##' } +is_detached <- function(repo = ".") { + .Call(git2r_repository_head_detached, lookup_repository(repo)) +} + +##' Check if repository is empty +##' +##' @template repo-param +##' @return \code{TRUE} if repository is empty else \code{FALSE}. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Check if it's an empty repository +##' is_empty(repo) +##' +##' ## Commit a file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Check if it's an empty repository +##' is_empty(repo) +##' } +is_empty <- function(repo = ".") { + .Call(git2r_repository_is_empty, lookup_repository(repo)) +} + +##' Determine if a directory is in a git repository +##' +##' The lookup start from path and walk across parent directories if +##' nothing has been found. +##' @param path The path to the directory. +##' @return TRUE if directory is in a git repository else FALSE +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Check if path is in a git repository +##' in_repository(path) +##' +##' ## Check if working directory is in a git repository +##' setwd(path) +##' in_repository() +##' } +in_repository <- function(path = ".") { + !is.null(discover_repository(path)) +} + +##' Determine if the repository is a shallow clone +##' +##' @template repo-param +##' @return \code{TRUE} if shallow clone, else \code{FALSE} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize repository +##' path_repo_1 <- tempfile(pattern="git2r-") +##' path_repo_2 <- tempfile(pattern="git2r-") +##' dir.create(path_repo_1) +##' dir.create(path_repo_2) +##' repo_1 <- init(path_repo_1) +##' +##' ## Config user and commit a file +##' config(repo_1, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Write to a file and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "First commit message") +##' +##' ## Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Second commit message") +##' +##' ## Change file again and commit. +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad", +##' "minim veniam, quis nostrud exercitation ullamco laboris nisi ut"), +##' file.path(path_repo_1, "example.txt")) +##' add(repo_1, "example.txt") +##' commit(repo_1, "Third commit message") +##' +##' ## Clone to second repository +##' repo_2 <- clone(path_repo_1, path_repo_2) +##' +##' ## Check if it's a shallow clone +##' is_shallow(repo_2) +##' } +is_shallow <- function(repo = ".") { + .Call(git2r_repository_is_shallow, lookup_repository(repo)) +} + +##' Lookup +##' +##' Lookup one object in a repository. +##' @template repo-param +##' @param sha The identity of the object to lookup. Must be 4 to 40 +##' characters long. +##' @return a \code{git_blob} or \code{git_commit} or \code{git_tag} +##' or \code{git_tree} object +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' +##' ## Create tag +##' tag(repo, "Tagname", "Tag message") +##' +##' ## First, get SHAs to lookup in the repository +##' sha_commit <- commit_1@@sha +##' sha_tree <- tree(commit_1)@@sha +##' sha_blob <- tree(commit_1)["example.txt"]$sha +##' sha_tag <- tags(repo)[[1]]@@sha +##' +##' ## SHAs +##' sha_commit +##' sha_tree +##' sha_blob +##' sha_tag +##' +##' ## Lookup objects +##' lookup(repo, sha_commit) +##' lookup(repo, sha_tree) +##' lookup(repo, sha_blob) +##' lookup(repo, sha_tag) +##' +##' ## Lookup objects, using only the first seven characters +##' lookup(repo, substr(sha_commit, 1, 7)) +##' lookup(repo, substr(sha_tree, 1, 7)) +##' lookup(repo, substr(sha_blob, 1, 7)) +##' lookup(repo, substr(sha_tag, 1, 7)) +##' } +lookup <- function(repo = ".", sha = NULL) { + .Call(git2r_object_lookup, lookup_repository(repo), sha) +} + +##' @export +print.git_repository <- function(x, ...) { + if (any(is_empty(x), is.null(repository_head(x)))) { + cat(sprintf("Local: %s\n", workdir(x))) + cat("Head: nothing commited (yet)\n") + } else { + if (is_detached(x)) { + cat(sprintf("Local: (detached) %s\n", workdir(x))) + + h <- repository_head(x) + } else { + cat(sprintf("Local: %s %s\n", + repository_head(x)$name, + workdir(x))) + + h <- repository_head(x) + u <- branch_get_upstream(h) + if (!is.null(u)) { + rn <- branch_remote_name(u) + cat(sprintf("Remote: %s @ %s (%s)\n", + substr(u$name, nchar(rn) + 2, nchar(u$name)), + rn, + branch_remote_url(u))) + } + + h <- lookup(x, branch_target(repository_head(x))) + } + + cat(sprintf("Head: [%s] %s: %s\n", + substring(h$sha, 1, 7), + substring(as.character(h$author$when), 1, 10), + h$summary)) + } +} + +##' Summary of repository +##' +##' @param object The repository \code{object} +##' @param ... Additional arguments affecting the summary produced. +##' @return None (invisible 'NULL'). +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' summary(repo) +##' +##' ## Add file +##' add(repo, "test.txt") +##' summary(repo) +##' +##' ## Commit +##' commit(repo, "First commit message") +##' summary(repo) +##' +##' ## Change the file +##' writeLines(c("Hello again!", "Here is a second line", "And a third"), +##' file.path(path, "test.txt")) +##' summary(repo) +##' +##' ## Add file and commit +##' add(repo, "test.txt") +##' commit(repo, "Second commit message") +##' summary(repo) +##'} +summary.git_repository <- function(object, ...) { + print(object) + cat("\n") + + n_branches <- sum(!is.na(unique(sapply(branches(object), + branch_target)))) + n_tags <- sum(!is.na(unique(vapply(tags(object), "[[", character(1), "sha")))) + + work <- commits(object) + n_commits <- length(work) + n_authors <- length(unique(vapply(lapply(work, "[[", "author"), + "[[", character(1), "name"))) + + s <- .Call(git2r_status_list, object, TRUE, TRUE, TRUE, FALSE, TRUE) + n_ignored <- length(s$ignored) + n_untracked <- length(s$untracked) + n_unstaged <- length(s$unstaged) + n_staged <- length(s$staged) + + n_stashes <- length(stash_list(object)) + + ## Determine max characters needed to display numbers + n <- max(vapply(c(n_branches, n_tags, n_commits, n_authors, + n_stashes, n_ignored, n_untracked, + n_unstaged, n_staged), + nchar, + numeric(1))) + + fmt <- paste0("Branches: %", n, "i\n", + "Tags: %", n, "i\n", + "Commits: %", n, "i\n", + "Contributors: %", n, "i\n", + "Stashes: %", n, "i\n", + "Ignored files: %", n, "i\n", + "Untracked files: %", n, "i\n", + "Unstaged files: %", n, "i\n", + "Staged files: %", n, "i\n") + cat(sprintf(fmt, n_branches, n_tags, n_commits, n_authors, + n_stashes, n_ignored, n_untracked, n_unstaged, + n_staged)) + + cat("\nLatest commits:\n") + lapply(commits(object, n = 5), print) + + invisible(NULL) +} + +## Strip trailing slash or backslash, unless it's the current drive +## root (/) or a Windows drive, for example, 'c:\'. +strip_trailing_slash <- function(path) { + if (!is.null(path) && grep("^(/|[a-zA-Z]:[/\\\\]?)$", path, invert = TRUE)) + path <- sub("/?$", "", path) + path +} + +##' Workdir of repository +##' +##' @template repo-param +##' @return Character vector with the path of the workdir. If the +##' repository is bare, \code{NULL} will be returned. +##' @export +##' @examples +##' \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' +##' ## Get the path of the workdir for repository +##' workdir(repo) +##' } +workdir <- function(repo = ".") { + path <- .Call(git2r_repository_workdir, lookup_repository(repo)) + strip_trailing_slash(path) +} + +##' Find path to repository for any file +##' +##' @param path A character vector specifying the path to a file or +##' folder +##' @param ceiling The defult is to not use the ceiling argument and +##' start the lookup from path and walk across parent +##' directories. When ceiling is 0, the lookup is only in +##' path. When ceiling is 1, the lookup is in both the path and +##' the parent to path. +##' @return Character vector with path (terminated by a file +##' separator) to repository or NULL if this cannot be +##' established. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' file.path(path, "example-1.txt")) +##' add(repo, "example-1.txt") +##' commit(repo, "First commit message") +##' +##' ## Create a second file. The file is not added for version control +##' ## in the repository. +##' dir.create(file.path(path, "example")) +##' file_2 <- file.path(path, "example/example-2.txt") +##' writeLines("Not under version control", file_2) +##' +##' ## Find the path to the repository using the path to the second file +##' discover_repository(file_2) +##' +##' ## Demonstrate the 'ceiling' argument +##' wd <- workdir(repo) +##' dir.create(file.path(wd, "temp")) +##' +##' ## Lookup repository in 'file.path(wd, "temp")'. Should return NULL +##' discover_repository(file.path(wd, "temp"), ceiling = 0) +##' +##' ## Lookup repository in parent to 'file.path(wd, "temp")'. +##' ## Should not return NULL +##' discover_repository(file.path(wd, "temp"), ceiling = 1) +##' } +discover_repository <- function(path = ".", ceiling = NULL) { + if (identical(path, ".")) + path <- getwd() + path <- normalizePath(path) + + if (!is.null(ceiling)) { + ceiling <- as.integer(ceiling) + if (identical(ceiling, 0L)) { + ceiling <- dirname(path) + } else if (identical(ceiling, 1L)) { + ceiling <- dirname(dirname(path)) + } else { + stop("'ceiling' must be either 0 or 1") + } + } + + path <- .Call(git2r_repository_discover, path, ceiling) + strip_trailing_slash(path) +} + +##' Internal utility function to lookup repository for methods +##' +##' @param repo repository \code{object} \code{git_repository}, or a +##' path to a repository, or \code{NULL}. If the \code{repo} +##' argument is \code{NULL}, the repository is searched for with +##' \code{\link{discover_repository}} in the current working +##' directory. +##' @return git_repository +##' @noRd +lookup_repository <- function(repo = NULL) { + if (is.null(repo) || identical(repo, ".")) { + ## Try current working directory + repo <- discover_repository(getwd()) + if (is.null(repo)) + stop("The working directory is not in a git repository") + } else if (inherits(repo, "git_repository")) { + return(repo) + } + + repository(repo) +} diff -Nru r-cran-git2r-0.21.0/R/reset.r r-cran-git2r-0.22.1/R/reset.r --- r-cran-git2r-0.21.0/R/reset.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/reset.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Reset current HEAD to the specified state -##' -##' @rdname reset-methods -##' @docType methods -##' @param object Either a \code{\linkS4class{git_commit}}, a -##' \code{\linkS4class{git_repository}} or a character vector. If -##' \code{object} is a \code{git_commit}, HEAD is moved to the -##' \code{git_commit}. If \code{object} is a -##' \code{git_repository}, resets the index entries in the -##' \code{path} argument to their state at HEAD. If \code{object} -##' is a character vector with paths, resets the index entries in -##' \code{object} to their state at HEAD if the current working -##' directory is in a repository. -##' @param ... Additional arguments affecting the reset. -##' @param reset_type If object is a 'git_commit', the kind of reset -##' operation to perform. 'soft' means the HEAD will be moved to -##' the commit. 'mixed' reset will trigger a 'soft' reset, plus -##' the index will be replaced with the content of the commit -##' tree. 'hard' reset will trigger a 'mixed' reset and the -##' working directory will be replaced with the content of the -##' index. -##' @param path If object is a 'git_repository', resets the index -##' entries for all paths to their state at HEAD. -##' @return invisible NULL -##' @keywords methods -##' @include S4_classes.r -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test-1.txt")) -##' add(repo, 'test-1.txt') -##' commit_1 <- commit(repo, "Commit message") -##' -##' ## Change and stage the file -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) -##' add(repo, 'test-1.txt') -##' status(repo) -##' -##' ## Unstage file -##' reset(repo, 'test-1.txt') -##' status(repo) -##' -##' ## Make one more commit -##' add(repo, 'test-1.txt') -##' commit(repo, "Next commit message") -##' -##' ## Create one more file -##' writeLines("Hello world!", file.path(path, "test-2.txt")) -##' -##' ## 'soft' reset to first commit and check status -##' reset(commit_1) -##' status(repo) -##' -##' ## 'mixed' reset to first commit and check status -##' commit(repo, "Next commit message") -##' reset(commit_1, "mixed") -##' status(repo) -##' -##' ## 'hard' reset to first commit and check status -##' add(repo, 'test-1.txt') -##' commit(repo, "Next commit message") -##' reset(commit_1, "hard") -##' status(repo) -##' } -setGeneric("reset", - signature = c("object"), - function(object, ...) - standardGeneric("reset")) - -##' @rdname reset-methods -##' @export -setMethod("reset", - signature(object = "git_commit"), - function(object, reset_type = c("soft", "mixed", "hard")) - { - reset_type <- switch(match.arg(reset_type), - soft = 1L, - mixed = 2L, - hard = 3L) - - invisible(.Call(git2r_reset, object, reset_type)) - } -) - -##' @rdname reset-methods -##' @export -setMethod("reset", - signature(object = "git_repository"), - function(object, path) - { - if (is_empty(object)) { - .Call(git2r_index_remove_bypath, object, path) - } else { - .Call(git2r_reset_default, object, path) - } - - invisible(NULL) - } -) - -##' @rdname reset-methods -##' @export -setMethod("reset", - signature(object = "character"), - function(object) - { - callGeneric(lookup_repository(), path = object) - } -) diff -Nru r-cran-git2r-0.21.0/R/reset.R r-cran-git2r-0.22.1/R/reset.R --- r-cran-git2r-0.21.0/R/reset.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/reset.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,101 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Reset current HEAD to the specified state +##' +##' @param object Either a \code{git_commit}, a \code{git_repository} +##' or a character vector. If \code{object} is a +##' \code{git_commit}, HEAD is moved to the \code{git_commit}. If +##' \code{object} is a \code{git_repository}, resets the index +##' entries in the \code{path} argument to their state at HEAD. If +##' \code{object} is a character vector with paths, resets the +##' index entries in \code{object} to their state at HEAD if the +##' current working directory is in a repository. +##' @param reset_type If object is a 'git_commit', the kind of reset +##' operation to perform. 'soft' means the HEAD will be moved to +##' the commit. 'mixed' reset will trigger a 'soft' reset, plus +##' the index will be replaced with the content of the commit +##' tree. 'hard' reset will trigger a 'mixed' reset and the +##' working directory will be replaced with the content of the +##' index. +##' @param path If object is a 'git_repository', resets the index +##' entries for all paths to their state at HEAD. +##' @return invisible NULL +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test-1.txt")) +##' add(repo, 'test-1.txt') +##' commit_1 <- commit(repo, "Commit message") +##' +##' ## Change and stage the file +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +##' add(repo, 'test-1.txt') +##' status(repo) +##' +##' ## Unstage file +##' reset(repo, 'test-1.txt') +##' status(repo) +##' +##' ## Make one more commit +##' add(repo, 'test-1.txt') +##' commit(repo, "Next commit message") +##' +##' ## Create one more file +##' writeLines("Hello world!", file.path(path, "test-2.txt")) +##' +##' ## 'soft' reset to first commit and check status +##' reset(commit_1) +##' status(repo) +##' +##' ## 'mixed' reset to first commit and check status +##' commit(repo, "Next commit message") +##' reset(commit_1, "mixed") +##' status(repo) +##' +##' ## 'hard' reset to first commit and check status +##' add(repo, 'test-1.txt') +##' commit(repo, "Next commit message") +##' reset(commit_1, "hard") +##' status(repo) +##' } +reset <- function(object, reset_type = c("soft", "mixed", "hard"), path = NULL) { + if (is_commit(object)) { + reset_type <- switch(match.arg(reset_type), + soft = 1L, + mixed = 2L, + hard = 3L) + + .Call(git2r_reset, object, reset_type) + } else { + object <- lookup_repository(object) + if (is_empty(object)) { + .Call(git2r_index_remove_bypath, object, path) + } else { + .Call(git2r_reset_default, object, path) + } + } + + invisible(NULL) +} diff -Nru r-cran-git2r-0.21.0/R/revparse.r r-cran-git2r-0.22.1/R/revparse.r --- r-cran-git2r-0.21.0/R/revparse.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/revparse.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Revparse -##' -##' Find object specified by revision. -##' @rdname revparse_single-methods -##' @docType methods -##' @param repo The repository -##' @param revision The revision string, see -##' http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions -##' @return a \code{git_commit} or \code{git_tag} or \code{git_tree} -##' object -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Create a directory in tempdir -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' -##' ## Initialize a repository -##' repo <- init(path) -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file, add and commit -##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "First commit message") -##' -##' # Change file and commit -##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", -##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), -##' con = file.path(path, "test.txt")) -##' add(repo, "test.txt") -##' commit(repo, "Second commit message") -##' -##' revparse_single(repo, "HEAD^") -##' } -setGeneric("revparse_single", - signature = c("repo", "revision"), - function(repo, revision) - standardGeneric("revparse_single") -) - -##' @rdname revparse_single-methods -##' @export -setMethod("revparse_single", - signature(repo = "git_repository", revision = "character"), - function(repo, revision) - { - .Call(git2r_revparse_single, repo, revision) - } -) diff -Nru r-cran-git2r-0.21.0/R/revparse.R r-cran-git2r-0.22.1/R/revparse.R --- r-cran-git2r-0.21.0/R/revparse.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/revparse.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,54 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Revparse +##' +##' Find object specified by revision. +##' @template repo-param +##' @param revision The revision string, see +##' http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions +##' @return a \code{git_commit} or \code{git_tag} or \code{git_tree} +##' object +##' @export +##' @examples +##' \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "First commit message") +##' +##' # Change file and commit +##' writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' "eiusmod tempor incididunt ut labore et dolore magna aliqua."), +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "Second commit message") +##' +##' revparse_single(repo, "HEAD^") +##' revparse_single(repo, "HEAD:test.txt") +##' } +revparse_single <- function(repo = ".", revision = NULL) { + .Call(git2r_revparse_single, lookup_repository(repo), revision) +} diff -Nru r-cran-git2r-0.21.0/R/S4_classes.r r-cran-git2r-0.22.1/R/S4_classes.r --- r-cran-git2r-0.21.0/R/S4_classes.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/S4_classes.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,842 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Class \code{"git_repository"} -##' -##' @title S4 class to handle a git repository -##' @section Slots: -##' \describe{ -##' \item{path}{ -##' Path to a git repository -##' } -##' } -##' @rdname git_repository-class -##' @keywords classes -##' @section Methods: -##' \describe{ -##' \item{is_bare}{\code{signature(object = "git_repository")}} -##' \item{is_empty}{\code{signature(object = "git_repository")}} -##' } -##' @keywords methods -##' @export -setClass("git_repository", - slots = c(path = "character"), - validity = function(object) { - errors <- character() - - can_open <- .Call(git2r_repository_can_open, object@path) - if (!isTRUE(can_open)) - errors <- c(errors, "Unable to open repository at 'path'") - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"git_time"} -##' -##' @title S4 class to handle a git time in a signature -##' @section Slots: -##' \describe{ -##' \item{time}{ -##' Time in seconds from epoch -##' } -##' \item{offset}{ -##' Timezone offset, in minutes -##' } -##' } -##' @name git_time-class -##' @aliases coerce,git_time,character-method -##' @aliases coerce,git_time,POSIXct-method -##' @aliases show,git_time-method -##' @keywords classes -##' @section Methods: -##' \describe{ -##' \item{show}{\code{signature(object = "git_time")}} -##' } -##' @keywords methods -##' @export -setClass("git_time", - slots = c(time = "numeric", - offset = "numeric"), - validity = function(object) - { - errors <- character() - - if (!identical(length(object@time), 1L)) - errors <- c(errors, "time must have length equal to one") - if (!identical(length(object@offset), 1L)) - errors <- c(errors, "offset must have length equal to one") - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"git_signature"} -##' -##' @title S4 class to handle a git signature -##' @section Slots: -##' \describe{ -##' \item{name}{ -##' The full name of the author. -##' } -##' \item{email}{ -##' Email of the author. -##' } -##' \item{when}{ -##' Time when the action happened. -##' } -##' } -##' @name git_signature-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_signature", - slots = c(name = "character", - email = "character", - when = "git_time"), - validity = function(object) - { - errors <- validObject(object@when) - - if (isTRUE(errors)) - errors <- character() - - if (!identical(length(object@name), 1L)) - errors <- c(errors, "name must have length equal to one") - if (!identical(length(object@email), 1L)) - errors <- c(errors, "email must have length equal to one") - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"cred_env"} -##' -##' @title S4 class to handle environmental variables credential -##' object -##' @section Slots: -##' \describe{ -##' \item{username}{ -##' The name of the environmental variable that holds -##' the username for the authentication. -##' } -##' \item{password}{ -##' The name of the environmental variable that holds -##' the password for the authentication. -##' } -##' } -##' @rdname cred_env-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("cred_env", - slots = c(username = "character", - password = "character") -) - -##' Class \code{"cred_token"} -##' -##' @title S4 class to handle a personal access token credential -##' object -##' @section Slots: -##' \describe{ -##' \item{token}{ -##' The name of the environmental variable that holds -##' the personal access token for the authentication. -##' } -##' } -##' @rdname cred_token-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("cred_token", - slots = c(token = "character") -) - -##' Class \code{"cred_user_pass"} -##' -##' @title S4 class to handle plain-text username and password -##' credential object -##' @section Slots: -##' \describe{ -##' \item{username}{ -##' The username of the credential -##' } -##' \item{password}{ -##' The password of the credential -##' } -##' } -##' @rdname cred_user_pass-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("cred_user_pass", - slots = c(username = "character", - password = "character") -) - -##' Class \code{"cred_ssh_key"} -##' -##' @title S4 class to handle a passphrase-protected ssh key -##' credential object -##' @section Slots: -##' \describe{ -##' \item{publickey}{ -##' The path to the public key of the credential -##' } -##' \item{privatekey}{ -##' The path to the private key of the credential -##' } -##' \item{passphrase}{ -##' The passphrase of the credential -##' } -##' } -##' @rdname cred_ssh_key-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("cred_ssh_key", - slots = c(publickey = "character", - privatekey = "character", - passphrase = "character") -) - -##' Class \code{"git_blame"} -##' -##' @title S4 class to handle a git blame for a single file -##' @section Slots: -##' \describe{ -##' \item{path}{ -##' The path to the file of the blame -##' } -##' \item{hunks}{ -##' List of blame hunks -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the file -##' } -##' } -##' @rdname git_blame-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_blame", - slots = c(path = "character", - hunks = "list", - repo = "git_repository"), - validity = function(object) { - errors <- character() - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"git_blame_hunk"} -##' -##' @title S4 class to represent a blame hunk -##' @section Slots: -##' \describe{ -##' \item{lines_in_hunk}{ -##' The number of lines in this hunk -##' } -##' \item{final_commit_id}{ -##' The sha of the commit where this line was last changed -##' } -##' \item{final_start_line_number}{ -##' The 1-based line number where this hunk begins, in the final -##' version of the file -##' } -##' \item{final_signature}{ -##' Final committer -##' } -##' \item{orig_commit_id}{ -##' The sha of the commit where this hunk was found. This will usually -##' be the same as 'final_commit_id'. -##' } -##' \item{orig_start_line_number}{ -##' The 1-based line number where this hunk begins in the file -##' named by 'orig_path' in the commit specified by 'orig_commit_id'. -##' } -##' \item{orig_signature}{ -##' Origin committer -##' } -##' \item{orig_path}{ -##' The path to the file where this hunk originated, as of the commit -##' specified by 'orig_commit_id' -##' } -##' \item{boundary}{ -##' TRUE iff the hunk has been tracked to a boundary commit. -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the blame hunk -##' } -##' } -##' @rdname git_blame_hunk-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_blame_hunk", - slots = c(lines_in_hunk = "integer", - final_commit_id = "character", - final_start_line_number = "integer", - final_signature = "git_signature", - orig_commit_id = "character", - orig_start_line_number = "integer", - orig_signature = "git_signature", - orig_path = "character", - boundary = "logical", - repo = "git_repository"), - validity = function(object) { - errors <- character() - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"git_blob"} -##' -##' @title S4 class to handle a git blob -##' @section Slots: -##' \describe{ -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the blob -##' } -##' } -##' @rdname git_blob-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_blob", - slots = c(sha = "character", - repo = "git_repository"), - validity = function(object) { - errors <- character() - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{git_branch} -##' -##' @title S4 class to handle a git branch -##' @section Slots: -##' \describe{ -##' \item{name}{ -##' Name of the branch. -##' } -##' \item{type}{ -##' Type of the branch, either 1 (local) or 2 (remote). -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the branch -##' } -##' } -##' @name git_branch-class -##' @keywords classes -##' @section Methods: -##' \describe{ -##' \item{is_head}{\code{signature(object = "git_branch")}} -##' \item{is_local}{\code{signature(object = "git_branch")}} -##' \item{show}{\code{signature(object = "git_branch")}} -##' } -##' @keywords methods -##' @export -setClass("git_branch", - slots = c(name = "character", - type = "integer", - repo = "git_repository")) - -##' Class \code{"git_commit"} -##' -##' @title S4 class to handle a git commit. -##' @section Slots: -##' \describe{ -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' \item{author}{ -##' An author signature -##' } -##' \item{committer}{ -##' The committer signature -##' } -##' \item{summary}{ -##' The short "summary" of a git commit message, comprising the first -##' paragraph of the message with whitespace trimmed and squashed. -##' } -##' \item{message}{ -##' The message of a commit -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the commit -##' } -##' } -##' @name git_commit-class -##' @keywords classes -##' @section Methods: -##' \describe{ -##' \item{show}{\code{signature(object = "git_commit")}} -##' } -##' @keywords methods -##' @export -setClass("git_commit", - slots = c(sha = "character", - author = "git_signature", - committer = "git_signature", - summary = "character", - message = "character", - repo = "git_repository"), - prototype = list(summary = NA_character_, - message = NA_character_)) - -##' Git diff -##' -##' @section Slots: -##' \describe{ -##' \item{old}{ -##' Represents the 'from' side of the diff. -##' } -##' \item{new}{ -##' Represents the 'to' side of the diff. -##' } -##' \item{files}{ -##' List of \code{\linkS4class{git_diff_file}} objects. -##' } -##' } -##' @name git_diff-class -##' @keywords classes -##' @export -setClass("git_diff", - slots = c(old = "ANY", - new = "ANY", - files = "list"), - prototype = list(old = NA_character_, - new = NA_character_)) - -##' Git diff file -##' -##' @section Slots: -##' \describe{ -##' \item{old_file}{ -##' Filename for old side of diff. -##' } -##' \item{new_file}{ -##' Filename for new side of diff. -##' } -##' \item{hunks}{ -##' List of \code{\linkS4class{git_diff_hunk}} objects. -##' } -##' } -##' @name git_diff_file-class -##' @keywords classes -##' @export -setClass("git_diff_file", - slots = c(old_file = "character", - new_file = "character", - hunks = "list")) - -##' Git diff hunk -##' -##' @section Slots: -##' \describe{ -##' \item{old_start}{ -##' Starting line number in old_file. -##' } -##' \item{old_lines}{ -##' Number of lines in old_file. -##' } -##' \item{new_start}{ -##' Starting line number in new_file. -##' } -##' \item{new_lines}{ -##' Number of lines in new_file. -##' } -##' \item{header}{ -##' Header text. -##' } -##' \item{lines}{ -##' List with \code{\linkS4class{git_diff_line}} objects. -##' } -##' } -##' @name git_diff_hunk-class -##' @keywords classes -##' @export -setClass("git_diff_hunk", - slots = c(old_start = "integer", - old_lines = "integer", - new_start = "integer", - new_lines = "integer", - header = "character", - lines = "list")) - -##' Git diff line -##' -##' @section Slots: -##' \describe{ -##' \item{origin}{ -##' Line origin constants. -##' } -##' \item{old_lineno}{ -##' Line number in old file or -1 for added line. -##' } -##' \item{new_lineno}{ -##' Line number in new file or -1 for deleted line. -##' } -##' \item{num_lines}{ -##' Number of newline characters in content. -##' } -##' \item{content}{ -##' The diff text. -##' } -##' } -##' @name git_diff_line-class -##' @keywords classes -##' @export -setClass("git_diff_line", - slots = c(origin = "integer", - old_lineno = "integer", - new_lineno = "integer", - num_lines = "integer", - content = "character")) - -##' Class \code{git_note} -##' -##' @title S4 class to handle a git note -##' @section Slots: -##' \describe{ -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 of the blob -##' containing the message -##' } -##' \item{annotated}{ -##' The 40 character hexadecimal string of the SHA-1 of the git -##' object being annotated -##' } -##' \item{message}{ -##' The note message -##' } -##' \item{refname}{ -##' Name of the reference -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the note -##' } -##' } -##' @name git_note-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_note", - slots = c(sha = "character", - annotated = "character", - message = "character", - refname = "character", - repo = "git_repository")) - -##' Class \code{"git_reference"} -##' -##' @title S4 class to handle a git reference -##' @section Slots: -##' \describe{ -##' \item{name}{ -##' The full name of the reference. -##' } -##' \item{type}{ -##' Type of the reference, either direct (GIT_REF_OID == 1) or -##' symbolic (GIT_REF_SYMBOLIC == 2) -##' } -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' \item{target}{ -##' The full name to the reference pointed to by a -##' symbolic reference. -##' } -##' \item{shorthand}{ -##' The reference's short name -##' } -##' } -##' @rdname git_reference-class -##' @keywords classes -##' @section Methods: -##' \describe{ -##' \item{show}{\code{signature(object = "git_reference")}} -##' } -##' @keywords methods -##' @export -setClass("git_reference", - slots = c(name = "character", - type = "integer", - sha = "character", - target = "character", - shorthand = "character"), - prototype = list(sha = NA_character_, - target = NA_character_)) - -##' Class \code{"git_reflog_entry"} -##' -##' @title S4 class to handle a git reflog entry. -##' @section Slots: -##' \describe{ -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' \item{message}{ -##' The log message of the entry -##' } -##' \item{index}{ -##' The index (zero-based) of the entry in the reflog -##' } -##' \item{committer}{ -##' The committer signature -##' } -##' \item{refname}{ -##' Name of the reference -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the reflog entry -##' } -##' } -##' @name git_reflog_entry-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_reflog_entry", - slots = c(sha = "character", - message = "character", - index = "integer", - committer = "git_signature", - refname = "character", - repo = "git_repository")) - -##' Class \code{"git_stash"} -##' -##' @title S4 class to handle a git stash -##' @name git_stash-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_stash", contains = "git_commit") - -##' Class \code{"git_tag"} -##' -##' @title S4 class to handle a git tag -##' @section Slots: -##' \describe{ -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' \item{message}{ -##' The message of the tag -##' } -##' \item{name}{ -##' The name of the tag -##' } -##' \item{tagger}{ -##' The tagger (author) of the tag -##' } -##' \item{target}{ -##' The target of the tag -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the tag -##' } -##' } -##' @name git_tag-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_tag", - slots = c(sha = "character", - message = "character", - name = "character", - tagger = "git_signature", - target = "character", - repo = "git_repository"), - validity = function(object) - { - errors <- validObject(object@tagger) - - if (isTRUE(errors)) - errors <- character() - - if (!identical(length(object@sha), 1L)) - errors <- c(errors, "sha must have length equal to one") - if (!identical(length(object@message), 1L)) - errors <- c(errors, "message must have length equal to one") - if (!identical(length(object@name), 1L)) - errors <- c(errors, "name must have length equal to one") - if (!identical(length(object@target), 1L)) - errors <- c(errors, "target must have length equal to one") - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"git_tree"} -##' -##' @title S4 class to handle a git tree -##' @section Slots: -##' \describe{ -##' \item{sha}{ -##' The 40 character hexadecimal string of the SHA-1 -##' } -##' \item{filemode}{ -##' The UNIX file attributes of a tree entry -##' } -##' \item{type}{ -##' String representation of the tree entry type -##' } -##' \item{id}{ -##' The sha id of a tree entry -##' } -##' \item{name}{ -##' The filename of a tree entry -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the commit -##' } -##' } -##' @name git_tree-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_tree", - slots = c(sha = "character", - filemode = "integer", - type = "character", - id = "character", - name = "character", - repo = "git_repository"), - validity = function(object) - { - errors <- character(0) - - if (!identical(length(object@sha), 1L)) - errors <- c(errors, "sha must have length equal to one") - - if (length(errors) == 0) TRUE else errors - } -) - -##' Class \code{"git_transfer_progress"} -##' -##' Statistics from the fetch operation. -##' @section Slots: -##' \describe{ -##' \item{total_objects}{ -##' Number of objects in the packfile being downloaded -##' } -##' \item{indexed_objects}{ -##' Received objects that have been hashed -##' } -##' \item{received_objects}{ -##' Objects which have been downloaded -##' } -##' \item{total_deltas}{ -##' Total number of deltas in the pack -##' } -##' \item{indexed_deltas}{ -##' Deltas which have been indexed -##' } -##' \item{local_objects}{ -##' Locally-available objects that have been injected in order to -##' fix a thin pack -##' } -##' \item{received_bytes}{ -##' Size of the packfile received up to now -##' } -##' } -##' @name git_transfer_progress-class -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_transfer_progress", - slots = c(total_objects = "integer", - indexed_objects = "integer", - received_objects = "integer", - local_objects = "integer", - total_deltas = "integer", - indexed_deltas = "integer", - received_bytes = "integer")) - -##' Class \code{"git_fetch_head"} -##' -##' @title S4 class to handle a fetch head -##' @section Slots: -##' \describe{ -##' \item{ref_name}{ -##' The name of the ref. -##' } -##' \item{remote_url}{ -##' The url of the remote. -##' } -##' \item{sha}{ -##' The SHA-1 of the remote head that were updated during the last -##' fetch. -##' } -##' \item{is_merge}{ -##' Is head for merge. -##' } -##' \item{repo}{ -##' The S4 class git_repository that contains the fetch head. -##' } -##' } -##' @rdname git_fetch_head -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_fetch_head", - slots = c(ref_name = "character", - remote_url = "character", - sha = "character", - is_merge = "logical", - repo = "git_repository") -) - -##' Class \code{"git_merge_result"} -##' -##' @title S4 class to handle the merge result -##' @section Slots: -##' \describe{ -##' \item{up_to_date}{ -##' TRUE if the merge is already up-to-date, else FALSE. -##' } -##' \item{fast_forward}{ -##' TRUE if a fast-forward merge, else FALSE. -##' } -##' \item{conflicts}{ -##' TRUE if the index contain entries representing file conflicts, -##' else FALSE. -##' } -##' \item{sha}{ -##' If the merge created a merge commit, the sha of the merge -##' commit. NA if no merge commit created. -##' } -##' } -##' @rdname git_merge_result -##' @keywords classes -##' @keywords methods -##' @export -setClass("git_merge_result", - slots = c(up_to_date = "logical", - fast_forward = "logical", - conflicts = "logical", - sha = "character") -) diff -Nru r-cran-git2r-0.21.0/R/sha.R r-cran-git2r-0.22.1/R/sha.R --- r-cran-git2r-0.21.0/R/sha.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/sha.R 2018-04-27 21:00:18.000000000 +0000 @@ -0,0 +1,103 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Get the SHA-1 of a git object +##' +##' Get the 40 character hexadecimal string of the SHA-1. +##' @param object a git object to get the SHA-1 from. +##' @return The 40 character hexadecimal string of the SHA-1. +##' @export +##' @examples \dontrun{ +##' ## Create a directory in tempdir +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' +##' ## Initialize a repository +##' repo <- init(path) +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file, add and commit +##' writeLines("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", +##' con = file.path(path, "test.txt")) +##' add(repo, "test.txt") +##' commit(repo, "Commit message 1") +##' +##' ## Get the SHA-1 of the last commit +##' sha(last_commit(repo)) +##' } +sha <- function(object) { + UseMethod("sha", object) +} + +##' @rdname sha +##' @export +sha.git_blob <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_branch <- function(object) { + branch_target(object) +} + +##' @rdname sha +##' @export +sha.git_commit <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_note <- function(object) { + object$sha +} + +##' @rdname sha-methods +##' @export +sha.git_reference <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_reflog_entry <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_tag <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_tree <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_fetch_head <- function(object) { + object$sha +} + +##' @rdname sha +##' @export +sha.git_merge_result <- function(object) { + object$sha +} diff -Nru r-cran-git2r-0.21.0/R/signature.r r-cran-git2r-0.22.1/R/signature.r --- r-cran-git2r-0.21.0/R/signature.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/signature.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Brief summary of signature -##' -##' @aliases show,git_signature-methods -##' @docType methods -##' @param object The repository \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Brief summary of default signature -##' default_signature(repo) -##' } -setMethod("show", - signature(object = "git_signature"), - function(object) - { - cat(sprintf(paste0("name: %s\n", - "email: %s\n", - "when: %s\n"), - object@name, - object@email, - as(object@when, "character"))) - } -) diff -Nru r-cran-git2r-0.21.0/R/signature.R r-cran-git2r-0.22.1/R/signature.R --- r-cran-git2r-0.21.0/R/signature.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/signature.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,66 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Get the signature +##' +##' Get the signature according to the repository's configuration +##' @template repo-param +##' @return A \code{git_signature} object with entries: +## \describe{ +## \item{name}{ +## The full name of the author. +## } +## \item{email}{ +## Email of the author. +## } +## \item{when}{ +## Time when the action happened. +## } +## } +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Get the default signature +##' default_signature(repo) +##' +##' ## Change user +##' config(repo, user.name="Bob", user.email="bob@@example.org") +##' +##' ## Get the default signature +##' default_signature(repo) +##' } +default_signature <- function(repo = ".") { + .Call(git2r_signature_default, lookup_repository(repo)) +} + +##' @export +format.git_signature <- function(x, ...) { + sprintf("name: %s\nemail: %s\nwhen: %s", + x$name, x$email, as.character(x$when)) +} + +##' @export +print.git_signature <- function(x, ...) { + cat(format(x, ...), "\n", sep = "") +} diff -Nru r-cran-git2r-0.21.0/R/stash.r r-cran-git2r-0.22.1/R/stash.r --- r-cran-git2r-0.21.0/R/stash.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/stash.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,338 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Drop stash -##' -##' @rdname stash_drop-methods -##' @docType methods -##' @param object The stash \code{object} to drop or a zero-based -##' integer to the stash to drop. The last stash has index 0. -##' @param ... Additional arguments affecting the stash_drop -##' @param index Zero based index to the stash to drop. Only used when -##' \code{object} is a \code{git_repository}. -##' @return invisible NULL -##' @keywords methods -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' # Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' add(repo, 'test.txt') -##' commit(repo, "Commit message") -##' -##' # Change file -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) -##' -##' # Create stash in repository -##' stash(repo) -##' -##' # Change file -##' writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) -##' -##' # Create stash in repository -##' stash(repo) -##' -##' # View stashes -##' stash_list(repo) -##' -##' # Drop git_stash object in repository -##' stash_drop(stash_list(repo)[[1]]) -##' -##' ## Drop stash using an index to stash -##' stash_drop(repo, 0) -##' -##' # View stashes -##' stash_list(repo) -##' } -setGeneric("stash_drop", - signature = "object", - function(object, ...) - standardGeneric("stash_drop")) - -##' @rdname stash_drop-methods -##' @include S4_classes.r -##' @export -setMethod("stash_drop", - signature(object = "git_repository"), - function(object, index) - { - if (missing(index)) - stop("missing argument 'index'") - if (abs(index - round(index)) >= .Machine$double.eps^0.5) - stop("'index' must be an integer") - index <- as.integer(index) - .Call(git2r_stash_drop, object, index) - invisible(NULL) - } -) - -##' @rdname stash_drop-methods -##' @export -setMethod("stash_drop", - signature(object = "git_stash"), - function(object) - { - ## Determine the index of the stash in the stash list - i <- match(object@sha, vapply(stash_list(object@repo), slot, character(1), "sha")) - - ## The stash list is zero-based - .Call(git2r_stash_drop, object@repo, i - 1L) - invisible(NULL) - } -) - -##' Stash -##' -##' @rdname stash-methods -##' @docType methods -##' @param object The repository \code{object}. -##' @param message Optional description. Defaults to current time. -##' @param index All changes already added to the index are left -##' intact in the working directory. Default is FALSE -##' @param untracked All untracked files are also stashed and then -##' cleaned up from the working directory. Default is FALSE -##' @param ignored All ignored files are also stashed and then cleaned -##' up from the working directory. Default is FALSE -##' @param stasher Signature with stasher and time of stash -##' @return invisible S4 class git_stash if anything to stash else NULL -##' @keywords methods -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' # Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' add(repo, 'test.txt') -##' commit(repo, "Commit message") -##' -##' # Change file -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) -##' -##' # Check status of repository -##' status(repo) -##' -##' # Create stash in repository -##' stash(repo) -##' -##' # Check status of repository -##' status(repo) -##' -##' # View stash -##' stash_list(repo) -##' } -setGeneric("stash", - signature = "object", - function(object, - message = as.character(Sys.time()), - index = FALSE, - untracked = FALSE, - ignored = FALSE, - stasher = default_signature(object)) - standardGeneric("stash")) - -##' @rdname stash-methods -##' @include S4_classes.r -##' @export -setMethod("stash", - signature(object = "git_repository"), - function(object, - message, - index, - untracked, - ignored, - stasher) - { - invisible(.Call(git2r_stash_save, - object, - message, - index, - untracked, - ignored, - stasher)) - } -) - -##' List stashes in repository -##' -##' @rdname stash_list-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return list of stashes in repository -##' @keywords methods -##' @include S4_classes.r -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' # Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test-1.txt")) -##' add(repo, 'test-1.txt') -##' commit(repo, "Commit message") -##' -##' # Make one more commit -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) -##' add(repo, 'test-1.txt') -##' commit(repo, "Next commit message") -##' -##' # Create one more file -##' writeLines("Hello world!", file.path(path, "test-2.txt")) -##' -##' # Check that there are no stashes -##' stash_list(repo) -##' -##' # Stash -##' stash(repo) -##' -##' # Only untracked changes, therefore no stashes -##' stash_list(repo) -##' -##' # Stash and include untracked changes -##' stash(repo, "Stash message", untracked=TRUE) -##' -##' # View stash -##' stash_list(repo) -##' } -setGeneric("stash_list", - signature = "repo", - function(repo) - standardGeneric("stash_list")) - -##' @rdname stash_list-methods -##' @export -setMethod("stash_list", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname stash_list-methods -##' @export -setMethod("stash_list", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_stash_list, repo) - } -) - -##' Brief summary of a stash -##' -##' @aliases show,git_stash-methods -##' @docType methods -##' @param object The stash \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' # Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' add(repo, 'test.txt') -##' commit(repo, "Commit message") -##' -##' # Change file -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) -##' -##' # Create stash in repository -##' stash(repo, "Stash message") -##' -##' # View brief summary of stash -##' stash_list(repo)[[1]] -##' } -setMethod("show", - signature(object = "git_stash"), - function(object) - { - cat(sprintf("%s\n", object@message)) - } -) - -##' Summary of a stash -##' -##' @aliases summary,git_stash-methods -##' @docType methods -##' @param object The stash \code{object} -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' # Configure a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' # Create a file, add and commit -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' add(repo, 'test.txt') -##' commit(repo, "Commit message") -##' -##' # Change file -##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) -##' -##' # Create stash in repository -##' stash(repo, "Stash message") -##' -##' # View summary of stash -##' summary(stash_list(repo)[[1]]) -##' } -setMethod("summary", - signature(object = "git_stash"), - function(object, ...) - { - cat(sprintf(paste0("message: %s\n", - "stasher: %s <%s>\n", - "when: %s\n", - "sha: %s\n\n"), - object@summary, - object@author@name, - object@author@email, - as(object@author@when, "character"), - object@sha)) - } -) diff -Nru r-cran-git2r-0.21.0/R/stash.R r-cran-git2r-0.22.1/R/stash.R --- r-cran-git2r-0.21.0/R/stash.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/stash.R 2018-07-01 21:27:25.000000000 +0000 @@ -0,0 +1,379 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Apply stash +##' +##' Apply a single stashed state from the stash list. +##' +##' If local changes in the working directory conflict with changes in +##' the stash then an error will be raised. In this case, the index +##' will always remain unmodified and all files in the working +##' directory will remain unmodified. However, if you are restoring +##' untracked files or ignored files and there is a conflict when +##' applying the modified files, then those files will remain in the +##' working directory. +##' @param object path to a repository, or a \code{git_repository} +##' object, or the stash \code{object} to pop. Default is a +##' \code{path = '.'} to a reposiory. +##' @param index The index to the stash to apply. Only used when +##' \code{object} is a path to a repository or a +##' \code{git_repository} object. Default is \code{index = 1}. +##' @return invisible NULL +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' # Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' add(repo, 'test.txt') +##' commit(repo, "Commit message") +##' +##' # Change file +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # Change file +##' writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # View stashes +##' stash_list(repo) +##' +##' # Read file +##' readLines(file.path(path, "test.txt")) +##' +##' # Apply latest git_stash object in repository +##' stash_apply(stash_list(repo)[[1]]) +##' +##' # Read file +##' readLines(file.path(path, "test.txt")) +##' +##' # View stashes +##' stash_list(repo) +##' } +stash_apply <- function(object = ".", index = 1) { + if (inherits(object, "git_stash")) { + ## Determine the index of the stash in the stash list + index <- match(object$sha, vapply(stash_list(object$repo), + "[[", character(1), "sha")) + object <- object$repo + } else { + object <- lookup_repository(object) + } + + ## The stash list is zero-based + if (abs(index - round(index)) >= .Machine$double.eps^0.5) + stop("'index' must be an integer") + index <- as.integer(index) - 1L + + invisible(.Call(git2r_stash_apply, object, index)) +} + +##' Drop stash +##' +##' @param object path to a repository, or a \code{git_repository} +##' object, or the stash \code{object} to drop. Default is a +##' \code{path = '.'} to a reposiory. +##' @param index The index to the stash to drop. Only used when +##' \code{object} is a path to a repository or a +##' \code{git_repository} object. Default is \code{index = 1}. +##' @return invisible NULL +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' # Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' add(repo, 'test.txt') +##' commit(repo, "Commit message") +##' +##' # Change file +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # Change file +##' writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # View stashes +##' stash_list(repo) +##' +##' # Drop git_stash object in repository +##' stash_drop(stash_list(repo)[[1]]) +##' +##' ## Drop stash using an index to stash +##' stash_drop(repo, 1) +##' +##' # View stashes +##' stash_list(repo) +##' } +stash_drop <- function(object = ".", index = 1) { + if (inherits(object, "git_stash")) { + ## Determine the index of the stash in the stash list + index <- match(object$sha, vapply(stash_list(object$repo), + "[[", character(1), "sha")) + object <- object$repo + } else { + object <- lookup_repository(object) + } + + ## The stash list is zero-based + if (abs(index - round(index)) >= .Machine$double.eps^0.5) + stop("'index' must be an integer") + index <- as.integer(index) - 1L + + invisible(.Call(git2r_stash_drop, object, index)) +} + +##' Stash +##' +##' @template repo-param +##' @param message Optional description. Defaults to current time. +##' @param index All changes already added to the index are left +##' intact in the working directory. Default is FALSE +##' @param untracked All untracked files are also stashed and then +##' cleaned up from the working directory. Default is FALSE +##' @param ignored All ignored files are also stashed and then cleaned +##' up from the working directory. Default is FALSE +##' @param stasher Signature with stasher and time of stash +##' @return invisible \code{git_stash} object if anything to stash +##' else NULL +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' # Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' add(repo, 'test.txt') +##' commit(repo, "Commit message") +##' +##' # Change file +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) +##' +##' # Check status of repository +##' status(repo) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # Check status of repository +##' status(repo) +##' +##' # View stash +##' stash_list(repo) +##' } +stash <- function(repo = ".", + message = as.character(Sys.time()), + index = FALSE, + untracked = FALSE, + ignored = FALSE, + stasher = NULL) +{ + repo <- lookup_repository(repo) + if (is.null(stasher)) + stasher <- default_signature(repo) + invisible(.Call(git2r_stash_save, repo, message, index, + untracked, ignored, stasher)) +} + +##' List stashes in repository +##' +##' @template repo-param +##' @return list of stashes in repository +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' # Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test-1.txt")) +##' add(repo, 'test-1.txt') +##' commit(repo, "Commit message") +##' +##' # Make one more commit +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +##' add(repo, 'test-1.txt') +##' commit(repo, "Next commit message") +##' +##' # Create one more file +##' writeLines("Hello world!", file.path(path, "test-2.txt")) +##' +##' # Check that there are no stashes +##' stash_list(repo) +##' +##' # Stash +##' stash(repo) +##' +##' # Only untracked changes, therefore no stashes +##' stash_list(repo) +##' +##' # Stash and include untracked changes +##' stash(repo, "Stash message", untracked=TRUE) +##' +##' # View stash +##' stash_list(repo) +##' } +stash_list <- function(repo = ".") { + .Call(git2r_stash_list, lookup_repository(repo)) +} + +##' Pop stash +##' +##' Apply a single stashed state from the stash list and remove it +##' from the list if successful. +##' @param object path to a repository, or a \code{git_repository} +##' object, or the stash \code{object} to pop. Default is a +##' \code{path = '.'} to a reposiory. +##' @param index The index to the stash to pop. Only used when +##' \code{object} is a path to a repository or a +##' \code{git_repository} object. Default is \code{index = 1}. +##' @return invisible NULL +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' # Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' add(repo, 'test.txt') +##' commit(repo, "Commit message") +##' +##' # Change file +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # Change file +##' writeLines(c("Hello world!", "HeLlO wOrLd!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo) +##' +##' # View stashes +##' stash_list(repo) +##' +##' # Read file +##' readLines(file.path(path, "test.txt")) +##' +##' # Pop latest git_stash object in repository +##' stash_pop(stash_list(repo)[[1]]) +##' +##' # Read file +##' readLines(file.path(path, "test.txt")) +##' +##' # View stashes +##' stash_list(repo) +##' } +stash_pop <- function(object = ".", index = 1) { + if (inherits(object, "git_stash")) { + ## Determine the index of the stash in the stash list + index <- match(object$sha, vapply(stash_list(object$repo), + "[[", character(1), "sha")) + object <- object$repo + } else { + object <- lookup_repository(object) + } + + ## The stash list is zero-based + if (abs(index - round(index)) >= .Machine$double.eps^0.5) + stop("'index' must be an integer") + index <- as.integer(index) - 1L + + invisible(.Call(git2r_stash_pop, object, index)) +} + +## @export +print.git_stash <- function(x, ...) { + cat(sprintf("%s\n", x$message)) +} + +##' Summary of a stash +##' +##' @param object The stash \code{object} +##' @param ... Additional arguments affecting the summary produced. +##' @return None (invisible 'NULL'). +##' @export +##' @examples \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' # Configure a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' # Create a file, add and commit +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' add(repo, 'test.txt') +##' commit(repo, "Commit message") +##' +##' # Change file +##' writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test.txt")) +##' +##' # Create stash in repository +##' stash(repo, "Stash message") +##' +##' # View summary of stash +##' summary(stash_list(repo)[[1]]) +##' } +summary.git_stash <- function(object, ...) { + cat(sprintf(paste0("message: %s\n", + "stasher: %s <%s>\n", + "when: %s\n", + "sha: %s\n\n"), + object$summary, + object$author$name, + object$author$email, + as.character(object$author$when), + object$sha)) +} diff -Nru r-cran-git2r-0.21.0/R/status.r r-cran-git2r-0.22.1/R/status.r --- r-cran-git2r-0.21.0/R/status.r 2017-12-20 16:05:37.000000000 +0000 +++ r-cran-git2r-0.22.1/R/status.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2017 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Status -##' -##' Display state of the repository working directory and the staging -##' area. -##' @rdname status-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}} to get status from. If the -##' \code{repo} argument is missing, the repository is searched -##' for with \code{\link{discover_repository}} in the current -##' working directory. -##' @param staged Include staged files. Default TRUE. -##' @param unstaged Include unstaged files. Default TRUE. -##' @param untracked Include untracked files and directories. Default -##' TRUE. -##' @param ignored Include ignored files. Default FALSE. -##' @param all_untracked Shows individual files in untracked -##' directories if \code{untracked} is \code{TRUE}. -##' @param ... Additional arguments to status. -##' @return S3 class \code{git_status} with repository status -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Config user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create a file -##' writeLines("Hello world!", file.path(path, "test.txt")) -##' -##' ## Check status; untracked file -##' status(repo) -##' -##' ## Add file -##' add(repo, "test.txt") -##' -##' ## Check status; staged file -##' status(repo) -##' -##' ## Commit -##' commit(repo, "First commit message") -##' -##' ## Check status; clean -##' status(repo) -##' -##' ## Change the file -##' writeLines(c("Hello again!", "Here is a second line", "And a third"), -##' file.path(path, "test.txt")) -##' -##' ## Check status; unstaged file -##' status(repo) -##' -##' ## Add file and commit -##' add(repo, "test.txt") -##' commit(repo, "Second commit message") -##' -##' ## Check status; clean -##' status(repo) -##'} -setGeneric("status", - signature = "repo", - function(repo, - staged = TRUE, - unstaged = TRUE, - untracked = TRUE, - ignored = FALSE, - all_untracked = FALSE, - ...) - standardGeneric("status")) - -##' @rdname status-methods -##' @export -setMethod("status", - signature(repo = "missing"), - function(staged, unstaged, untracked, ignored, all_untracked, ...) - { - callGeneric(repo = lookup_repository(), - staged = staged, - unstaged = unstaged, - untracked = untracked, - ignored = ignored, - all_untracked = all_untracked, - ...) - } -) - -##' @rdname status-methods -##' @export -setMethod("status", - signature(repo = "git_repository"), - function(repo, staged, unstaged, untracked, ignored, all_untracked, ...) - { - structure(.Call(git2r_status_list, repo, staged, - unstaged, untracked, all_untracked, - ignored), - class = "git_status") - } -) - -##' @export -print.git_status <- function(x, ...) -{ - display_status <- function(title, section) { - cat(sprintf("%s:\n", title)) - - for(i in seq_len(length(section))) { - label <- names(section)[i] - label <- paste0(toupper(substr(label, 1, 1)), - substr(label, 2, nchar(label))) - cat(sprintf("\t%-12s%s\n", paste0(label, ":"), section[[i]])) - } - - invisible(NULL) - } - - if (max(sapply(x, length)) == 0L) - cat("working directory clean\n") - - if (length(x$ignored)) { - display_status("Ignored files", x$ignored) - cat("\n") - } - - if (length(x$untracked)) { - display_status("Untracked files", x$untracked) - cat("\n") - } - - if (length(x$unstaged)) { - display_status("Unstaged changes", x$unstaged) - cat("\n") - } - - if (length(x$staged)) { - display_status("Staged changes", x$staged) - cat("\n") - } - - invisible(NULL) -} diff -Nru r-cran-git2r-0.21.0/R/status.R r-cran-git2r-0.22.1/R/status.R --- r-cran-git2r-0.21.0/R/status.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/status.R 2018-05-25 17:10:53.000000000 +0000 @@ -0,0 +1,125 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Status +##' +##' Display state of the repository working directory and the staging +##' area. +##' @template repo-param +##' @param staged Include staged files. Default TRUE. +##' @param unstaged Include unstaged files. Default TRUE. +##' @param untracked Include untracked files and directories. Default +##' TRUE. +##' @param ignored Include ignored files. Default FALSE. +##' @param all_untracked Shows individual files in untracked +##' directories if \code{untracked} is \code{TRUE}. +##' @return \code{git_status} with repository status +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Config user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create a file +##' writeLines("Hello world!", file.path(path, "test.txt")) +##' +##' ## Check status; untracked file +##' status(repo) +##' +##' ## Add file +##' add(repo, "test.txt") +##' +##' ## Check status; staged file +##' status(repo) +##' +##' ## Commit +##' commit(repo, "First commit message") +##' +##' ## Check status; clean +##' status(repo) +##' +##' ## Change the file +##' writeLines(c("Hello again!", "Here is a second line", "And a third"), +##' file.path(path, "test.txt")) +##' +##' ## Check status; unstaged file +##' status(repo) +##' +##' ## Add file and commit +##' add(repo, "test.txt") +##' commit(repo, "Second commit message") +##' +##' ## Check status; clean +##' status(repo) +##'} +status <- function(repo = ".", + staged = TRUE, + unstaged = TRUE, + untracked = TRUE, + ignored = FALSE, + all_untracked = FALSE) +{ + structure(.Call(git2r_status_list, lookup_repository(repo), staged, + unstaged, untracked, all_untracked, ignored), + class = "git_status") +} + +##' @export +print.git_status <- function(x, ...) +{ + display_status <- function(title, section) { + cat(sprintf("%s:\n", title)) + + for(i in seq_len(length(section))) { + label <- names(section)[i] + label <- paste0(toupper(substr(label, 1, 1)), + substr(label, 2, nchar(label))) + cat(sprintf("\t%-12s%s\n", paste0(label, ":"), section[[i]])) + } + + invisible(NULL) + } + + if (max(sapply(x, length)) == 0L) + cat("working directory clean\n") + + if (length(x$ignored)) { + display_status("Ignored files", x$ignored) + cat("\n") + } + + if (length(x$untracked)) { + display_status("Untracked files", x$untracked) + cat("\n") + } + + if (length(x$unstaged)) { + display_status("Unstaged changes", x$unstaged) + cat("\n") + } + + if (length(x$staged)) { + display_status("Staged changes", x$staged) + cat("\n") + } + + invisible(NULL) +} diff -Nru r-cran-git2r-0.21.0/R/tag.r r-cran-git2r-0.22.1/R/tag.r --- r-cran-git2r-0.21.0/R/tag.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/tag.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,308 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Create tag targeting HEAD commit in repository -##' -##' @rdname tag-methods -##' @docType methods -##' @param object The repository \code{object}. -##' @param name Name for the tag. -##' @param message The tag message. -##' @param session Add sessionInfo to tag message. Default is FALSE. -##' @param tagger The tagger (author) of the tag -##' @return invisible(\code{git_tag}) object -##' @keywords methods -##' @include commit.r -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' ## List tags -##' tags(repo) -##' } -setGeneric("tag", - signature = "object", - function(object, - name, - message, - session = FALSE, - tagger = default_signature(object)) - standardGeneric("tag")) - -##' @rdname tag-methods -##' @export -setMethod("tag", - signature(object = "git_repository"), - function(object, - name, - message, - session, - tagger) - { - ## Argument checking - stopifnot(is.character(name), - identical(length(name), 1L), - nchar(name[1]) > 0, - is.character(message), - identical(length(message), 1L), - nchar(message[1]) > 0, - is.logical(session), - identical(length(session), 1L), - is(tagger, "git_signature")) - - if (session) - message <- add_session_info(message) - - invisible(.Call(git2r_tag_create, object, name, message, tagger)) - } -) - -##' Delete an existing tag reference -##' -##' @rdname tag_delete-methods -##' @docType methods -##' @param object Can be either a -##' (\code{\linkS4class{git_repository}}) object, a -##' \code{\linkS4class{git_tag}} object or the tag name. If the -##' \code{object} argument is the tag name, the repository is -##' searched for with \code{\link{discover_repository}} in the -##' current working directory. -##' @param ... Additional arguments -##' @param name If the \code{object} argument is a -##' \code{git_repository}, the name of the tag to delete. -##' @return \code{invisible(NULL)} -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create two tags -##' tag(repo, "Tag1", "Tag message 1") -##' t2 <- tag(repo, "Tag2", "Tag message 2") -##' -##' ## List the two tags in the repository -##' tags(repo) -##' -##' ## Delete the two tags in the repository -##' tag_delete(repo, "Tag1") -##' tag_delete(t2) -##' -##' ## Show the empty list with tags in the repository -##' tags(repo) -##' } -setGeneric("tag_delete", - signature = "object", - function(object, ...) - standardGeneric("tag_delete")) - -##' @rdname tag_delete-methods -##' @export -setMethod("tag_delete", - signature(object = "git_repository"), - function(object, name) - { - invisible(.Call(git2r_tag_delete, object, name)) - } -) - -##' @rdname tag_delete-methods -##' @export -setMethod("tag_delete", - signature(object = "character"), - function(object) - { - callGeneric(object = lookup_repository(), name = object) - } -) - -##' @rdname tag_delete-methods -##' @export -setMethod("tag_delete", - signature(object = "git_tag"), - function(object) - { - callGeneric(object = object@repo, name = object@name) - } -) - -##' Tags -##' -##' @rdname tags-methods -##' @docType methods -##' @param repo The repository \code{object} -##' \code{\linkS4class{git_repository}}. If the \code{repo} argument -##' is missing, the repository is searched for with -##' \code{\link{discover_repository}} in the current working -##' directory. -##' @return list of tags in repository -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' ## List tags -##' tags(repo) -##' } -setGeneric("tags", - signature = "repo", - function(repo) - standardGeneric("tags")) - -##' @rdname tags-methods -##' @export -setMethod("tags", - signature(repo = "missing"), - function() - { - callGeneric(repo = lookup_repository()) - } -) - -##' @rdname tags-methods -##' @export -setMethod("tags", - signature(repo = "git_repository"), - function(repo) - { - .Call(git2r_tag_list, repo) - } -) - -##' Brief summary of a tag -##' -##' @aliases show,git_tag-methods -##' @docType methods -##' @param object The tag \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' ## View brief summary of tag -##' tags(repo)[[1]] -##' } -setMethod("show", - signature(object = "git_tag"), - function(object) - { - cat(sprintf("[%s] %s\n", - substr(object@target, 1 , 6), - object@name)) - } -) - -##' Summary of a tag -##' -##' @aliases summary,git_tag-methods -##' @docType methods -##' @param object The tag \code{object} -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Commit a text file -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' ## Summary of tag -##' summary(tags(repo)[[1]]) -##' } -setMethod("summary", - signature(object = "git_tag"), - function(object, ...) - { - cat(sprintf(paste0("name: %s\n", - "target: %s\n", - "tagger: %s <%s>\n", - "when: %s\n", - "message: %s\n"), - object@name, - object@target, - object@tagger@name, - object@tagger@email, - as(object@tagger@when, "character"), - object@message)) - } -) diff -Nru r-cran-git2r-0.21.0/R/tag.R r-cran-git2r-0.22.1/R/tag.R --- r-cran-git2r-0.21.0/R/tag.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/tag.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,175 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Create tag targeting HEAD commit in repository +##' +##' @param object The repository \code{object}. +##' @param name Name for the tag. +##' @param message The tag message. +##' @param session Add sessionInfo to tag message. Default is FALSE. +##' @param tagger The tagger (author) of the tag +##' @return invisible(\code{git_tag}) object +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Create tag +##' tag(repo, "Tagname", "Tag message") +##' +##' ## List tags +##' tags(repo) +##' } +tag <- function(object = ".", + name = NULL, + message = NULL, + session = FALSE, + tagger = NULL) +{ + object <- lookup_repository(object) + + stopifnot(is.character(message), + identical(length(message), 1L), + nchar(message[1]) > 0) + if (isTRUE(session)) + message <- add_session_info(message) + + if (is.null(tagger)) + tagger <- default_signature(object) + + invisible(.Call(git2r_tag_create, object, name, message, tagger)) +} + +is_tag <- function(object) { + inherits(object, "git_tag") +} + +##' Delete an existing tag reference +##' +##' @param object Can be either the path (default is ".") to a +##' repository, or a \code{git_repository} object, or a +##' \code{git_tag} object. or the tag name. +##' @param name If the \code{object} argument is a path to a +##' repository or a \code{git_repository}, the name of the tag to +##' delete. +##' @return \code{invisible(NULL)} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Create two tags +##' tag(repo, "Tag1", "Tag message 1") +##' t2 <- tag(repo, "Tag2", "Tag message 2") +##' +##' ## List the two tags in the repository +##' tags(repo) +##' +##' ## Delete the two tags in the repository +##' tag_delete(repo, "Tag1") +##' tag_delete(t2) +##' +##' ## Show the empty list with tags in the repository +##' tags(repo) +##' } +tag_delete <- function(object = ".", name = NULL) { + if (is_tag(object)) { + name <- object$name + object <- object$repo + } else { + object <- lookup_repository(object) + } + + .Call(git2r_tag_delete, object, name) + invisible(NULL) +} + +##' Tags +##' +##' @template repo-param +##' @return list of tags in repository +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Create tag +##' tag(repo, "Tagname", "Tag message") +##' +##' ## List tags +##' tags(repo) +##' } +tags <- function(repo = ".") { + .Call(git2r_tag_list, lookup_repository(repo)) +} + +##' @export +format.git_tag <- function(x, ...) { + sprintf("[%s] %s", substr(x$target, 1 , 6), x$name) +} + +##' @export +print.git_tag <- function(x, ...) { + cat(format(x, ...), "\n", sep = "") +} + +##' @export +summary.git_tag <- function(object, ...) { + cat(sprintf(paste0("name: %s\n", + "target: %s\n", + "tagger: %s <%s>\n", + "when: %s\n", + "message: %s\n"), + object$name, + object$target, + object$tagger$name, + object$tagger$email, + as.character(object$tagger$when), + object$message)) +} diff -Nru r-cran-git2r-0.21.0/R/time.r r-cran-git2r-0.22.1/R/time.r --- r-cran-git2r-0.21.0/R/time.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/time.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -setAs(from="git_time", - to="character", - def=function(from) - { - as.character(as(from, "POSIXct")) - } -) - -setAs(from="git_time", - to="POSIXct", - def=function(from) - { - as.POSIXct(from@time + from@offset*60, - origin="1970-01-01", - tz="GMT") - } -) - -setAs(from = "POSIXlt", - to = "git_time", - def=function(from) - { - if (is.null(from$gmtoff) || is.na(from$gmtoff)) { - offset <- 0 - } else { - offset <- from$gmtoff / 60 - } - - new("git_time", - time = as.numeric(from), - offset = offset) - } -) - -##' Brief summary of \code{git_time} -##' -##' @aliases show,git_time-methods -##' @docType methods -##' @param object The time \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Brief summary of git_time from the default signature -##' default_signature(repo)@@when -##' } -setMethod("show", - signature(object = "git_time"), - function(object) - { - cat(sprintf("%s\n", as(object, "character"))) - } -) diff -Nru r-cran-git2r-0.21.0/R/time.R r-cran-git2r-0.22.1/R/time.R --- r-cran-git2r-0.21.0/R/time.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/time.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,45 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' @export +as.character.git_time <- function(x, ...) { + as.character(as.POSIXct(x)) +} + +##' @export +as.POSIXct.git_time <- function(x, ...) { + as.POSIXct(x$time + x$offset*60, origin = "1970-01-01", tz = "GMT") +} + +## setAs(from = "POSIXlt", +## to = "git_time", +## def=function(from) +## { +## if (is.null(from$gmtoff) || is.na(from$gmtoff)) { +## offset <- 0 +## } else { +## offset <- from$gmtoff / 60 +## } + +## structure(list(time = as.numeric(from), offset = offset), +## class = "git_time") +## } +## ) + +##' @export +print.git_time <- function(x, ...) { + cat(sprintf("%s\n", as.character(x))) +} diff -Nru r-cran-git2r-0.21.0/R/tree.r r-cran-git2r-0.22.1/R/tree.r --- r-cran-git2r-0.21.0/R/tree.r 2017-11-21 18:36:54.000000000 +0000 +++ r-cran-git2r-0.22.1/R/tree.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,341 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' Coerce entries in a git_tree to a \code{data.frame} -##' -##' The entries in a tree are coerced to a \code{data.frame} -##' -##' -##' The \code{data.frame} have the following columns: -##' \describe{ -##' -##' \item{filemode}{ -##' The UNIX file attributes of a tree entry -##' } -##' -##' \item{type}{ -##' String representation of the tree entry type -##' } -##' -##' \item{sha}{ -##' The sha of a tree entry -##' } -##' -##' \item{name}{ -##' The filename of a tree entry -##' } -##' -##' } -##' @name coerce-git_tree-data.frame-method -##' @aliases coerce,git_tree,data.frame-method -##' @docType methods -##' @param from The tree \code{object} -##' @return \code{data.frame} -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' dir.create(file.path(path, "subfolder")) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create three files and commit -##' writeLines("First file", file.path(path, "example-1.txt")) -##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) -##' writeLines("Third file", file.path(path, "example-3.txt")) -##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) -##' new_commit <- commit(repo, "Commit message") -##' -##' ## Coerce tree to a data.frame -##' df <- as(tree(new_commit), "data.frame") -##' df -##' } -setAs(from = "git_tree", - to = "data.frame", - def = function(from) - { - data.frame(mode = sprintf("%06o", from@filemode), - type = from@type, - sha = from@id, - name = from@name, - stringsAsFactors = FALSE) - } -) - -##' Coerce entries in a git_tree to a list of entry objects -##' -##' @name coerce-git_tree-list-method -##' @docType methods -##' @param from The tree \code{object} -##' @return list of entry objects -##' @keywords methods -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' dir.create(file.path(path, "subfolder")) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create three files and commit -##' writeLines("First file", file.path(path, "example-1.txt")) -##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) -##' writeLines("Third file", file.path(path, "example-3.txt")) -##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) -##' new_commit <- commit(repo, "Commit message") -##' -##' ## Inspect size of each blob in tree -##' invisible(lapply(as(tree(new_commit), "list"), -##' function(obj) { -##' if (is_blob(obj)) -##' summary(obj) -##' NULL -##' })) -##' } -setAs(from = "git_tree", - to = "list", - def = function(from) - { - lapply(from@id, function(sha) lookup(from@repo, sha)) - } -) - -##' Tree -##' -##' Get the tree pointed to by a commit or stash. -##' @rdname tree-methods -##' @docType methods -##' @param object the \code{commit} or \code{stash} object -##' @return A S4 class git_tree object -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a first user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' tree(commits(repo)[[1]]) -##' summary(tree(commits(repo)[[1]])) -##' } -setGeneric("tree", - signature = "object", - function(object) standardGeneric("tree")) - -##' @rdname tree-methods -##' @export -setMethod("tree", - signature(object = "git_commit"), - function(object) - { - .Call(git2r_commit_tree, object) - } -) - -##' @rdname tree-methods -##' @export -setMethod("tree", - signature(object = "git_stash"), - function(object) - { - .Call(git2r_commit_tree, object) - } -) - -##' Brief summary of tree -##' -##' @aliases show,git_tree-methods -##' @docType methods -##' @param object The tree \code{object} -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Brief summary of the tree in the repository -##' tree(commits(repo)[[1]]) -##' } -setMethod("show", - signature(object = "git_tree"), - function(object) - { - cat(sprintf("tree: %s\n", object@sha)) - } -) - -##' Summary of tree -##' -##' @aliases summary,git_tree-methods -##' @docType methods -##' @param object The tree \code{object} -##' @param ... Additional arguments affecting the summary produced. -##' @return None (invisible 'NULL'). -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' summary(tree(commits(repo)[[1]])) -##' } -setMethod("summary", - signature(object = "git_tree"), - function(object, ...) - { - show(as(object, "data.frame")) - } -) - -##' Extract object from tree -##' -##' Lookup a tree entry by its position in the tree -##' @rdname tree-index-methods -##' @docType methods -##' @param x The tree \code{object} -##' @param i The index (integer or logical) of the tree object to -##' extract. If negative values, all elements except those indicated -##' are selected. A character vector to match against the names of -##' objects to extract. -##' @return Git object -##' @keywords methods -##' @export -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' dir.create(file.path(path, "subfolder")) -##' repo <- init(path) -##' -##' ## Create a user -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' -##' ## Create three files and commit -##' writeLines("First file", file.path(path, "example-1.txt")) -##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) -##' writeLines("Third file", file.path(path, "example-3.txt")) -##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) -##' new_commit <- commit(repo, "Commit message") -##' -##' ## Pick a tree in the repository -##' tree_object <- tree(new_commit) -##' -##' ## Summarize tree -##' summary(tree_object) -##' -##' ## Select item by name -##' tree_object["example-1.txt"] -##' -##' ## Select first item in tree -##' tree_object[1] -##' -##' ## Select first three items in tree -##' tree_object[1:3] -##' -##' ## Select all blobs in tree -##' tree_object[vapply(as(tree_object, 'list'), is_blob, logical(1))] -##' } -setMethod("[", - signature(x = "git_tree", i = "integer", j = "missing"), - function(x, i) - { - i <- seq_len(length(x))[i] - ret <- lapply(i, function(j) lookup(x@repo, x@id[j])) - if (identical(length(ret), 1L)) - ret <- ret[[1]] - ret - } -) - -##' @rdname tree-index-methods -##' @export -setMethod("[", - signature(x = "git_tree", i = "numeric", j = "missing"), - function(x, i) - { - x[as.integer(i)] - } -) - -##' @rdname tree-index-methods -##' @export -setMethod("[", - signature(x = "git_tree", i = "logical", j = "missing"), - function(x, i) - { - x[seq_along(x)[i]] - } -) - -##' @rdname tree-index-methods -##' @export -setMethod("[", - signature(x = "git_tree", i = "character", j = "missing"), - function(x, i) - { - x[which(x@name %in% i)] - } -) - -##' Number of entries in tree -##' -##' @docType methods -##' @param x The tree \code{object} -##' @return a non-negative integer or double (which will be rounded -##' down) -##' @keywords methods -##' @export -setMethod("length", - signature(x = "git_tree"), - function(x) - { - length(x@id) - } -) diff -Nru r-cran-git2r-0.21.0/R/tree.R r-cran-git2r-0.22.1/R/tree.R --- r-cran-git2r-0.21.0/R/tree.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/tree.R 2018-07-01 20:59:27.000000000 +0000 @@ -0,0 +1,337 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' Coerce entries in a git_tree to a \code{data.frame} +##' +##' The entries in a tree are coerced to a \code{data.frame} +##' +##' +##' The \code{data.frame} have the following columns: +##' \describe{ +##' +##' \item{filemode}{ +##' The UNIX file attributes of a tree entry +##' } +##' +##' \item{type}{ +##' String representation of the tree entry type +##' } +##' +##' \item{sha}{ +##' The sha of a tree entry +##' } +##' +##' \item{name}{ +##' The filename of a tree entry +##' } +##' +##' } +##' @param x The tree \code{object} +##' @param ... Additional arguments. Not used. +##' @return \code{data.frame} +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' dir.create(file.path(path, "subfolder")) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create three files and commit +##' writeLines("First file", file.path(path, "example-1.txt")) +##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +##' writeLines("Third file", file.path(path, "example-3.txt")) +##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +##' commit(repo, "Commit message") +##' +##' ## Display tree +##' tree(last_commit(repo)) +##' +##' ## Coerce tree to a data.frame +##' df <- as(tree(last_commit(repo)), "data.frame") +##' df +##' } +as.data.frame.git_tree <- function(x, ...) { + data.frame(mode = sprintf("%06o", x$filemode), + type = x$type, + sha = x$id, + name = x$name, + stringsAsFactors = FALSE) +} + +##' @export +base::as.data.frame + +##' Coerce entries in a git_tree to a list of entry objects +##' +##' @param x The tree \code{object} +##' @param ... Unused +##' @return list of entry objects +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' dir.create(file.path(path, "subfolder")) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create three files and commit +##' writeLines("First file", file.path(path, "example-1.txt")) +##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +##' writeLines("Third file", file.path(path, "example-3.txt")) +##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +##' commit(repo, "Commit message") +##' +##' ## Inspect size of each blob in tree +##' invisible(lapply(as(tree(last_commit(repo)), "list"), +##' function(obj) { +##' if (is_blob(obj)) +##' summary(obj) +##' NULL +##' })) +##' } +as.list.git_tree <- function(x, ...) { + lapply(x$id, function(sha) lookup(x$repo, sha)) +} + +##' Tree +##' +##' Get the tree pointed to by a commit or stash. +##' @param object the \code{commit} or \code{stash} object +##' @return A S3 class git_tree object +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a first user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' tree(last_commit(repo)) +##' } +tree <- function(object = NULL) { + .Call(git2r_commit_tree, object) +} + +##' @export +print.git_tree <- function(x, ...) { + cat(sprintf("tree: %s\n\n", x$sha)) + print(as.data.frame(x)) +} + +##' Summary of tree +##' +##' @param object The tree \code{object} +##' @param ... Additional arguments affecting the summary produced. +##' @return None (invisible 'NULL'). +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' summary(tree(last_commit(repo))) +##' } +summary.git_tree <- function(object, ...) { + print(as.data.frame(object)) +} + +##' Extract object from tree +##' +##' Lookup a tree entry by its position in the tree +##' @param x The tree \code{object} +##' @param i The index (integer or logical) of the tree object to +##' extract. If negative values, all elements except those indicated +##' are selected. A character vector to match against the names of +##' objects to extract. +##' @return Git object +##' @export +##' @examples +##' \dontrun{ +##' ##' Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' dir.create(file.path(path, "subfolder")) +##' repo <- init(path) +##' +##' ##' Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ##' Create three files and commit +##' writeLines("First file", file.path(path, "example-1.txt")) +##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +##' writeLines("Third file", file.path(path, "example-3.txt")) +##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +##' new_commit <- commit(repo, "Commit message") +##' +##' ##' Pick a tree in the repository +##' tree_object <- tree(new_commit) +##' +##' ##' Display tree +##' tree_object +##' +##' ##' Select item by name +##' tree_object["example-1.txt"] +##' +##' ##' Select first item in tree +##' tree_object[1] +##' +##' ##' Select first three items in tree +##' tree_object[1:3] +##' +##' ##' Select all blobs in tree +##' tree_object[vapply(as(tree_object, 'list'), is_blob, logical(1))] +##' } +"[.git_tree" <- function(x, i) { + if (is.logical(i)) + return(x[seq_along(x)[i]]) + + if (is.character(i)) + return(x[which(x$name %in% i)]) + + if (!is.numeric(i)) + stop("Invalid index") + + i <- seq_len(length(x))[as.integer(i)] + ret <- lapply(i, function(j) lookup(x$repo, x$id[j])) + if (identical(length(ret), 1L)) + ret <- ret[[1]] + ret +} + +##' Number of entries in tree +##' +##' @param x The tree \code{object} +##' @return a non-negative integer or double (which will be rounded +##' down) +##' @export +length.git_tree <- function(x) { + length(x$id) +} + +##' Check if object is S3 class git_tree +##' +##' @param object Check if object is S3 class git_tree +##' @return TRUE if object is S3 class git_tree, else FALSE +##' @keywords methods +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Commit a text file +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit_1 <- commit(repo, "First commit message") +##' tree_1 <- tree(commit_1) +##' +##' ## Check if tree +##' is_tree(commit_1) +##' is_tree(tree_1) +##' } +is_tree <- function(object) { + inherits(object, "git_tree") +} + +##' List the contents of a tree object +##' +##' Traverse the entries in a tree and its subtrees. Akin to the 'git +##' ls-tree' command. +##' @param tree default (\code{NULL}) is the tree of the last commit +##' in \code{repo}. Can also be a \code{git_tree} object or a +##' character that identifies a tree in the repository (see +##' \sQuote{Examples}). +##' @param repo never used if \code{tree} is a \code{git_tree} +##' object. A \code{git_repository} object, or a path (default = +##' '.') to a repository. +##' @param recursive default is to recurse into sub-trees. +##' @return A data.frame with the following columns: \describe{ +##' \item{mode}{UNIX file attribute of the tree entry} +##' \item{type}{type of object} \item{sha}{sha of the object} +##' \item{path}{path relative to the root tree} +##' \item{name}{filename of the tree entry} \item{len}{object size +##' of blob (file) entries. NA for other objects.} } +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' dir.create(file.path(path, "subfolder")) +##' repo <- init(path) +##' +##' ## Create a user +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' +##' ## Create three files and commit +##' writeLines("First file", file.path(path, "example-1.txt")) +##' writeLines("Second file", file.path(path, "subfolder/example-2.txt")) +##' writeLines("Third file", file.path(path, "example-3.txt")) +##' add(repo, c("example-1.txt", "subfolder/example-2.txt", "example-3.txt")) +##' commit(repo, "Commit message") +##' +##' ## Traverse tree entries and its subtrees. +##' ## Various approaches that give identical result. +##' ls_tree(tree = tree(last_commit(path))) +##' ls_tree(tree = tree(last_commit(repo))) +##' ls_tree(repo = path) +##' ls_tree(repo = repo) +##' +##' ## Skip content in subfolder +##' ls_tree(repo = repo, recursive = FALSE) +##' +##' ## Start in subfolder +##' ls_tree(tree = "HEAD:subfolder", repo = repo) +##' } +ls_tree <- function(tree = NULL, repo = ".", recursive = TRUE) +{ + if (is.null(tree)) { + tree <- tree(last_commit(lookup_repository(repo))) + } else if (is.character(tree)) { + tree <- revparse_single(repo = lookup_repository(repo), revision = tree) + } + + data.frame(.Call(git2r_tree_walk, tree, recursive), + stringsAsFactors = FALSE) +} diff -Nru r-cran-git2r-0.21.0/R/when.r r-cran-git2r-0.22.1/R/when.r --- r-cran-git2r-0.21.0/R/when.r 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/R/when.r 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors -## -## This program is free software; you can redistribute it and/or modify -## it under the terms of the GNU General Public License, version 2, -## as published by the Free Software Foundation. -## -## git2r is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License along -## with this program; if not, write to the Free Software Foundation, Inc., -## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -##' When -##' -##' Help method to extract the time as a character string from the S4 -##' classes \code{git_commit}, \code{git_signature}, \code{git_tag} -##' and \code{git_time}. -##' @rdname when-methods -##' @docType methods -##' @param object the \code{object} to extract the time slot from. -##' @return A \code{character} vector of length one. -##' @keywords methods -##' @include S4_classes.r -##' @examples -##' \dontrun{ -##' ## Initialize a temporary repository -##' path <- tempfile(pattern="git2r-") -##' dir.create(path) -##' repo <- init(path) -##' -##' ## Create a first user and commit a file -##' config(repo, user.name="Alice", user.email="alice@@example.org") -##' writeLines("Hello world!", file.path(path, "example.txt")) -##' add(repo, "example.txt") -##' commit(repo, "First commit message") -##' -##' ## Create tag -##' tag(repo, "Tagname", "Tag message") -##' -##' when(commits(repo)[[1]]) -##' when(tags(repo)[[1]]) -##' } -setGeneric("when", - signature = "object", - function(object) - standardGeneric("when")) - -##' @rdname when-methods -##' @export -setMethod("when", - signature(object = "git_commit"), - function(object) - { - as(object@author@when, "character") - } -) - -##' @rdname when-methods -##' @export -setMethod("when", - signature(object = "git_signature"), - function(object) - { - as(object@when, "character") - } -) - -##' @rdname when-methods -##' @export -setMethod("when", - signature(object = "git_stash"), - function(object) - { - as(object@stasher@when, "character") - } -) - -##' @rdname when-methods -##' @export -setMethod("when", - signature(object = "git_tag"), - function(object) - { - as(object@tagger@when, "character") - } -) - -##' @rdname when-methods -##' @export -setMethod("when", - signature(object = "git_time"), - function(object) - { - as(object, "character") - } -) diff -Nru r-cran-git2r-0.21.0/R/when.R r-cran-git2r-0.22.1/R/when.R --- r-cran-git2r-0.21.0/R/when.R 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/R/when.R 2018-03-19 21:49:32.000000000 +0000 @@ -0,0 +1,55 @@ +## git2r, R bindings to the libgit2 library. +## Copyright (C) 2013-2018 The git2r contributors +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License, version 2, +## as published by the Free Software Foundation. +## +## git2r is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License along +## with this program; if not, write to the Free Software Foundation, Inc., +## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +##' When +##' +##' Help method to extract the time as a character string from a +##' git_commit, git_signature, git_tag and git_time object. +##' @param object the \code{object} to extract the time slot from. +##' @return A \code{character} vector of length one. +##' @export +##' @examples +##' \dontrun{ +##' ## Initialize a temporary repository +##' path <- tempfile(pattern="git2r-") +##' dir.create(path) +##' repo <- init(path) +##' +##' ## Create a first user and commit a file +##' config(repo, user.name="Alice", user.email="alice@@example.org") +##' writeLines("Hello world!", file.path(path, "example.txt")) +##' add(repo, "example.txt") +##' commit(repo, "First commit message") +##' +##' ## Create tag +##' tag(repo, "Tagname", "Tag message") +##' +##' when(commits(repo)[[1]]) +##' when(tags(repo)[[1]]) +##' } +when <- function(object) { + if (inherits(object, "git_commit")) + return(as.character(object$author$when)) + if (inherits(object, "git_signature")) + return(as.character(object$when)) + if (inherits(object, "git_stash")) + return(as.character(object$stasher$when)) + if (inherits(object, "git_tag")) + return(as.character(object$tagger$when)) + if (inherits(object, "git_time")) + return(as.character(object)) + stop("Invalid 'object'") +} diff -Nru r-cran-git2r-0.21.0/src/git2r_arg.c r-cran-git2r-0.22.1/src/git2r_arg.c --- r-cran-git2r-0.21.0/src/git2r_arg.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_arg.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,11 +16,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" +#include "git2r_S3.h" /** * Check blob argument @@ -30,16 +30,10 @@ */ int git2r_arg_check_blob(SEXP arg) { - SEXP class_name; - - if (isNull(arg) || S4SXP != TYPEOF(arg)) - return -1; - - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_blob")) + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_blob")) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("sha")))) + if (git2r_arg_check_sha(git2r_get_list_element(arg, "sha"))) return -1; return 0; @@ -53,20 +47,15 @@ */ int git2r_arg_check_branch(SEXP arg) { - SEXP class_name; SEXP slot; - if (isNull(arg) || S4SXP != TYPEOF(arg)) + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_branch")) return -1; - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_branch")) + if (git2r_arg_check_string(git2r_get_list_element(arg, "name"))) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("name")))) - return -1; - - slot = GET_SLOT(arg, Rf_install("type")); + slot = git2r_get_list_element(arg, "type"); if (git2r_arg_check_integer(slot)) return -1; switch (INTEGER(slot)[0]) { @@ -88,16 +77,30 @@ */ int git2r_arg_check_commit(SEXP arg) { - SEXP class_name; + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_commit")) + return -1; + + if (git2r_arg_check_sha(git2r_get_list_element(arg, "sha"))) + return -1; + + return 0; +} - if (isNull(arg) || S4SXP != TYPEOF(arg)) +/** + * Check commit or stash argument + * + * @param arg the arg to check + * @return 0 if OK, else -1 + */ +int git2r_arg_check_commit_stash(SEXP arg) +{ + if (!Rf_isNewList(arg)) return -1; - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_commit")) + if (!Rf_inherits(arg, "git_commit") && !Rf_inherits(arg, "git_stash")) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("sha")))) + if (git2r_arg_check_sha(git2r_get_list_element(arg, "sha"))) return -1; return 0; @@ -111,49 +114,46 @@ */ int git2r_arg_check_credentials(SEXP arg) { - SEXP class_name; - /* It's ok if the credentials is R_NilValue */ - if (isNull(arg)) + if (Rf_isNull(arg)) return 0; - if (S4SXP != TYPEOF(arg)) + if (!Rf_isNewList(arg)) return -1; - class_name = getAttrib(arg, R_ClassSymbol); - if (0 == strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_env")) { + if (Rf_inherits(arg, "cred_env")) { /* Check username and password */ - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("username")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "username"))) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("password")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "password"))) return -1; - } else if (0 == strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_token")) { + } else if (Rf_inherits(arg, "cred_token")) { /* Check token */ - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("token")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "token"))) return -1; - } else if (0 == strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_user_pass")) { + } else if (Rf_inherits(arg, "cred_user_pass")) { /* Check username and password */ - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("username")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "username"))) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("password")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "password"))) return -1; - } else if (0 == strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_ssh_key")) { + } else if (Rf_inherits(arg, "cred_ssh_key")) { SEXP passphrase; /* Check public and private key */ - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("publickey")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "publickey"))) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("privatekey")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "privatekey"))) return -1; /* Check that passphrase is a character vector */ - passphrase = GET_SLOT(arg, Rf_install("passphrase")); + passphrase = git2r_get_list_element(arg, "passphrase"); if (git2r_arg_check_string_vec(passphrase)) return -1; /* Check that length of passphrase < 2, i.e. it's either * character(0) or some "passphrase" */ - switch (length(passphrase)) { + switch (Rf_length(passphrase)) { case 0: break; case 1: @@ -174,7 +174,7 @@ * Check fetch_heads argument * * It's OK: - * - A list with S4 class git_fetch_head objects + * - A list with S3 class git_fetch_head objects * @param arg the arg to check * @return 0 if OK, else -1 */ @@ -182,27 +182,20 @@ { const char *repo = NULL; size_t i,n; - SEXP s_repo = Rf_install("repo"); - SEXP s_path = Rf_install("path"); - if (isNull(arg) || VECSXP != TYPEOF(arg)) + if (Rf_isNull(arg) || VECSXP != TYPEOF(arg)) return -1; /* Check that the repository paths are identical for each item */ n = Rf_length(arg); for (i = 0; i < n; i++) { SEXP path; - SEXP class_name; SEXP item = VECTOR_ELT(arg, i); - if (isNull(item) || S4SXP != TYPEOF(item)) + if (!Rf_isNewList(item) || !Rf_inherits(item, "git_fetch_head")) return -1; - class_name = getAttrib(item, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_fetch_head")) - return -1; - - path = GET_SLOT(GET_SLOT(item, s_repo), s_path); + path = git2r_get_list_element(git2r_get_list_element(item, "repo"), "path"); if (git2r_arg_check_string(path)) return -1; @@ -227,11 +220,11 @@ */ int git2r_arg_check_filename(SEXP arg) { - if (isNull(arg)) + if (Rf_isNull(arg)) return 0; - if (!isString(arg)) + if (!Rf_isString(arg)) return -1; - switch (length(arg)) { + switch (Rf_length(arg)) { case 0: break; case 1: @@ -275,10 +268,7 @@ */ int git2r_arg_check_integer(SEXP arg) { - if (isNull(arg) - || !isInteger(arg) - || 1 != length(arg) - || NA_INTEGER == INTEGER(arg)[0]) + if (!Rf_isInteger(arg) || 1 != Rf_length(arg) || NA_INTEGER == INTEGER(arg)[0]) return -1; return 0; } @@ -306,7 +296,7 @@ */ int git2r_arg_check_list(SEXP arg) { - if (isNull(arg) || !isNewList(arg)) + if (!Rf_isNewList(arg)) return -1; return 0; } @@ -320,10 +310,7 @@ */ int git2r_arg_check_logical(SEXP arg) { - if (isNull(arg) - || !isLogical(arg) - || 1 != length(arg) - || NA_LOGICAL == LOGICAL(arg)[0]) + if (!Rf_isLogical(arg) || 1 != Rf_length(arg) || NA_LOGICAL == LOGICAL(arg)[0]) return -1; return 0; } @@ -336,37 +323,66 @@ */ int git2r_arg_check_note(SEXP arg) { - SEXP class_name; + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_note")) + return -1; - if (isNull(arg) || S4SXP != TYPEOF(arg)) + if (git2r_arg_check_sha(git2r_get_list_element(arg, "sha"))) return -1; - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_note")) + if (git2r_arg_check_string(git2r_get_list_element(arg, "refname"))) + return -1; + + return 0; +} + +/** + * Check real argument + * + * @param arg the arg to check + * @return 0 if OK, else -1 + */ +int git2r_arg_check_real(SEXP arg) +{ + if (!Rf_isReal(arg) || 1 != Rf_length(arg) || !R_finite(REAL(arg)[0])) return -1; + return 0; +} - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("sha")))) +/** + * Check repository argument + * + * @param arg the arg to check + * @return 0 if OK, else -1 + */ +int git2r_arg_check_repository(SEXP arg) +{ + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_repository")) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("refname")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "path"))) return -1; return 0; } /** - * Check real argument + * Check if the two repositories have the same path * * @param arg the arg to check * @return 0 if OK, else -1 */ -int git2r_arg_check_real(SEXP arg) +int git2r_arg_check_same_repo(SEXP arg1, SEXP arg2) { - if (isNull(arg) - || !isReal(arg) - || 1 != length(arg) - || !R_finite(REAL(arg)[0])) + SEXP path1, path2; + + if (git2r_arg_check_repository(arg1) || git2r_arg_check_repository(arg2)) return -1; + + path1 = git2r_get_list_element(arg1, "path"); + path2 = git2r_get_list_element(arg2, "path"); + if (strcmp(CHAR(STRING_ELT(path1, 0)), CHAR(STRING_ELT(path2, 0)))) + return -1; + return 0; } @@ -378,25 +394,20 @@ */ int git2r_arg_check_signature(SEXP arg) { - SEXP class_name; SEXP when; - if (isNull(arg) || S4SXP != TYPEOF(arg)) - return -1; - - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_signature")) + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_signature")) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("name")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "name"))) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("email")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "email"))) return -1; - when = GET_SLOT(arg, Rf_install("when")); - if (git2r_arg_check_real(GET_SLOT(when, Rf_install("time")))) + when = git2r_get_list_element(arg, "when"); + if (git2r_arg_check_real(git2r_get_list_element(when, "time"))) return -1; - if (git2r_arg_check_real(GET_SLOT(when, Rf_install("offset")))) + if (git2r_arg_check_real(git2r_get_list_element(when, "offset"))) return -1; return 0; @@ -414,7 +425,7 @@ { if (git2r_arg_check_string_vec(arg) < 0) return -1; - if (1 != length(arg) || NA_STRING == STRING_ELT(arg, 0)) + if (1 != Rf_length(arg) || NA_STRING == STRING_ELT(arg, 0)) return -1; return 0; } @@ -429,7 +440,7 @@ */ int git2r_arg_check_string_vec(SEXP arg) { - if (isNull(arg) || !isString(arg)) + if (!Rf_isString(arg)) return -1; return 0; } @@ -447,7 +458,7 @@ size_t i, len; /* Count number of non NA values */ - len = length(src); + len = Rf_length(src); for (i = 0; i < len; i++) if (NA_STRING != STRING_ELT(src, i)) dst->count++; @@ -479,16 +490,10 @@ */ int git2r_arg_check_tag(SEXP arg) { - SEXP class_name; - - if (isNull(arg) || S4SXP != TYPEOF(arg)) - return -1; - - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_tag")) + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_tag")) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("target")))) + if (git2r_arg_check_string(git2r_get_list_element(arg, "target"))) return -1; return 0; @@ -502,16 +507,10 @@ */ int git2r_arg_check_tree(SEXP arg) { - SEXP class_name; - - if (isNull(arg) || S4SXP != TYPEOF(arg)) - return -1; - - class_name = getAttrib(arg, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_tree")) + if (!Rf_isNewList(arg) || !Rf_inherits(arg, "git_tree")) return -1; - if (git2r_arg_check_string(GET_SLOT(arg, Rf_install("sha")))) + if (git2r_arg_check_sha(git2r_get_list_element(arg, "sha"))) return -1; return 0; diff -Nru r-cran-git2r-0.21.0/src/git2r_arg.h r-cran-git2r-0.22.1/src/git2r_arg.h --- r-cran-git2r-0.21.0/src/git2r_arg.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_arg.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2016 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -21,11 +21,12 @@ #include #include -#include "git2.h" +#include int git2r_arg_check_blob(SEXP arg); int git2r_arg_check_branch(SEXP arg); int git2r_arg_check_commit(SEXP arg); +int git2r_arg_check_commit_stash(SEXP arg); int git2r_arg_check_credentials(SEXP arg); int git2r_arg_check_fetch_heads(SEXP arg); int git2r_arg_check_filename(SEXP arg); @@ -35,6 +36,8 @@ int git2r_arg_check_list(SEXP arg); int git2r_arg_check_logical(SEXP arg); int git2r_arg_check_note(SEXP arg); +int git2r_arg_check_repository(SEXP arg); +int git2r_arg_check_same_repo(SEXP arg1, SEXP arg2); int git2r_arg_check_signature(SEXP arg); int git2r_arg_check_string(SEXP arg); int git2r_arg_check_string_vec(SEXP arg); diff -Nru r-cran-git2r-0.21.0/src/git2r_blame.c r-cran-git2r-0.22.1/src/git2r_blame.c --- r-cran-git2r-0.21.0/src/git2r_blame.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_blame.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,112 +16,138 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_blame.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" /** - * Init slots in S4 class git_blame + * Init slots in S3 class git_blame * * Iterates over and init each git_blame_hunk * @param source a blame object - * @param repo S4 class git_repository that contains the blob + * @param repo S3 class git_repository that contains the blame * @param path The path to the file to get the blame - * @param dest S4 class git_blame to initialize + * @param dest S3 class git_blame to initialize * @return void */ void git2r_blame_init(git_blame *source, SEXP repo, SEXP path, SEXP dest) { SEXP hunks; size_t i, n; - SEXP s_hunks = Rf_install("hunks"); - SEXP s_lines_in_hunk = Rf_install("lines_in_hunk"); - SEXP s_final_commit_id = Rf_install("final_commit_id"); - SEXP s_final_start_line_number = Rf_install("final_start_line_number"); - SEXP s_final_signature = Rf_install("final_signature"); - SEXP s_orig_commit_id = Rf_install("orig_commit_id"); - SEXP s_orig_start_line_number = Rf_install("orig_start_line_number"); - SEXP s_orig_signature = Rf_install("orig_signature"); - SEXP s_orig_path = Rf_install("orig_path"); - SEXP s_boundary = Rf_install("boundary"); - SEXP s_repo = Rf_install("repo"); - SEXP s_path = Rf_install("path"); n = git_blame_get_hunk_count(source); - PROTECT(hunks = allocVector(VECSXP, n)); - SET_SLOT(dest, s_hunks, hunks); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_blame__hunks, + hunks = Rf_allocVector(VECSXP, n)); + for (i = 0; i < n; i++) { const git_blame_hunk *hunk; hunk = git_blame_get_hunk_byindex(source, i); if (hunk) { - SEXP item; + SEXP item, signature; char sha[GIT_OID_HEXSZ + 1]; SET_VECTOR_ELT( hunks, i, - item = NEW_OBJECT(MAKE_CLASS("git_blame_hunk"))); + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_blame_hunk)); + Rf_setAttrib( + item, + R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blame_hunk)); - SET_SLOT(item, s_lines_in_hunk, ScalarInteger(hunk->lines_in_hunk)); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__lines_in_hunk, + Rf_ScalarInteger(hunk->lines_in_hunk)); git_oid_fmt(sha, &(hunk->final_commit_id)); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(item, s_final_commit_id, mkString(sha)); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__final_commit_id, + Rf_mkString(sha)); - SET_SLOT( + SET_VECTOR_ELT( item, - s_final_start_line_number, - ScalarInteger(hunk->final_start_line_number)); + git2r_S3_item__git_blame_hunk__final_start_line_number, + Rf_ScalarInteger(hunk->final_start_line_number)); - git2r_signature_init( - hunk->final_signature, - GET_SLOT(item, s_final_signature)); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__final_signature, + signature = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + Rf_setAttrib( + signature, + R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); + git2r_signature_init(hunk->final_signature, signature); git_oid_fmt(sha, &(hunk->orig_commit_id)); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(item, s_orig_commit_id, mkString(sha)); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__orig_commit_id, + Rf_mkString(sha)); - SET_SLOT( + SET_VECTOR_ELT( item, - s_orig_start_line_number, - ScalarInteger(hunk->orig_start_line_number)); + git2r_S3_item__git_blame_hunk__orig_start_line_number, + Rf_ScalarInteger(hunk->orig_start_line_number)); - git2r_signature_init( - hunk->orig_signature, - GET_SLOT(item, s_orig_signature)); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__orig_signature, + signature = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + Rf_setAttrib(signature, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); + git2r_signature_init(hunk->orig_signature, signature); - SET_SLOT(item, s_orig_path, mkString(hunk->orig_path)); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__orig_path, + Rf_mkString(hunk->orig_path)); - if (hunk->boundary) - SET_SLOT(item, s_boundary, ScalarLogical(1)); - else - SET_SLOT(item, s_boundary, ScalarLogical(0)); + if (hunk->boundary) { + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__boundary, + Rf_ScalarLogical(1)); + } else { + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__boundary, + Rf_ScalarLogical(0)); + } - SET_SLOT(item, s_repo, repo); + SET_VECTOR_ELT( + item, + git2r_S3_item__git_blame_hunk__repo, + Rf_duplicate(repo)); } } - SET_SLOT(dest, s_path, path); - SET_SLOT(dest, s_repo, repo); - UNPROTECT(1); + SET_VECTOR_ELT(dest, git2r_S3_item__git_blame__path, path); + SET_VECTOR_ELT(dest, git2r_S3_item__git_blame__repo, Rf_duplicate(repo)); } /** * Get the blame for a single file * - * @param repo S4 class git_repository that contains the blob + * @param repo S3 class git_repository that contains the blob * @param path The path to the file to get the blame - * @return S4 class git_blame + * @return S3 class git_blame */ SEXP git2r_blame_file(SEXP repo, SEXP path) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git_blame *blame = NULL; git_repository *repository = NULL; @@ -134,28 +160,28 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_blame_file( + error = git_blame_file( &blame, repository, CHAR(STRING_ELT(path, 0)), &blame_opts); - if (err) + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_blame"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_blame)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blame)); git2r_blame_init(blame, repo, path, result); cleanup: - if (blame) - git_blame_free(blame); - - if (repository) - git_repository_free(repository); + git_blame_free(blame); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_blob.c r-cran-git2r-0.22.1/src/git2r_blob.c --- r-cran-git2r-0.21.0/src/git2r_blob.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_blob.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,22 +16,21 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include - #include "git2r_arg.h" #include "git2r_blob.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" /** * Get content of a blob * - * @param blob S4 class git_blob + * @param blob S3 class git_blob * @return content */ SEXP git2r_blob_content(SEXP blob) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; SEXP sha; git_blob *blob_obj = NULL; @@ -41,31 +40,29 @@ if (git2r_arg_check_blob(blob)) git2r_error(__func__, NULL, "'blob'", git2r_err_blob_arg); - repository = git2r_repository_open(GET_SLOT(blob, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(blob, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(blob, Rf_install("sha")); + sha = git2r_get_list_element(blob, "sha"); git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); - err = git_blob_lookup(&blob_obj, repository, &oid); - if (err) + error = git_blob_lookup(&blob_obj, repository, &oid); + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(git_blob_rawcontent(blob_obj))); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(git_blob_rawcontent(blob_obj))); cleanup: - if (blob_obj) - git_blob_free(blob_obj); - - if (repository) - git_repository_free(repository); + git_blob_free(blob_obj); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -77,15 +74,13 @@ * @param repo The repository where the blob will be written. Can be * a bare repository. * @param path The file from which the blob will be created. - * @return list of S4 class git_blob objects + * @return list of S3 class git_blob objects */ SEXP git2r_blob_create_fromdisk(SEXP repo, SEXP path) { SEXP result = R_NilValue; - int err = GIT_OK; + int error = 0, nprotect = 0; size_t len, i; - git_oid oid; - git_blob *blob = NULL; git_repository *repository = NULL; if (git2r_arg_check_string_vec(path)) @@ -95,37 +90,42 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - len = length(path); - PROTECT(result = allocVector(VECSXP, len)); + len = Rf_length(path); + PROTECT(result = Rf_allocVector(VECSXP, len)); + nprotect++; for (i = 0; i < len; i++) { if (NA_STRING != STRING_ELT(path, i)) { + git_oid oid; + git_blob *blob = NULL; SEXP item; - err = git_blob_create_fromdisk( + error = git_blob_create_fromdisk( &oid, repository, CHAR(STRING_ELT(path, i))); - if (err) + if (error) goto cleanup; - err = git_blob_lookup(&blob, repository, &oid); - if (err) + error = git_blob_lookup(&blob, repository, &oid); + if (error) goto cleanup; - SET_VECTOR_ELT(result, i, item = NEW_OBJECT(MAKE_CLASS("git_blob"))); + SET_VECTOR_ELT(result, i, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_blob)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blob)); git2r_blob_init(blob, repo, item); git_blob_free(blob); } } cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -141,15 +141,13 @@ * written. Cannot be a bare repository. * @param relative_path The file(s) from which the blob will be * created, relative to the repository's working dir. - * @return list of S4 class git_blob objects + * @return list of S3 class git_blob objects */ SEXP git2r_blob_create_fromworkdir(SEXP repo, SEXP relative_path) { SEXP result = R_NilValue; - int err = GIT_OK; + int error = 0, nprotect = 0; size_t len, i; - git_oid oid; - git_blob *blob = NULL; git_repository *repository = NULL; if (git2r_arg_check_string_vec(relative_path)) @@ -159,72 +157,75 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - len = length(relative_path); - PROTECT(result = allocVector(VECSXP, len)); + len = Rf_length(relative_path); + PROTECT(result = Rf_allocVector(VECSXP, len)); + nprotect++; for (i = 0; i < len; i++) { if (NA_STRING != STRING_ELT(relative_path, i)) { + git_oid oid; + git_blob *blob = NULL; SEXP item; - err = git_blob_create_fromworkdir( + error = git_blob_create_fromworkdir( &oid, repository, CHAR(STRING_ELT(relative_path, i))); - if (err) + if (error) goto cleanup; - err = git_blob_lookup(&blob, repository, &oid); - if (err) + error = git_blob_lookup(&blob, repository, &oid); + if (error) goto cleanup; - SET_VECTOR_ELT(result, i, item = NEW_OBJECT(MAKE_CLASS("git_blob"))); + SET_VECTOR_ELT(result, i, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_blob)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blob)); git2r_blob_init(blob, repo, item); git_blob_free(blob); } } cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; } /** - * Init slots in S4 class git_blob + * Init entries in a S3 class git_blob * * @param source a blob - * @param repo S4 class git_repository that contains the blob - * @param dest S4 class git_blob to initialize + * @param repo S3 class git_repository that contains the blob + * @param dest S3 class git_blob to initialize * @return void */ void git2r_blob_init(const git_blob *source, SEXP repo, SEXP dest) { const git_oid *oid; char sha[GIT_OID_HEXSZ + 1]; - SEXP s_sha = Rf_install("sha"); - SEXP s_repo = Rf_install("repo"); oid = git_blob_id(source); git_oid_tostr(sha, sizeof(sha), oid); - SET_SLOT(dest, s_sha, mkString(sha)); - SET_SLOT(dest, s_repo, repo); + SET_VECTOR_ELT(dest, git2r_S3_item__git_blob__sha, Rf_mkString(sha)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_blob__repo, Rf_duplicate(repo)); } /** * Is blob binary * - * @param blob S4 class git_blob + * @param blob S3 class git_blob * @return TRUE if binary data, FALSE if not */ SEXP git2r_blob_is_binary(SEXP blob) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; SEXP sha; git_blob *blob_obj = NULL; @@ -234,34 +235,32 @@ if (git2r_arg_check_blob(blob)) git2r_error(__func__, NULL, "'blob'", git2r_err_blob_arg); - repository= git2r_repository_open(GET_SLOT(blob, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(blob, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(blob, Rf_install("sha")); + sha = git2r_get_list_element(blob, "sha"); git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); - err = git_blob_lookup(&blob_obj, repository, &oid); - if (err) + error = git_blob_lookup(&blob_obj, repository, &oid); + if (error) goto cleanup; - PROTECT(result = allocVector(LGLSXP, 1)); + PROTECT(result = Rf_allocVector(LGLSXP, 1)); + nprotect++; if (git_blob_is_binary(blob_obj)) LOGICAL(result)[0] = 1; else LOGICAL(result)[0] = 0; cleanup: - if (blob_obj) - git_blob_free(blob_obj); - - if (repository) - git_repository_free(repository); + git_blob_free(blob_obj); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -270,12 +269,12 @@ /** * Size in bytes of contents of a blob * - * @param blob S4 class git_blob + * @param blob S3 class git_blob * @return size */ SEXP git2r_blob_rawsize(SEXP blob) { - int err; + int error; SEXP sha; git_off_t size = 0; git_blob *blob_obj = NULL; @@ -285,28 +284,25 @@ if (git2r_arg_check_blob(blob)) git2r_error(__func__, NULL, "'blob'", git2r_err_blob_arg); - repository= git2r_repository_open(GET_SLOT(blob, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(blob, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(blob, Rf_install("sha")); + sha = git2r_get_list_element(blob, "sha"); git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); - err = git_blob_lookup(&blob_obj, repository, &oid); - if (err) + error = git_blob_lookup(&blob_obj, repository, &oid); + if (error) goto cleanup; size = git_blob_rawsize(blob_obj); cleanup: - if (blob_obj) - git_blob_free(blob_obj); - - if (repository) - git_repository_free(repository); + git_blob_free(blob_obj); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); - return ScalarInteger(size); + return Rf_ScalarInteger(size); } diff -Nru r-cran-git2r-0.21.0/src/git2r_blob.h r-cran-git2r-0.22.1/src/git2r_blob.h --- r-cran-git2r-0.21.0/src/git2r_blob.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_blob.h 2018-07-10 13:23:34.000000000 +0000 @@ -21,7 +21,7 @@ #include #include -#include "git2.h" +#include SEXP git2r_blob_content(SEXP blob); SEXP git2r_blob_create_fromdisk(SEXP repo, SEXP path); diff -Nru r-cran-git2r-0.21.0/src/git2r_branch.c r-cran-git2r-0.22.1/src/git2r_branch.c --- r-cran-git2r-0.21.0/src/git2r_branch.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_branch.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,8 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "refs.h" +#include #include "git2r_arg.h" #include "git2r_branch.h" @@ -25,12 +24,13 @@ #include "git2r_error.h" #include "git2r_reference.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" /** * Count number of branches. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param flags Filtering flags for the branch listing. Valid values * are 1 (LOCAL), 2 (REMOTE) and 3 (ALL) * @param n The number of branches @@ -38,20 +38,20 @@ */ static int git2r_branch_count(git_repository *repo, int flags, size_t *n) { - int err; + int error; git_branch_iterator *iter; git_branch_t type; git_reference *ref; *n = 0; - err = git_branch_iterator_new(&iter, repo, flags); - if (err) - return err; + error = git_branch_iterator_new(&iter, repo, flags); + if (error) + return error; for (;;) { - err = git_branch_next(&ref, &type, iter); - if (err) + error = git_branch_next(&ref, &type, iter); + if (error) break; git_reference_free(ref); (*n)++; @@ -59,19 +59,19 @@ git_branch_iterator_free(iter); - if (GIT_ITEROVER != err) - return err; + if (GIT_ITEROVER != error) + return error; return 0; } /** - * Init slots in S4 class git_branch + * Init slots in S3 class git_branch * * @param source a reference * @param repository the repository * @param type the branch type; local or remote - * @param repo S4 class git_repository that contains the blob - * @param dest S4 class git_branch to initialize + * @param repo S3 class git_repository that contains the blob + * @param dest S3 class git_branch to initialize * @return int; < 0 if error, else 0 */ int git2r_branch_init( @@ -80,21 +80,18 @@ SEXP repo, SEXP dest) { - int err; + int error; const char *name; - SEXP s_name = Rf_install("name"); - SEXP s_type = Rf_install("type"); - SEXP s_repo = Rf_install("repo"); - err = git_branch_name(&name, source); - if (err) + error = git_branch_name(&name, source); + if (error) goto cleanup; - SET_SLOT(dest, s_name, mkString(name)); - SET_SLOT(dest, s_type, ScalarInteger(type)); - SET_SLOT(dest, s_repo, repo); + SET_VECTOR_ELT(dest, git2r_S3_item__git_branch__name, Rf_mkString(name)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_branch__type, Rf_ScalarInteger(type)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_branch__repo, Rf_duplicate(repo)); cleanup: - return err; + return error; } /** @@ -103,17 +100,15 @@ * @param branch_name Name for the branch * @param commit Commit to which branch should point. * @param force Overwrite existing branch - * @return S4 class git_branch + * @return S3 class git_branch */ SEXP git2r_branch_create( SEXP branch_name, SEXP commit, SEXP force) { - SEXP repo; - SEXP result = R_NilValue; - int err; - int overwrite = 0; + SEXP repo, result = R_NilValue; + int error, nprotect = 0, overwrite = 0; git_commit *target = NULL; git_reference *reference = NULL; git_repository *repository = NULL; @@ -125,44 +120,42 @@ if (git2r_arg_check_logical(force)) git2r_error(__func__, NULL, "'force'", git2r_err_logical_arg); - repo = GET_SLOT(commit, Rf_install("repo")); + repo = git2r_get_list_element(commit, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_commit_lookup(&target, repository, commit); - if (err) + error = git2r_commit_lookup(&target, repository, commit); + if (error) goto cleanup; if (LOGICAL(force)[0]) overwrite = 1; - err = git_branch_create( + error = git_branch_create( &reference, repository, CHAR(STRING_ELT(branch_name, 0)), target, overwrite); - if (err) + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_branch"))); - err = git2r_branch_init(reference, GIT_BRANCH_LOCAL, repo, result); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_branch)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_branch)); + error = git2r_branch_init(reference, GIT_BRANCH_LOCAL, repo, result); cleanup: - if (reference) - git_reference_free(reference); - - if (target) - git_commit_free(target); + git_reference_free(reference); + git_commit_free(target); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -171,12 +164,12 @@ /** * Delete branch * - * @param branch S4 class git_branch + * @param branch S3 class git_branch * @return R_NilValue */ SEXP git2r_branch_delete(SEXP branch) { - int err; + int error; const char *name; git_branch_t type; git_reference *reference = NULL; @@ -185,26 +178,23 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - err = git_branch_delete(reference); + error = git_branch_delete(reference); cleanup: - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_reference_free(reference); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -213,13 +203,13 @@ /** * Determine if the current local branch is pointed at by HEAD * - * @param branch S4 class git_branch + * @param branch S3 class git_branch * @return TRUE if head, FALSE if not */ SEXP git2r_branch_is_head(SEXP branch) { SEXP result = R_NilValue; - int err; + int error, nprotect = 0; const char *name; git_reference *reference = NULL; git_repository *repository = NULL; @@ -227,38 +217,36 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); - err = git_branch_lookup( + error = git_branch_lookup( &reference, repository, name, - INTEGER(GET_SLOT(branch, Rf_install("type")))[0]); - if (err) + INTEGER(git2r_get_list_element(branch, "type"))[0]); + if (error) goto cleanup; - err = git_branch_is_head(reference); - if (0 == err || 1 == err) { - PROTECT(result = allocVector(LGLSXP, 1)); - LOGICAL(result)[0] = err; - err = GIT_OK; + error = git_branch_is_head(reference); + if (0 == error || 1 == error) { + PROTECT(result = Rf_allocVector(LGLSXP, 1)); + nprotect++; + LOGICAL(result)[0] = error; + error = 0; } cleanup: - if (reference) - git_reference_free(reference); + git_reference_free(reference); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -267,16 +255,15 @@ /** * List branches in a repository * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param flags Filtering flags for the branch listing. Valid values * are 1 (LOCAL), 2 (REMOTE) and 3 (ALL) - * @return VECXSP with S4 objects of class git_branch + * @return VECXSP with S3 objects of class git_branch */ SEXP git2r_branch_list(SEXP repo, SEXP flags) { - SEXP result = R_NilValue; - SEXP names; - int err; + SEXP names, result = R_NilValue; + int error, nprotect = 0; git_branch_iterator *iter = NULL; size_t i, n = 0; git_repository *repository = NULL; @@ -291,53 +278,52 @@ git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); /* Count number of branches before creating the list */ - err = git2r_branch_count(repository, INTEGER(flags)[0], &n); - if (err) + error = git2r_branch_count(repository, INTEGER(flags)[0], &n); + if (error) goto cleanup; - PROTECT(result = allocVector(VECSXP, n)); - setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, n)); + PROTECT(result = Rf_allocVector(VECSXP, n)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, n)); - err = git_branch_iterator_new(&iter, repository, INTEGER(flags)[0]); - if (err) + error = git_branch_iterator_new(&iter, repository, INTEGER(flags)[0]); + if (error) goto cleanup; for (i = 0; i < n; i++) { SEXP branch; - err = git_branch_next(&reference, &type, iter); - if (err) { - if (GIT_ITEROVER == err) - err = GIT_OK; + error = git_branch_next(&reference, &type, iter); + if (error) { + if (GIT_ITEROVER == error) + error = GIT_OK; goto cleanup; } - SET_VECTOR_ELT(result, i, branch = NEW_OBJECT(MAKE_CLASS("git_branch"))); - err = git2r_branch_init(reference, type, repo, branch); - if (err) + SET_VECTOR_ELT(result, i, + branch = Rf_mkNamed(VECSXP, git2r_S3_items__git_branch)); + Rf_setAttrib(branch, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_branch)); + error = git2r_branch_init(reference, type, repo, branch); + if (error) goto cleanup; SET_STRING_ELT( names, i, - STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); + STRING_ELT(git2r_get_list_element(branch, "name"), 0)); if (reference) git_reference_free(reference); reference = NULL; } cleanup: - if (iter) - git_branch_iterator_free(iter); - - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_branch_iterator_free(iter); + git_reference_free(reference); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -346,12 +332,12 @@ /** * Get the full name of a branch * - * @param branch S4 class git_branch + * @param branch S3 class git_branch * @return character string with full name of branch. */ SEXP git2r_branch_canonical_name(SEXP branch) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const char *name; git_branch_t type; @@ -361,30 +347,28 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(git_reference_name(reference))); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(git_reference_name(reference))); cleanup: - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_reference_free(reference); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -394,65 +378,80 @@ * local branch, i.e "branch.branch_name.merge" property of the config * file. * - * @param branch S4 class git_branch. + * @param branch S3 class git_branch. * @return Character vector of length one with upstream canonical name. */ SEXP git2r_branch_upstream_canonical_name(SEXP branch) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; SEXP repo; const char *name; git_branch_t type; - git_buf buf = GIT_BUF_INIT; + const char *branch_name; + size_t branch_name_len; + char *buf = NULL; + size_t buf_len; git_config *cfg = NULL; git_repository *repository = NULL; if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; if (GIT_BRANCH_LOCAL != type) git2r_error(__func__, NULL, git2r_err_branch_not_local, NULL); - repo = GET_SLOT(branch, Rf_install("repo")); + repo = git2r_get_list_element(branch, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_repository_config_snapshot(&cfg, repository); - if (err) + error = git_repository_config_snapshot(&cfg, repository); + if (error) goto cleanup; - err = git_buf_join3( - &buf, - '.', - "branch", - CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)), - "merge"); - if (err) + branch_name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + branch_name_len = strlen(branch_name); + while (branch_name[0] == '.') { + branch_name++; + branch_name_len--; + } + while (branch_name_len >= 1 && branch_name[branch_name_len - 1] == '.') { + branch_name_len--; + } + buf_len = branch_name_len + sizeof("branch." ".merge"); + buf = malloc(buf_len); + if (!buf) { + giterr_set_oom(); + error = GITERR_NOMEMORY; goto cleanup; + } + error = snprintf(buf, buf_len, "branch.%.*s.merge", (int)branch_name_len, branch_name); + if (error < 0 || error >= buf_len) { + giterr_set_str(GITERR_OS, "Failed to snprintf branch config."); + error = GITERR_OS; + goto cleanup; + } - err = git_config_get_string(&name, cfg, buf.ptr); - if (err) + error = git_config_get_string(&name, cfg, buf); + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(name)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(name)); cleanup: - git_buf_free(&buf); + if (buf) + free(buf); + git_config_free(cfg); + git_repository_free(repository); - if (cfg) - git_config_free(cfg); + if (nprotect) + UNPROTECT(nprotect); - if (repository) - git_repository_free(repository); - - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -461,12 +460,12 @@ /** * Get remote name of branch * - * @param branch S4 class git_branch + * @param branch S3 class git_branch * @return character string with remote name. */ SEXP git2r_branch_remote_name(SEXP branch) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const char *name; git_buf buf = {0}; @@ -477,41 +476,39 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; if (GIT_BRANCH_REMOTE != type) git2r_error(__func__, NULL, git2r_err_branch_not_remote, NULL); - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - err = git_branch_remote_name( + error = git_branch_remote_name( &buf, repository, git_reference_name(reference)); - if (err) + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(buf.ptr)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(buf.ptr)); git_buf_free(&buf); cleanup: - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_reference_free(reference); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -520,12 +517,12 @@ /** * Get remote url of branch * - * @param branch S4 class git_branch + * @param branch S3 class git_branch * @return character string with remote url. */ SEXP git2r_branch_remote_url(SEXP branch) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const char *name; git_buf buf = {0}; @@ -537,53 +534,49 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; if (GIT_BRANCH_REMOTE != type) git2r_error(__func__, NULL, git2r_err_branch_not_remote, NULL); - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - err = git_branch_remote_name( + error = git_branch_remote_name( &buf, repository, git_reference_name(reference)); - if (err) + if (error) goto cleanup; - err = git_remote_lookup(&remote, repository, buf.ptr); - if (err) { - err = git_remote_create_anonymous(&remote, repository, buf.ptr); - if (err) { + error = git_remote_lookup(&remote, repository, buf.ptr); + if (error) { + error = git_remote_create_anonymous(&remote, repository, buf.ptr); + if (error) { git_buf_free(&buf); goto cleanup; } } git_buf_free(&buf); - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(git_remote_url(remote))); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(git_remote_url(remote))); cleanup: - if (remote) - git_remote_free(remote); - - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_remote_free(remote); + git_reference_free(reference); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -595,21 +588,18 @@ * @param branch Branch to rename * @param new_branch_name The new name for the branch * @param force Overwrite existing branch - * @return The renamed S4 class git_branch + * @return The renamed S3 class git_branch */ SEXP git2r_branch_rename( SEXP branch, SEXP new_branch_name, SEXP force) { - SEXP repo; - SEXP result = R_NilValue; - int err; - int overwrite = 0; + SEXP repo, result = R_NilValue; + int error, nprotect = 0, overwrite = 0; const char *name = NULL; git_branch_t type; - git_reference *reference = NULL; - git_reference *new_reference = NULL; + git_reference *reference = NULL, *new_reference = NULL; git_repository *repository = NULL; if (git2r_arg_check_branch(branch)) @@ -619,45 +609,43 @@ if (git2r_arg_check_logical(force)) git2r_error(__func__, NULL, "'force'", git2r_err_logical_arg); - repo = GET_SLOT(branch, Rf_install("repo")); + repo = git2r_get_list_element(branch, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - err = git_branch_lookup(&reference, repository, name, type); - if (err) + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; if (LOGICAL(force)[0]) overwrite = 1; - err = git_branch_move( + error = git_branch_move( &new_reference, reference, CHAR(STRING_ELT(new_branch_name, 0)), overwrite); - if (err) + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_branch"))); - err = git2r_branch_init(new_reference, type, repo, result); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_branch)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_branch)); + error = git2r_branch_init(new_reference, type, repo, result); cleanup: - if (reference) - git_reference_free(reference); - - if (new_reference) - git_reference_free(new_reference); + git_reference_free(reference); + git_reference_free(new_reference); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -666,12 +654,12 @@ /** * Get sha pointed to by a branch * - * @param branch S4 class git_branch + * @param branch S3 class git_branch * @return The 40 character sha if the reference is direct, else NA */ SEXP git2r_branch_target(SEXP branch) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const char *name; char sha[GIT_OID_HEXSZ + 1]; @@ -682,36 +670,34 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; if (GIT_REF_OID == git_reference_type(reference)) { git_oid_fmt(sha, git_reference_target(reference)); sha[GIT_OID_HEXSZ] = '\0'; - SET_STRING_ELT(result, 0, mkChar(sha)); + SET_STRING_ELT(result, 0, Rf_mkChar(sha)); } else { SET_STRING_ELT(result, 0, NA_STRING); } cleanup: - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_reference_free(reference); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -720,58 +706,54 @@ /** * Get remote tracking branch, given a local branch. * - * @param branch S4 class git_branch - * @return S4 class git_branch or R_NilValue if no remote tracking branch. + * @param branch S3 class git_branch + * @return S3 class git_branch or R_NilValue if no remote tracking branch. */ SEXP git2r_branch_get_upstream(SEXP branch) { - int err; - SEXP result = R_NilValue; - SEXP repo; + int error, nprotect = 0; + SEXP repo, result = R_NilValue; const char *name; git_branch_t type; - git_reference *reference = NULL; - git_reference *upstream = NULL; + git_reference *reference = NULL, *upstream = NULL; git_repository *repository = NULL; if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - repo = GET_SLOT(branch, Rf_install("repo")); + repo = git2r_get_list_element(branch, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - err = git_branch_upstream(&upstream, reference); - if (err) { - if (GIT_ENOTFOUND == err) - err = GIT_OK; + error = git_branch_upstream(&upstream, reference); + if (error) { + if (GIT_ENOTFOUND == error) + error = GIT_OK; goto cleanup; } - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_branch"))); - err = git2r_branch_init(upstream, GIT_BRANCH_REMOTE, repo, result); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_branch)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_branch)); + error = git2r_branch_init(upstream, GIT_BRANCH_REMOTE, repo, result); cleanup: - if (reference) - git_reference_free(reference); - - if (upstream) - git_reference_free(upstream); + git_reference_free(reference); + git_reference_free(upstream); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -788,7 +770,7 @@ */ SEXP git2r_branch_set_upstream(SEXP branch, SEXP upstream_name) { - int err; + int error; SEXP repo; const char *name; const char *u_name = NULL; @@ -798,33 +780,30 @@ if (git2r_arg_check_branch(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_branch_arg); - if (!isNull(upstream_name)) { + if (!Rf_isNull(upstream_name)) { if (git2r_arg_check_string(upstream_name)) git2r_error(__func__, NULL, "'upstream_name'", git2r_err_string_arg); u_name = CHAR(STRING_ELT(upstream_name, 0)); } - repo = GET_SLOT(branch, Rf_install("repo")); + repo = git2r_get_list_element(branch, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; - err = git_branch_set_upstream(reference, u_name); + error = git_branch_set_upstream(reference, u_name); cleanup: - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_reference_free(reference); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; diff -Nru r-cran-git2r-0.21.0/src/git2r_branch.h r-cran-git2r-0.22.1/src/git2r_branch.h --- r-cran-git2r-0.21.0/src/git2r_branch.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_branch.h 2018-07-10 13:23:34.000000000 +0000 @@ -21,7 +21,7 @@ #include #include -#include "git2.h" +#include SEXP git2r_branch_canonical_name(SEXP branch); SEXP git2r_branch_create(SEXP branch_name, SEXP commit, SEXP force); diff -Nru r-cran-git2r-0.21.0/src/git2r.c r-cran-git2r-0.22.1/src/git2r.c --- r-cran-git2r-0.21.0/src/git2r.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -24,12 +24,11 @@ * */ -#include #include #include #include -#include "git2.h" +#include #include "git2r_blame.h" #include "git2r_blob.h" @@ -59,6 +58,7 @@ #include "git2r_stash.h" #include "git2r_status.h" #include "git2r_tag.h" +#include "git2r_tree.h" #define CALLDEF(name, n) {#name, (DL_FUNC) &name, n} @@ -88,6 +88,7 @@ CALLDEF(git2r_commit, 4), CALLDEF(git2r_commit_parent_list, 1), CALLDEF(git2r_commit_tree, 1), + CALLDEF(git2r_config_find_file, 1), CALLDEF(git2r_config_get, 1), CALLDEF(git2r_config_get_logical, 2), CALLDEF(git2r_config_get_string, 2), @@ -100,7 +101,7 @@ CALLDEF(git2r_libgit2_features, 0), CALLDEF(git2r_libgit2_version, 0), CALLDEF(git2r_merge_base, 2), - CALLDEF(git2r_merge_branch, 3), + CALLDEF(git2r_merge_branch, 4), CALLDEF(git2r_merge_fetch_heads, 2), CALLDEF(git2r_note_create, 7), CALLDEF(git2r_note_default_ref, 1), @@ -142,13 +143,16 @@ CALLDEF(git2r_revwalk_list, 5), CALLDEF(git2r_signature_default, 1), CALLDEF(git2r_ssl_cert_locations, 2), + CALLDEF(git2r_stash_apply, 2), CALLDEF(git2r_stash_drop, 2), CALLDEF(git2r_stash_list, 1), + CALLDEF(git2r_stash_pop, 2), CALLDEF(git2r_stash_save, 6), CALLDEF(git2r_status_list, 6), CALLDEF(git2r_tag_create, 4), CALLDEF(git2r_tag_delete, 2), CALLDEF(git2r_tag_list, 1), + CALLDEF(git2r_tree_walk, 2), {NULL, NULL, 0} }; diff -Nru r-cran-git2r-0.21.0/src/git2r_checkout.c r-cran-git2r-0.22.1/src/git2r_checkout.c --- r-cran-git2r-0.21.0/src/git2r_checkout.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_checkout.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,9 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "refs.h" +#include #include "git2r_arg.h" #include "git2r_checkout.h" @@ -28,13 +26,13 @@ /** * Checkout path * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param path The paths to checkout * @return R_NilValue */ SEXP git2r_checkout_path(SEXP repo, SEXP path) { - int err = 0; + int error = 0; size_t i, len; git_repository *repository = NULL; git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; @@ -47,7 +45,7 @@ git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); /* Count number of non NA values */ - len = length(path); + len = Rf_length(path); for (i = 0; i < len; i++) if (NA_STRING != STRING_ELT(path, i)) opts.paths.count++; @@ -60,7 +58,7 @@ opts.paths.strings = malloc(opts.paths.count * sizeof(char*)); if (!opts.paths.strings) { giterr_set_str(GITERR_NONE, git2r_err_alloc_memory_buffer); - err = GIT_ERROR; + error = GIT_ERROR; goto cleanup; } @@ -70,16 +68,13 @@ opts.paths.strings[i] = (char *)CHAR(STRING_ELT(path, i)); opts.checkout_strategy = GIT_CHECKOUT_FORCE; - err = git_checkout_head(repository, &opts); + error = git_checkout_head(repository, &opts); cleanup: - if (opts.paths.strings) - free(opts.paths.strings); + free(opts.paths.strings); + git_repository_free(repository); - if (repository) - git_repository_free(repository); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -88,7 +83,7 @@ /** * Checkout tree * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param revision The revision string, see * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions * @param force Using checkout strategy GIT_CHECKOUT_SAFE (force = @@ -97,7 +92,7 @@ */ SEXP git2r_checkout_tree(SEXP repo, SEXP revision, SEXP force) { - int err; + int error; git_repository *repository = NULL; git_object *treeish = NULL; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; @@ -111,22 +106,22 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_revparse_single(&treeish, repository, CHAR(STRING_ELT(revision, 0))); - if (err) + error = git_revparse_single(&treeish, repository, CHAR(STRING_ELT(revision, 0))); + if (error) goto cleanup; switch (git_object_type(treeish)) { case GIT_OBJ_COMMIT: case GIT_OBJ_TAG: case GIT_OBJ_TREE: - err = GIT_OK; + error = GIT_OK; break; default: giterr_set_str(GITERR_NONE, git2r_err_checkout_tree); - err = GIT_ERROR; + error = GIT_ERROR; break; } - if (err) + if (error) goto cleanup; if (LOGICAL(force)[0]) @@ -134,16 +129,13 @@ else checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; - err = git_checkout_tree(repository, treeish, &checkout_opts); + error = git_checkout_tree(repository, treeish, &checkout_opts); cleanup: - if (treeish) - git_object_free(treeish); - - if (repository) - git_repository_free(repository); + git_object_free(treeish); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; diff -Nru r-cran-git2r-0.21.0/src/git2r_clone.c r-cran-git2r-0.22.1/src/git2r_clone.c --- r-cran-git2r-0.21.0/src/git2r_clone.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_clone.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_clone.h" @@ -85,7 +85,7 @@ SEXP credentials, SEXP progress) { - int err; + int error; git_repository *repository = NULL; git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; @@ -97,7 +97,7 @@ git2r_error(__func__, NULL, "'local_path'", git2r_err_string_arg); if (git2r_arg_check_logical(bare)) git2r_error(__func__, NULL, "'bare'", git2r_err_logical_arg); - if ((!isNull(branch)) && git2r_arg_check_string(branch)) + if ((!Rf_isNull(branch)) && git2r_arg_check_string(branch)) git2r_error(__func__, NULL, "'branch'", git2r_err_string_arg); if (git2r_arg_check_logical(checkout)) git2r_error(__func__, NULL, "'checkout'", git2r_err_logical_arg); @@ -119,7 +119,7 @@ if (LOGICAL(bare)[0]) clone_opts.bare = 1; - if (!isNull(branch)) + if (!Rf_isNull(branch)) clone_opts.checkout_branch = CHAR(STRING_ELT(branch, 0)); if (LOGICAL(progress)[0]) { @@ -127,15 +127,14 @@ Rprintf("cloning into '%s'...\n", CHAR(STRING_ELT(local_path, 0))); } - err = git_clone(&repository, + error = git_clone(&repository, CHAR(STRING_ELT(url, 0)), CHAR(STRING_ELT(local_path, 0)), &clone_opts); - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error( __func__, giterr_last(), diff -Nru r-cran-git2r-0.21.0/src/git2r_commit.c r-cran-git2r-0.22.1/src/git2r_commit.c --- r-cran-git2r-0.21.0/src/git2r_commit.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_commit.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,16 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "buffer.h" -#include "commit.h" +#include #include "git2r_arg.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_oid.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" #include "git2r_tree.h" @@ -37,15 +35,15 @@ */ static int git2r_any_changes_in_index(git_repository *repository) { - int err; + int error; int changes_in_index = 0; size_t i, count; git_status_list *status = NULL; git_status_options opts = GIT_STATUS_OPTIONS_INIT; opts.show = GIT_STATUS_SHOW_INDEX_ONLY; - err = git_status_list_new(&status, repository, &opts); - if (err) + error = git_status_list_new(&status, repository, &opts); + if (error) goto cleanup; count = git_status_list_entrycount(status); @@ -72,14 +70,12 @@ if (!changes_in_index) { giterr_set_str(GITERR_NONE, git2r_err_nothing_added_to_commit); - err = GIT_ERROR; + error = GIT_ERROR; } cleanup: - if (status) - git_status_list_free(status); - - return err; + git_status_list_free(status); + return error; } /** @@ -124,18 +120,18 @@ const git_oid *oid, void *payload) { - int err = 0; + int error = 0; git2r_merge_head_cb_data *cb_data = (git2r_merge_head_cb_data*)payload; if (cb_data->parents) - err = git_commit_lookup( + error = git_commit_lookup( &(cb_data->parents[cb_data->n]), cb_data->repository, oid); cb_data->n += 1; - return err; + return error; } /** @@ -151,28 +147,28 @@ size_t *n_parents, git_repository *repository) { - int err; + int error; git_oid oid; git2r_merge_head_cb_data cb_data = {0, NULL, NULL}; git_repository_state_t state; - err = git_repository_head_unborn(repository); - if (1 == err) { + error = git_repository_head_unborn(repository); + if (1 == error) { *n_parents = 0; return GIT_OK; - } else if (0 != err) { - return err; + } else if (0 != error) { + return error; } state = git_repository_state(repository); if (state == GIT_REPOSITORY_STATE_MERGE) { /* Count number of merge heads */ - err = git_repository_mergehead_foreach( + error = git_repository_mergehead_foreach( repository, git2r_repository_mergehead_foreach_cb, &cb_data); - if (err) - return err; + if (error) + return error; } *parents = calloc(cb_data.n + 1, sizeof(git_commit*)); @@ -182,25 +178,25 @@ } *n_parents = cb_data.n + 1; - err = git_reference_name_to_id(&oid, repository, "HEAD"); - if (err) - return err; - - err = git_commit_lookup(&**parents, repository, &oid); - if (err) - return err; + error = git_reference_name_to_id(&oid, repository, "HEAD"); + if (error) + return error; + + error = git_commit_lookup(&**parents, repository, &oid); + if (error) + return error; if (state == GIT_REPOSITORY_STATE_MERGE) { /* Append merge heads to parents */ cb_data.n = 0; cb_data.repository = repository; cb_data.parents = *parents + 1; - err = git_repository_mergehead_foreach( + error = git_repository_mergehead_foreach( repository, git2r_repository_mergehead_foreach_cb, &cb_data); - if (err) - return err; + if (error) + return error; } return GIT_OK; @@ -225,25 +221,25 @@ git_signature *author, git_signature *committer) { - int err; + int error; git_oid oid; git_tree *tree = NULL; git_commit **parents = NULL; size_t n_parents = 0; - err = git_index_write_tree(&oid, index); - if (err) + error = git_index_write_tree(&oid, index); + if (error) goto cleanup; - err = git_tree_lookup(&tree, repository, &oid); - if (err) + error = git_tree_lookup(&tree, repository, &oid); + if (error) goto cleanup; - err = git2r_retrieve_parents(&parents, &n_parents, repository); - if (err) + error = git2r_retrieve_parents(&parents, &n_parents, repository); + if (error) goto cleanup; - err = git_commit_create( + error = git_commit_create( out, repository, "HEAD", @@ -254,29 +250,25 @@ tree, n_parents, (const git_commit**)parents); - if (err) + if (error) goto cleanup; - err = git_repository_state_cleanup(repository); + error = git_repository_state_cleanup(repository); cleanup: - if (parents) - git2r_parents_free(parents, n_parents); - - if (tree) - git_tree_free(tree); - - return err; + git2r_parents_free(parents, n_parents); + git_tree_free(tree); + return error; } /** * Commit * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param message The message for the commit - * @param author S4 class git_signature - * @param committer S4 class git_signature - * @return S4 class git_commit + * @param author S3 class git_signature + * @param committer S3 class git_signature + * @return S3 class git_commit */ SEXP git2r_commit( SEXP repo, @@ -284,7 +276,7 @@ SEXP author, SEXP committer) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git_signature *c_author = NULL; git_signature *c_committer = NULL; @@ -304,70 +296,64 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_signature_from_arg(&c_author, author); - if (err) + error = git2r_signature_from_arg(&c_author, author); + if (error) goto cleanup; - err = git2r_signature_from_arg(&c_committer, committer); - if (err) + error = git2r_signature_from_arg(&c_committer, committer); + if (error) goto cleanup; - err = git2r_any_changes_in_index(repository); - if (err) + error = git2r_any_changes_in_index(repository); + if (error) goto cleanup; - err = git_repository_index(&index, repository); - if (err) + error = git_repository_index(&index, repository); + if (error) goto cleanup; - err = git2r_commit_create( + error = git2r_commit_create( &oid, repository, index, CHAR(STRING_ELT(message, 0)), c_author, c_committer); - if (err) + if (error) goto cleanup; - err = git_commit_lookup(&commit, repository, &oid); - if (err) + error = git_commit_lookup(&commit, repository, &oid); + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_commit"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init(commit, repo, result); cleanup: - if (c_author) - git_signature_free(c_author); - - if (c_committer) - git_signature_free(c_committer); - - if (index) - git_index_free(index); + git_signature_free(c_author); + git_signature_free(c_committer); + git_index_free(index); + git_repository_free(repository); + git_commit_free(commit); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (commit) - git_commit_free(commit); - - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; } /** - * Get commit object from S4 class git_commit + * Get commit object from S3 class git_commit * * @param out Pointer to the looked up commit * @param repository The repository - * @param commit S4 class git_commit + * @param commit S3 class git_commit * @return 0 or an error code */ int git2r_commit_lookup( @@ -378,7 +364,7 @@ SEXP sha; git_oid oid; - sha = GET_SLOT(commit, Rf_install("sha")); + sha = git2r_get_list_element(commit, "sha"); git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); return git_commit_lookup(out, repository, &oid); } @@ -386,110 +372,124 @@ /** * Get the tree pointed to by a commit * - * @param commit S4 class git_commit or git_stash - * @return S4 class git_tree + * @param commit S3 class git_commit or git_stash + * @return S3 class git_tree */ SEXP git2r_commit_tree(SEXP commit) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; SEXP repo; git_commit *commit_obj = NULL; git_repository *repository = NULL; git_tree *tree = NULL; - if (git2r_arg_check_commit(commit)) - git2r_error(__func__, NULL, "'commit'", git2r_err_commit_arg); + if (git2r_arg_check_commit_stash(commit)) + git2r_error(__func__, NULL, "'commit'", git2r_err_commit_stash_arg); - repo = GET_SLOT(commit, Rf_install("repo")); + repo = git2r_get_list_element(commit, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_commit_lookup(&commit_obj, repository, commit); - if (err) + error = git2r_commit_lookup(&commit_obj, repository, commit); + if (error) goto cleanup; - err = git_commit_tree(&tree, commit_obj); - if (err) + error = git_commit_tree(&tree, commit_obj); + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_tree"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_tree)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tree)); git2r_tree_init((git_tree*)tree, repo, result); cleanup: - if (commit_obj) - git_commit_free(commit_obj); + git_commit_free(commit_obj); + git_tree_free(tree); + git_repository_free(repository); - if (tree) - git_tree_free(tree); + if (nprotect) + UNPROTECT(nprotect); - if (repository) - git_repository_free(repository); - - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; } /** - * Init slots in S4 class git_commit + * Init slots in S3 class git_commit * * @param source a commit object - * @param repo S4 class git_repository that contains the blob - * @param dest S4 class git_commit to initialize + * @param repo S3 class git_repository that contains the blob + * @param dest S3 class git_commit to initialize * @return void */ void git2r_commit_init(git_commit *source, SEXP repo, SEXP dest) { - const char *message; - const char *summary; - const git_signature *author; - const git_signature *committer; + const char *str; + const git_signature *signature; char sha[GIT_OID_HEXSZ + 1]; - SEXP s_sha = Rf_install("sha"); - SEXP s_author = Rf_install("author"); - SEXP s_committer = Rf_install("committer"); - SEXP s_summary = Rf_install("summary"); - SEXP s_message = Rf_install("message"); - SEXP s_repo = Rf_install("repo"); git_oid_fmt(sha, git_commit_id(source)); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(dest, s_sha, mkString(sha)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_commit__sha, Rf_mkString(sha)); + + signature = git_commit_author(source); + if (signature) { + SEXP elem = VECTOR_ELT(dest, git2r_S3_item__git_commit__author); + + if (Rf_isNull(elem)) { + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_commit__author, + elem = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + Rf_setAttrib(elem, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); + } - author = git_commit_author(source); - if (author) - git2r_signature_init(author, GET_SLOT(dest, s_author)); + git2r_signature_init(signature, elem); + } - committer = git_commit_committer(source); - if (committer) - git2r_signature_init(committer, GET_SLOT(dest, s_committer)); + signature = git_commit_committer(source); + if (signature) { + SEXP elem = VECTOR_ELT(dest, git2r_S3_item__git_commit__committer); + + if (Rf_isNull(elem)) { + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_commit__author, + elem = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + Rf_setAttrib(elem, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); + } - summary = git_commit_summary(source); - if (summary) - SET_SLOT(dest, s_summary, mkString(summary)); + git2r_signature_init(signature, elem); + } - message = git_commit_message(source); - if (message) - SET_SLOT(dest, s_message, mkString(message)); + str = git_commit_summary(source); + if (str) + SET_VECTOR_ELT(dest, git2r_S3_item__git_commit__summary, Rf_mkString(str)); + + str = git_commit_message(source); + if (str) + SET_VECTOR_ELT(dest, git2r_S3_item__git_commit__message, Rf_mkString(str)); - SET_SLOT(dest, s_repo, repo); + SET_VECTOR_ELT(dest, git2r_S3_item__git_commit__repo, Rf_duplicate(repo)); } /** * Parents of a commit * - * @param commit S4 class git_commit - * @return list of S4 class git_commit objects + * @param commit S3 class git_commit + * @return list of S3 class git_commit objects */ SEXP git2r_commit_parent_list(SEXP commit) { - int err; + int error, nprotect = 0; size_t i, n; SEXP repo; SEXP list = R_NilValue; @@ -499,42 +499,45 @@ if (git2r_arg_check_commit(commit)) git2r_error(__func__, NULL, "'commit'", git2r_err_commit_arg); - repo = GET_SLOT(commit, Rf_install("repo")); + repo = git2r_get_list_element(commit, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_commit_lookup(&commit_obj, repository, commit); - if (err) + error = git2r_commit_lookup(&commit_obj, repository, commit); + if (error) goto cleanup; n = git_commit_parentcount(commit_obj); - PROTECT(list = allocVector(VECSXP, n)); + PROTECT(list = Rf_allocVector(VECSXP, n)); + nprotect++; for (i = 0; i < n; i++) { git_commit *parent = NULL; SEXP item; - err = git_commit_parent(&parent, commit_obj, i); - if (err) + error = git_commit_parent(&parent, commit_obj, i); + if (error) goto cleanup; - SET_VECTOR_ELT(list, i, item = NEW_OBJECT(MAKE_CLASS("git_commit"))); + SET_VECTOR_ELT( + list, + i, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init(parent, repo, item); git_commit_free(parent); } cleanup: - if (commit_obj) - git_commit_free(commit_obj); - - if (repository) - git_repository_free(repository); + git_commit_free(commit_obj); + git_repository_free(repository); - if (!isNull(list)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return list; diff -Nru r-cran-git2r-0.21.0/src/git2r_commit.h r-cran-git2r-0.22.1/src/git2r_commit.h --- r-cran-git2r-0.21.0/src/git2r_commit.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_commit.h 2018-07-10 13:23:34.000000000 +0000 @@ -22,7 +22,7 @@ #include #include -#include "git2.h" +#include SEXP git2r_commit( SEXP repo, diff -Nru r-cran-git2r-0.21.0/src/git2r_config.c r-cran-git2r-0.22.1/src/git2r_config.c --- r-cran-git2r-0.21.0/src/git2r_config.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_config.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,8 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" @@ -36,19 +35,19 @@ const git_config *cfg, size_t *n_level) { - int err; + int error; git_config_iterator *iterator = NULL; - err = git_config_iterator_new(&iterator, cfg); - if (err) - return err; + error = git_config_iterator_new(&iterator, cfg); + if (error) + return error; for (;;) { git_config_entry *entry; - err = git_config_next(&entry, iterator); - if (err) { - if (GIT_ITEROVER == err) - err = GIT_OK; + error = git_config_next(&entry, iterator); + if (error) { + if (GIT_ITEROVER == error) + error = GIT_OK; goto cleanup; } @@ -77,16 +76,14 @@ default: giterr_set_str(GITERR_CONFIG, git2r_err_unexpected_config_level); - err = GIT_ERROR; + error = GIT_ERROR; goto cleanup; } } cleanup: - if (iterator) - git_config_iterator_free(iterator); - - return err; + git_config_iterator_free(iterator); + return error; } /** @@ -114,10 +111,10 @@ SET_VECTOR_ELT( list, i_list[level], - item = allocVector(VECSXP, n_level[level])); - setAttrib(item, R_NamesSymbol, allocVector(STRSXP, n_level[level])); - names = getAttrib(list, R_NamesSymbol); - SET_STRING_ELT(names, i_list[level] , mkChar(name)); + item = Rf_allocVector(VECSXP, n_level[level])); + Rf_setAttrib(item, R_NamesSymbol, Rf_allocVector(STRSXP, n_level[level])); + names = Rf_getAttrib(list, R_NamesSymbol); + SET_STRING_ELT(names, i_list[level] , Rf_mkChar(name)); } return i; @@ -146,9 +143,9 @@ SEXP sub_list = VECTOR_ELT(list, i_list[level]); if (i_level[level] < (size_t)LENGTH(sub_list)) { - SEXP names = getAttrib(sub_list, R_NamesSymbol); - SET_STRING_ELT(names, i_level[level], mkChar(entry->name)); - SET_VECTOR_ELT(sub_list, i_level[level], mkString(entry->value)); + SEXP names = Rf_getAttrib(sub_list, R_NamesSymbol); + SET_STRING_ELT(names, i_level[level], Rf_mkChar(entry->name)); + SET_VECTOR_ELT(sub_list, i_level[level], Rf_mkString(entry->value)); i_level[level]++; return; } @@ -169,14 +166,14 @@ SEXP list, size_t *n_level) { - int err; + int error; size_t i_level[GIT2R_N_CONFIG_LEVELS] = {0}; /* Current index at level */ size_t i_list[GIT2R_N_CONFIG_LEVELS] = {0}; /* Index of level in target list */ git_config_iterator *iterator = NULL; size_t i = 0; - err = git_config_iterator_new(&iterator, cfg); - if (err) + error = git_config_iterator_new(&iterator, cfg); + if (error) goto cleanup; i = git2r_config_list_init(list, 0, n_level, i_list, i, "programdata"); @@ -189,10 +186,10 @@ for (;;) { git_config_entry *entry; - err = git_config_next(&entry, iterator); - if (err) { - if (GIT_ITEROVER == err) - err = GIT_OK; + error = git_config_next(&entry, iterator); + if (error) { + if (GIT_ITEROVER == error) + error = GIT_OK; goto cleanup; } @@ -221,23 +218,21 @@ default: giterr_set_str(GITERR_CONFIG, git2r_err_unexpected_config_level); - err = GIT_ERROR; + error = GIT_ERROR; goto cleanup; } } cleanup: - if (iterator) - git_config_iterator_free(iterator); - - return err; + git_config_iterator_free(iterator); + return error; } /** * Open configuration file * * @param out Pointer to store the loaded configuration. - * @param repo S4 class git_repository. If non-R_NilValue open the + * @param repo S3 class git_repository. If non-R_NilValue open the * configuration file for the repository. If R_NilValue open the * global, XDG and system configuration files. * @param snapshot Open a snapshot of the configuration. @@ -245,57 +240,57 @@ */ static int git2r_config_open(git_config **out, SEXP repo, int snapshot) { - int err; + int error; - if (!isNull(repo)) { + if (!Rf_isNull(repo)) { git_repository *repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); if (snapshot) - err = git_repository_config_snapshot(out, repository); + error = git_repository_config_snapshot(out, repository); else - err = git_repository_config(out, repository); + error = git_repository_config(out, repository); git_repository_free(repository); } else if (snapshot) { git_config *config = NULL; - err = git_config_open_default(&config); - if (err) { + error = git_config_open_default(&config); + if (error) { git_config_free(config); - return err; + return error; } - err = git_config_snapshot(out, config); + error = git_config_snapshot(out, config); git_config_free(config); } else { - err = git_config_open_default(out); + error = git_config_open_default(out); } - return err; + return error; } /** * Get config variables * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return VECSXP list with variables by level */ SEXP git2r_config_get(SEXP repo) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; size_t i = 0, n = 0, n_level[GIT2R_N_CONFIG_LEVELS] = {0}; git_config *cfg = NULL; - err = git2r_config_open(&cfg, repo, 0); - if (err) + error = git2r_config_open(&cfg, repo, 0); + if (error) goto cleanup; - err = git2r_config_count_variables(cfg, n_level); - if (err) + error = git2r_config_count_variables(cfg, n_level); + if (error) goto cleanup; /* Count levels with entries */ @@ -304,20 +299,20 @@ n++; } - PROTECT(result = allocVector(VECSXP, n)); - setAttrib(result, R_NamesSymbol, allocVector(STRSXP, n)); + PROTECT(result = Rf_allocVector(VECSXP, n)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, Rf_allocVector(STRSXP, n)); if (git2r_config_list_variables(cfg, result, n_level)) goto cleanup; cleanup: - if (cfg) - git_config_free(cfg); + git_config_free(cfg); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -326,13 +321,13 @@ /** * Set or delete config entries * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param variables list of variables. If variable is NULL, it's deleted. * @return R_NilValue */ SEXP git2r_config_set(SEXP repo, SEXP variables) { - int err = 0, nprotect = 0; + int error = 0, nprotect = 0; SEXP names; size_t i, n; git_config *cfg = NULL; @@ -340,30 +335,30 @@ if (git2r_arg_check_list(variables)) git2r_error(__func__, NULL, "'variables'", git2r_err_list_arg); - n = length(variables); + n = Rf_length(variables); if (n) { - err = git2r_config_open(&cfg, repo, 0); - if (err) + error = git2r_config_open(&cfg, repo, 0); + if (error) goto cleanup; - PROTECT(names = getAttrib(variables, R_NamesSymbol)); + PROTECT(names = Rf_getAttrib(variables, R_NamesSymbol)); nprotect++; for (i = 0; i < n; i++) { const char *key = CHAR(STRING_ELT(names, i)); const char *value = NULL; - if (!isNull(VECTOR_ELT(variables, i))) + if (!Rf_isNull(VECTOR_ELT(variables, i))) value = CHAR(STRING_ELT(VECTOR_ELT(variables, i), 0)); if (value) - err = git_config_set_string(cfg, key, value); + error = git_config_set_string(cfg, key, value); else - err = git_config_delete_entry(cfg, key); + error = git_config_delete_entry(cfg, key); - if (err) { - if (err == GIT_EINVALIDSPEC) { + if (error) { + if (error == GIT_EINVALIDSPEC) { Rf_warning("Variable was not in a valid format: '%s'", key); - err = 0; + error = 0; } else { goto cleanup; } @@ -373,13 +368,12 @@ } cleanup: - if (cfg) - git_config_free(cfg); + git_config_free(cfg); if (nprotect) UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -388,14 +382,14 @@ /** * Get the value of a string config variable * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The name of the variable * @return If the variable exists, a character vector of length one * with the value, else R_NilValue. */ SEXP git2r_config_get_string(SEXP repo, SEXP name) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const char *value; git_config *cfg = NULL; @@ -403,28 +397,28 @@ if (git2r_arg_check_string(name)) git2r_error(__func__, NULL, "'name'", git2r_err_string_arg); - err = git2r_config_open(&cfg, repo, 1); - if (err) + error = git2r_config_open(&cfg, repo, 1); + if (error) goto cleanup; - err = git_config_get_string(&value, cfg, CHAR(STRING_ELT(name, 0))); - if (err) { - if (err == GIT_ENOTFOUND) - err = 0; + error = git_config_get_string(&value, cfg, CHAR(STRING_ELT(name, 0))); + if (error) { + if (error == GIT_ENOTFOUND) + error = 0; goto cleanup; } - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(value)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(value)); cleanup: - if (cfg) - git_config_free(cfg); + git_config_free(cfg); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -433,14 +427,14 @@ /** * Get the value of a boolean config variable * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The name of the variable * @return If the variable exists, a logical vector of length one * with TRUE or FALSE, else R_NilValue. */ SEXP git2r_config_get_logical(SEXP repo, SEXP name) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; int value; git_config *cfg = NULL; @@ -448,32 +442,67 @@ if (git2r_arg_check_string(name)) git2r_error(__func__, NULL, "'name'", git2r_err_string_arg); - err = git2r_config_open(&cfg, repo, 1); - if (err) + error = git2r_config_open(&cfg, repo, 1); + if (error) goto cleanup; - err = git_config_get_bool(&value, cfg, CHAR(STRING_ELT(name, 0))); - if (err) { - if (err == GIT_ENOTFOUND) - err = 0; + error = git_config_get_bool(&value, cfg, CHAR(STRING_ELT(name, 0))); + if (error) { + if (error == GIT_ENOTFOUND) + error = 0; goto cleanup; } - PROTECT(result = allocVector(LGLSXP, 1)); + PROTECT(result = Rf_allocVector(LGLSXP, 1)); + nprotect++; if (value) LOGICAL(result)[0] = 1; else LOGICAL(result)[0] = 0; cleanup: - if (cfg) - git_config_free(cfg); + git_config_free(cfg); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; } + +/** + * Locate the path to the configuration file + * + * @return path if a configuration file has been found, else NA. + */ +SEXP git2r_config_find_file(SEXP level) +{ + int not_found = 1; + SEXP result; + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); + + if (git2r_arg_check_string(level)) + git2r_error(__func__, NULL, "'level'", git2r_err_string_arg); + + if (strcmp(CHAR(STRING_ELT(level, 0)), "global") == 0) + not_found = git_config_find_global(&buf); + else if (strcmp(CHAR(STRING_ELT(level, 0)), "programdata") == 0) + not_found = git_config_find_programdata(&buf); + else if (strcmp(CHAR(STRING_ELT(level, 0)), "system") == 0) + not_found = git_config_find_system(&buf); + else if (strcmp(CHAR(STRING_ELT(level, 0)), "xdg") == 0) + not_found = git_config_find_xdg(&buf); + + PROTECT(result = Rf_allocVector(STRSXP, 1)); + if (not_found) + SET_STRING_ELT(result, 0, NA_STRING); + else + SET_STRING_ELT(result, 0, Rf_mkChar(buf.ptr)); + + git_buf_free(&buf); + UNPROTECT(1); + + return result; +} diff -Nru r-cran-git2r-0.21.0/src/git2r_config.h r-cran-git2r-0.22.1/src/git2r_config.h --- r-cran-git2r-0.21.0/src/git2r_config.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_config.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -22,6 +22,7 @@ #include #include +SEXP git2r_config_find_file(SEXP level); SEXP git2r_config_get(SEXP repo); SEXP git2r_config_get_logical(SEXP repo, SEXP name); SEXP git2r_config_get_string(SEXP repo, SEXP name); diff -Nru r-cran-git2r-0.21.0/src/git2r_cred.c r-cran-git2r-0.22.1/src/git2r_cred.c --- r-cran-git2r-0.21.0/src/git2r_cred.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_cred.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -18,21 +18,63 @@ #include #include -#include -#include "buffer.h" -#include "common.h" +#ifdef WIN32 +#include +#include +# ifndef WC_ERR_INVALID_CHARS +# define WC_ERR_INVALID_CHARS 0x80 +# endif +#endif + +#include +#include + +#include + +#include "git2r_arg.h" #include "git2r_cred.h" +#include "git2r_S3.h" #include "git2r_transfer.h" +#define GIT2R_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) + +/** + * Read an environtmental variable. + * + * @param out Pointer where to store the environmental variable. + * @param obj The S3 object with name of the environmental + * variable to read. + * @param slot The slot in the S3 object with the name of the + * environmental variable. + * @return 0 on success, else -1. + */ +static int git2r_getenv(char **out, SEXP obj, const char *slot) +{ + const char *buf; + + /* Read value of the environment variable */ + buf = getenv(CHAR(STRING_ELT(git2r_get_list_element(obj, slot), 0))); + if (!buf || !strlen(buf)) + return -1; + + *out = malloc(strlen(buf)+1); + if (!*out) + return -1; + + strcpy(*out, buf); + + return 0; +} + /** - * Create credential object from S4 class 'cred_ssh_key'. + * Create credential object from S3 class 'cred_ssh_key'. * * @param cred The newly created credential object. * @param user_from_url The username that was embedded in a "user@host" * @param allowed_types A bitmask stating which cred types are OK to return. - * @param credentials The S4 class object with credentials. + * @param credentials The S3 class object with credentials. * @return 0 on success, else -1. */ static int git2r_cred_ssh_key( @@ -42,21 +84,17 @@ SEXP credentials) { if (GIT_CREDTYPE_SSH_KEY & allowed_types) { - SEXP slot; + SEXP elem; const char *publickey; const char *privatekey = NULL; const char *passphrase = NULL; - publickey = CHAR(STRING_ELT( - GET_SLOT(credentials, - Rf_install("publickey")), 0)); - privatekey = CHAR(STRING_ELT( - GET_SLOT(credentials, - Rf_install("privatekey")), 0)); - - slot = GET_SLOT(credentials, Rf_install("passphrase")); - if (length(slot) && (NA_STRING != STRING_ELT(slot, 0))) - passphrase = CHAR(STRING_ELT(slot, 0)); + publickey = CHAR(STRING_ELT(git2r_get_list_element(credentials, "publickey"), 0)); + privatekey = CHAR(STRING_ELT(git2r_get_list_element(credentials, "privatekey"), 0)); + + elem = git2r_get_list_element(credentials, "passphrase"); + if (Rf_length(elem) && (NA_STRING != STRING_ELT(elem, 0))) + passphrase = CHAR(STRING_ELT(elem, 0)); if (git_cred_ssh_key_new( cred, username_from_url, publickey, privatekey, passphrase)) @@ -69,11 +107,11 @@ } /** - * Create credential object from S4 class 'cred_env'. + * Create credential object from S3 class 'cred_env'. * * @param cred The newly created credential object. * @param allowed_types A bitmask stating which cred types are OK to return. - * @param credentials The S4 class object with credentials. + * @param credentials The S3 class object with credentials. * @return 0 on success, else -1. */ static int git2r_cred_env( @@ -82,46 +120,27 @@ SEXP credentials) { if (GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) { - int err; - git_buf username = GIT_BUF_INIT; - git_buf password = GIT_BUF_INIT; + int error; + char *username = NULL; + char *password = NULL; /* Read value of the username environment variable */ - err = git__getenv(&username, - CHAR(STRING_ELT( - GET_SLOT(credentials, - Rf_install("username")), 0))); - if (err) + error = git2r_getenv(&username, credentials, "username"); + if (error) goto cleanup; - if (!git_buf_len(&username)) { - err = -1; - goto cleanup; - } - /* Read value of the password environment variable */ - err = git__getenv(&password, - CHAR(STRING_ELT( - GET_SLOT(credentials, - Rf_install("password")), 0))); - if (err) - goto cleanup; - - if (!git_buf_len(&password)) { - err = -1; + error = git2r_getenv(&password, credentials, "password"); + if (error) goto cleanup; - } - err = git_cred_userpass_plaintext_new( - cred, - git_buf_cstr(&username), - git_buf_cstr(&password)); + error = git_cred_userpass_plaintext_new(cred, username, password); cleanup: - git_buf_free(&username); - git_buf_free(&password); + free(username); + free(password); - if (err) + if (error) return -1; return 0; @@ -131,11 +150,11 @@ } /** - * Create credential object from S4 class 'cred_token'. + * Create credential object from S3 class 'cred_token'. * * @param cred The newly created credential object. * @param allowed_types A bitmask stating which cred types are OK to return. - * @param credentials The S4 class object with credentials. + * @param credentials The S3 class object with credentials. * @return 0 on success, else -1. */ static int git2r_cred_token( @@ -144,23 +163,21 @@ SEXP credentials) { if (GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) { - int err; - git_buf token = GIT_BUF_INIT; + int error; + char *token = NULL; /* Read value of the personal access token from the * environment variable */ - err = git__getenv(&token, - CHAR(STRING_ELT(GET_SLOT(credentials, - Rf_install("token")), 0))); - if (err) + error = git2r_getenv(&token, credentials, "token"); + if (error) goto cleanup; - err = git_cred_userpass_plaintext_new(cred, " ", git_buf_cstr(&token)); + error = git_cred_userpass_plaintext_new(cred, " ", token); cleanup: - git_buf_free(&token); + free(token); - if (err) + if (error) return -1; return 0; @@ -170,11 +187,11 @@ } /** - * Create credential object from S4 class 'cred_user_pass'. + * Create credential object from S3 class 'cred_user_pass'. * * @param cred The newly created credential object. * @param allowed_types A bitmask stating which cred types are OK to return. - * @param credentials The S4 class object with credentials. + * @param credentials The S3 class object with credentials. * @return 0 on success, else -1. */ static int git2r_cred_user_pass( @@ -186,13 +203,8 @@ const char *username; const char *password; - username = CHAR(STRING_ELT( - GET_SLOT(credentials, - Rf_install("username")), 0)); - password = CHAR(STRING_ELT( - GET_SLOT(credentials, - Rf_install("password")), 0)); - + username = CHAR(STRING_ELT(git2r_get_list_element(credentials, "username"), 0)); + password = CHAR(STRING_ELT(git2r_get_list_element(credentials, "password"), 0)); if (git_cred_userpass_plaintext_new(cred, username, password)) return -1; @@ -202,6 +214,210 @@ return -1; } +static int git2r_join_str(char** out, const char *str_a, const char *str_b) +{ + int len_a, len_b; + + if (!str_a || !str_b) + return -1; + + len_a = strlen(str_a); + len_b = strlen(str_b); + + *out = malloc(len_a + len_b + 1); + if (!*out) + return -1; + + if (len_a) + memcpy(*out, str_a, len_a); + if (len_b) + memcpy(*out + len_a, str_b, len_b); + (*out)[len_a + len_b] = '\0'; + + return 0; +} + +static int git2r_file_exists(const char *path) +{ +#ifdef WIN32 + struct _stati64 sb; + return _stati64(path, &sb) == 0; +#else + struct stat sb; + return stat(path, &sb) == 0; +#endif +} + +#ifdef WIN32 +static int git2r_expand_key(char** out, const wchar_t *key, const char *ext) +{ + wchar_t wbuf[MAX_PATH]; + char *buf_utf8 = NULL; + DWORD len_wbuf; + int len_utf8; + + *out = NULL; + + if (!key || !ext) + goto on_error; + + /* Expands environment-variable strings and replaces them with the + * values defined for the current user. */ + len_wbuf = ExpandEnvironmentStringsW(key, wbuf, GIT2R_ARRAY_SIZE(wbuf)); + if (!len_wbuf || len_wbuf > GIT2R_ARRAY_SIZE(wbuf)) + goto on_error; + + /* Map wide character string to a new utf8 character string. */ + len_utf8 = WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, wbuf,-1, NULL, 0, NULL, NULL); + if (!len_utf8) + goto on_error; + + buf_utf8 = malloc(len_utf8); + if (!buf_utf8) + goto on_error; + + len_utf8 = WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, wbuf, -1, buf_utf8, len_utf8, NULL, NULL); + if (!len_utf8) + goto on_error; + + if (git2r_join_str(out, buf_utf8, ext)) + goto on_error; + free(buf_utf8); + + if (git2r_file_exists(*out)) + return 0; + +on_error: + free(buf_utf8); + free(*out); + *out = NULL; + + return -1; +} +#else +static int git2r_expand_key(char** out, const char *key, const char *ext) +{ + const char *buf = R_ExpandFileName(key); + + *out = NULL; + + if (!key || !ext) + return -1; + + if (git2r_join_str(out, buf, ext)) + return -1; + + if (git2r_file_exists(*out)) + return 0; + + free(*out); + *out = NULL; + + return -1; +} +#endif + +static int git2r_ssh_key_needs_passphrase(const char *key) +{ + size_t i; + FILE* file = fopen(key, "r"); + + if (file == NULL) + return 0; + + /* Look for "ENCRYPTED" in the first three lines. */ + for (i = 0; i < 3; i++) { + char str[128] = {0}; + if (fgets(str, GIT2R_ARRAY_SIZE(str), file) != NULL) { + if (strstr(str, "ENCRYPTED") != NULL) { + fclose(file); + return 1; + } + } else { + fclose(file); + return 0; + } + } + + fclose(file); + + return 0; +} + +static int git2r_cred_default_ssh_key( + git_cred **cred, + const char *username_from_url) +{ +#ifdef WIN32 + static const wchar_t *key_patterns[3] = + {L"%HOME%\\.ssh\\id_rsa", + L"%HOMEDRIVE%%HOMEPATH%\\.ssh\\id_rsa", + L"%USERPROFILE%\\.ssh\\id_rsa"}; +#else + static const char *key_patterns[1] = {"~/.ssh/id_rsa"}; +#endif + size_t i; + int error = 1; + + /* Find key. */ + for (i = 0; i < GIT2R_ARRAY_SIZE(key_patterns); i++) { + char *private_key = NULL; + char *public_key = NULL; + const char *passphrase = NULL; + SEXP pass, askpass, call; + int nprotect = 0; + + /* Expand key pattern and check if files exists. */ + if (git2r_expand_key(&private_key, key_patterns[i], "") || + git2r_expand_key(&public_key, key_patterns[i], ".pub")) + { + free(private_key); + free(public_key); + continue; + } + + if (git2r_ssh_key_needs_passphrase(private_key)) { + /* Use the R package getPass to ask for the passphrase. */ + PROTECT(pass = Rf_eval(Rf_lang2(Rf_install("getNamespace"), + Rf_ScalarString(Rf_mkChar("getPass"))), + R_GlobalEnv)); + nprotect++; + + PROTECT(call = Rf_lcons( + Rf_findFun(Rf_install("getPass"), pass), + Rf_lcons(Rf_mkString("Enter passphrase: "), + R_NilValue))); + nprotect++; + + PROTECT(askpass = Rf_eval(call, pass)); + nprotect++; + if (git2r_arg_check_string(askpass) == 0) + passphrase = CHAR(STRING_ELT(askpass, 0)); + } + + error = git_cred_ssh_key_new( + cred, + username_from_url, + public_key, + private_key, + passphrase); + + /* Cleanup. */ + free(private_key); + free(public_key); + if (nprotect) + UNPROTECT(nprotect); + + break; + } + + if (error) + return -1; + return 0; +} + /** * Callback if the remote host requires authentication in order to * connect to it @@ -221,36 +437,42 @@ unsigned int allowed_types, void *payload) { - SEXP credentials, class_name; - - GIT_UNUSED(url); + git2r_transfer_data *td; + SEXP credentials; if (!payload) return -1; - credentials = ((git2r_transfer_data*)payload)->credentials; - if (isNull(credentials)) { + td = (git2r_transfer_data*)payload; + credentials = td->credentials; + if (Rf_isNull(credentials)) { if (GIT_CREDTYPE_SSH_KEY & allowed_types) { - if (((git2r_transfer_data*)payload)->ssh_key_agent_tried) - return -1; - ((git2r_transfer_data*)payload)->ssh_key_agent_tried = 1; - if (git_cred_ssh_key_from_agent(cred, username_from_url)) - return -1; - return 0; + if (td->use_ssh_agent) { + /* Try to get credentials from the ssh-agent. */ + td->use_ssh_agent = 0; + if (git_cred_ssh_key_from_agent(cred, username_from_url) == 0) + return 0; + } + + if (td->use_ssh_key) { + /* Try to get credentials from default ssh key. */ + td->use_ssh_key = 0; + if (git2r_cred_default_ssh_key(cred, username_from_url) == 0) + return 0; + } } return -1; } - class_name = getAttrib(credentials, R_ClassSymbol); - if (strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_ssh_key") == 0) { + if (Rf_inherits(credentials, "cred_ssh_key")) { return git2r_cred_ssh_key( cred, username_from_url, allowed_types, credentials); - } else if (strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_env") == 0) { + } else if (Rf_inherits(credentials, "cred_env")) { return git2r_cred_env(cred, allowed_types, credentials); - } else if (strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_token") == 0) { + } else if (Rf_inherits(credentials, "cred_token")) { return git2r_cred_token(cred, allowed_types, credentials); - } else if (strcmp(CHAR(STRING_ELT(class_name, 0)), "cred_user_pass") == 0) { + } else if (Rf_inherits(credentials, "cred_user_pass")) { return git2r_cred_user_pass(cred, allowed_types, credentials); } diff -Nru r-cran-git2r-0.21.0/src/git2r_cred.h r-cran-git2r-0.22.1/src/git2r_cred.h --- r-cran-git2r-0.21.0/src/git2r_cred.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_cred.h 2018-07-10 13:23:34.000000000 +0000 @@ -19,7 +19,7 @@ #ifndef INCLUDE_git2r_cred_h #define INCLUDE_git2r_cred_h -#include "git2.h" +#include int git2r_cred_acquire_cb( git_cred **out, diff -Nru r-cran-git2r-0.21.0/src/git2r_diff.c r-cran-git2r-0.22.1/src/git2r_diff.c --- r-cran-git2r-0.21.0/src/git2r_diff.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_diff.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -19,12 +19,12 @@ #include "git2r_arg.h" #include "git2r_diff.h" #include "git2r_error.h" -#include "git2r_tree.h" #include "git2r_repository.h" +#include "git2r_S3.h" +#include "git2r_tree.h" -#include "git2.h" -#include "buffer.h" -#include "diff.h" +#include +#include #include #include @@ -62,12 +62,12 @@ * @param tree2 The second tree to compare. * @param index Whether to compare to the index. * @param filename Determines where to write the diff. If filename is - * R_NilValue, then the diff is written to a S4 class git_diff + * R_NilValue, then the diff is written to a S3 class git_diff * object. If filename is a character vector of length 0, then the * diff is written to a character vector. If filename is a character * vector of length one with non-NA value, the diff is written to a * file with name filename (the file is overwritten if it exists). - * @return A S4 class git_diff object if filename equals R_NilValue. A + * @return A S3 class git_diff object if filename equals R_NilValue. A * character vector with diff if filename has length 0. Oterwise NULL. */ SEXP git2r_diff(SEXP repo, SEXP tree1, SEXP tree2, SEXP index, SEXP filename) @@ -79,46 +79,52 @@ c_index = LOGICAL(index)[0]; - if (isNull(tree1) && ! c_index) { - if (!isNull(tree2)) + if (Rf_isNull(tree1) && ! c_index) { + if (!Rf_isNull(tree2)) git2r_error(__func__, NULL, git2r_err_diff_arg, NULL); return git2r_diff_index_to_wd(repo, filename); - } else if (isNull(tree1) && c_index) { - if (!isNull(tree2)) + } + + if (Rf_isNull(tree1) && c_index) { + if (!Rf_isNull(tree2)) git2r_error(__func__, NULL, git2r_err_diff_arg, NULL); return git2r_diff_head_to_index(repo, filename); - } else if (!isNull(tree1) && isNull(tree2) && ! c_index) { - if (!isNull(repo)) + } + + if (!Rf_isNull(tree1) && Rf_isNull(tree2) && !c_index) { + if (!Rf_isNull(repo)) git2r_error(__func__, NULL, git2r_err_diff_arg, NULL); return git2r_diff_tree_to_wd(tree1, filename); - } else if (!isNull(tree1) && isNull(tree2) && c_index) { - if (!isNull(repo)) + } + + if (!Rf_isNull(tree1) && Rf_isNull(tree2) && c_index) { + if (!Rf_isNull(repo)) git2r_error(__func__, NULL, git2r_err_diff_arg, NULL); return git2r_diff_tree_to_index(tree1, filename); - } else { - if (!isNull(repo)) - git2r_error(__func__, NULL, git2r_err_diff_arg, NULL); - return git2r_diff_tree_to_tree(tree1, tree2, filename); } + + if (!Rf_isNull(repo)) + git2r_error(__func__, NULL, git2r_err_diff_arg, NULL); + return git2r_diff_tree_to_tree(tree1, tree2, filename); } /** * Create a diff between the repository index and the workdir * directory. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param filename Determines where to write the diff. If filename is - * R_NilValue, then the diff is written to a S4 class git_diff + * R_NilValue, then the diff is written to a S3 class git_diff * object. If filename is a character vector of length 0, then the * diff is written to a character vector. If filename is a character * vector of length one with non-NA value, the diff is written to a * file with name filename (the file is overwritten if it exists). - * @return A S4 class git_diff object if filename equals R_NilValue. A + * @return A S3 class git_diff object if filename equals R_NilValue. A * character vector with diff if filename has length 0. Oterwise NULL. */ SEXP git2r_diff_index_to_wd(SEXP repo, SEXP filename) { - int err, nprotect = 0; + int error, nprotect = 0; git_repository *repository = NULL; git_diff *diff = NULL; SEXP result = R_NilValue; @@ -130,33 +136,31 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_diff_index_to_workdir(&diff, + error = git_diff_index_to_workdir(&diff, repository, /*index=*/ NULL, /*opts=*/ NULL); - if (err) + if (error) goto cleanup; - if (isNull(filename)) { - SEXP s_new = Rf_install("new"); - SEXP s_old = Rf_install("old"); - - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_diff"))); + if (Rf_isNull(filename)) { + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff)); nprotect++; - SET_SLOT(result, s_old, mkString("index")); - SET_SLOT(result, s_new, mkString("workdir")); - err = git2r_diff_format_to_r(diff, result); - } else if (0 == length(filename)) { - git_buf buf = GIT_BUF_INIT; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff)); - err = git_diff_print( - diff, - GIT_DIFF_FORMAT_PATCH, - git_diff_print_callback__to_buf, - &buf); - if (0 == err) { - PROTECT(result = mkString(buf.ptr)); + SET_VECTOR_ELT(result, git2r_S3_item__git_diff__old, Rf_mkString("index")); + + SET_VECTOR_ELT(result, git2r_S3_item__git_diff__new, Rf_mkString("workdir")); + + error = git2r_diff_format_to_r(diff, result); + } else if (0 == Rf_length(filename)) { + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); + + error = git_diff_to_buf(&buf, diff, GIT_DIFF_FORMAT_PATCH); + if (!error) { + PROTECT(result = Rf_mkString(buf.ptr)); nprotect++; } @@ -164,7 +168,7 @@ } else { FILE *fp = fopen(CHAR(STRING_ELT(filename, 0)), "w+"); - err = git_diff_print( + error = git_diff_print( diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_file_handle, @@ -175,16 +179,13 @@ } cleanup: - if (diff) - git_diff_free(diff); - - if (repository) - git_repository_free(repository); + git_diff_free(diff); + git_repository_free(repository); if (nprotect) UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -193,19 +194,19 @@ /** * Create a diff between head and repository index * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param filename Determines where to write the diff. If filename is - * R_NilValue, then the diff is written to a S4 class git_diff + * R_NilValue, then the diff is written to a S3 class git_diff * object. If filename is a character vector of length 0, then the * diff is written to a character vector. If filename is a character * vector of length one with non-NA value, the diff is written to a * file with name filename (the file is overwritten if it exists). - * @return A S4 class git_diff object if filename equals R_NilValue. A + * @return A S3 class git_diff object if filename equals R_NilValue. A * character vector with diff if filename has length 0. Oterwise NULL. */ SEXP git2r_diff_head_to_index(SEXP repo, SEXP filename) { - int err, nprotect = 0; + int error, nprotect = 0; git_repository *repository = NULL; git_diff *diff = NULL; git_object *obj = NULL; @@ -219,43 +220,50 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_revparse_single(&obj, repository, "HEAD^{tree}"); - if (err) + error = git_revparse_single(&obj, repository, "HEAD^{tree}"); + if (error) goto cleanup; - err = git_tree_lookup(&head, repository, git_object_id(obj)); - if (err) + error = git_tree_lookup(&head, repository, git_object_id(obj)); + if (error) goto cleanup; - err = git_diff_tree_to_index( + error = git_diff_tree_to_index( &diff, repository, head, /* index= */ NULL, /* opts = */ NULL); - if (err) + if (error) goto cleanup; - if (isNull(filename)) { - SEXP s_new = Rf_install("new"); - SEXP s_old = Rf_install("old"); - + if (Rf_isNull(filename)) { /* TODO: object instead of HEAD string */ - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_diff"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff)); nprotect++; - SET_SLOT(result, s_old, mkString("HEAD")); - SET_SLOT(result, s_new, mkString("index")); - err = git2r_diff_format_to_r(diff, result); - } else if (0 == length(filename)) { - git_buf buf = GIT_BUF_INIT; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff)); + + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__old, + Rf_mkString("HEAD")); + + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__new, + Rf_mkString("index")); + + error = git2r_diff_format_to_r(diff, result); + } else if (0 == Rf_length(filename)) { + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); - err = git_diff_print( + error = git_diff_to_buf( + &buf, diff, - GIT_DIFF_FORMAT_PATCH, - git_diff_print_callback__to_buf, - &buf); - if (0 == err) { - PROTECT(result = mkString(buf.ptr)); + GIT_DIFF_FORMAT_PATCH); + if (!error) { + PROTECT(result = Rf_mkString(buf.ptr)); nprotect++; } @@ -263,7 +271,7 @@ } else { FILE *fp = fopen(CHAR(STRING_ELT(filename, 0)), "w+"); - err = git_diff_print( + error = git_diff_print( diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_file_handle, @@ -274,22 +282,15 @@ } cleanup: - if (head) - git_tree_free(head); - - if (obj) - git_object_free(obj); - - if (diff) - git_diff_free(diff); - - if (repository) - git_repository_free(repository); + git_tree_free(head); + git_object_free(obj); + git_diff_free(diff); + git_repository_free(repository); if (nprotect) UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -298,19 +299,19 @@ /** * Create a diff between a tree and the working directory * - * @param tree S4 class git_tree + * @param tree S3 class git_tree * @param filename Determines where to write the diff. If filename is - * R_NilValue, then the diff is written to a S4 class git_diff + * R_NilValue, then the diff is written to a S3 class git_diff * object. If filename is a character vector of length 0, then the * diff is written to a character vector. If filename is a character * vector of length one with non-NA value, the diff is written to a * file with name filename (the file is overwritten if it exists). - * @return A S4 class git_diff object if filename equals R_NilValue. A + * @return A S3 class git_diff object if filename equals R_NilValue. A * character vector with diff if filename has length 0. Oterwise NULL. */ SEXP git2r_diff_tree_to_wd(SEXP tree, SEXP filename) { - int err, nprotect = 0; + int error, nprotect = 0; git_repository *repository = NULL; git_diff *diff = NULL; git_object *obj = NULL; @@ -324,42 +325,50 @@ if (git2r_arg_check_filename(filename)) git2r_error(__func__, NULL, "'filename'", git2r_err_filename_arg); - repo = GET_SLOT(tree, Rf_install("repo")); + repo = git2r_get_list_element(tree, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(tree, Rf_install("sha")); - err = git_revparse_single(&obj, repository, CHAR(STRING_ELT(sha, 0))); - if (err) + sha = git2r_get_list_element(tree, "sha"); + error = git_revparse_single(&obj, repository, CHAR(STRING_ELT(sha, 0))); + if (error) goto cleanup; - err = git_tree_lookup(&c_tree, repository, git_object_id(obj)); - if (err) + error = git_tree_lookup(&c_tree, repository, git_object_id(obj)); + if (error) goto cleanup; - err = git_diff_tree_to_workdir(&diff, repository, c_tree, /* opts = */ NULL); - if (err) + error = git_diff_tree_to_workdir(&diff, repository, c_tree, /* opts = */ NULL); + if (error) goto cleanup; - if (isNull(filename)) { - SEXP s_new = Rf_install("new"); - - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_diff"))); + if (Rf_isNull(filename)) { + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff)); nprotect++; - SET_SLOT(result, Rf_install("old"), tree); - SET_SLOT(result, s_new, mkString("workdir")); - err = git2r_diff_format_to_r(diff, result); - } else if (0 == length(filename)) { - git_buf buf = GIT_BUF_INIT; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff)); - err = git_diff_print( + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__old, + tree); + + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__new, + Rf_mkString("workdir")); + + error = git2r_diff_format_to_r(diff, result); + } else if (0 == Rf_length(filename)) { + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); + + error = git_diff_to_buf( + &buf, diff, - GIT_DIFF_FORMAT_PATCH, - git_diff_print_callback__to_buf, - &buf); - if (0 == err) { - PROTECT(result = mkString(buf.ptr)); + GIT_DIFF_FORMAT_PATCH); + if (!error) { + PROTECT(result = Rf_mkString(buf.ptr)); nprotect++; } @@ -367,7 +376,7 @@ } else { FILE *fp = fopen(CHAR(STRING_ELT(filename, 0)), "w+"); - err = git_diff_print( + error = git_diff_print( diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_file_handle, @@ -378,22 +387,15 @@ } cleanup: - if (diff) - git_diff_free(diff); - - if (c_tree) - git_tree_free(c_tree); - - if (obj) - git_object_free(obj); - - if (repository) - git_repository_free(repository); + git_diff_free(diff); + git_tree_free(c_tree); + git_object_free(obj); + git_repository_free(repository); if (nprotect) UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -402,19 +404,19 @@ /** * Create a diff between a tree and repository index * - * @param tree S4 class git_tree + * @param tree S3 class git_tree * @param filename Determines where to write the diff. If filename is - * R_NilValue, then the diff is written to a S4 class git_diff + * R_NilValue, then the diff is written to a S3 class git_diff * object. If filename is a character vector of length 0, then the * diff is written to a character vector. If filename is a character * vector of length one with non-NA value, the diff is written to a * file with name filename (the file is overwritten if it exists). - * @return A S4 class git_diff object if filename equals R_NilValue. A + * @return A S3 class git_diff object if filename equals R_NilValue. A * character vector with diff if filename has length 0. Oterwise NULL. */ SEXP git2r_diff_tree_to_index(SEXP tree, SEXP filename) { - int err, nprotect = 0; + int error, nprotect = 0; git_repository *repository = NULL; git_diff *diff = NULL; git_object *obj = NULL; @@ -428,47 +430,55 @@ if (git2r_arg_check_filename(filename)) git2r_error(__func__, NULL, "'filename'", git2r_err_filename_arg); - repo = GET_SLOT(tree, Rf_install("repo")); + repo = git2r_get_list_element(tree, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(tree, Rf_install("sha")); - err = git_revparse_single(&obj, repository, CHAR(STRING_ELT(sha, 0))); - if (err) + sha = git2r_get_list_element(tree, "sha"); + error = git_revparse_single(&obj, repository, CHAR(STRING_ELT(sha, 0))); + if (error) goto cleanup; - err = git_tree_lookup(&c_tree, repository, git_object_id(obj)); - if (err) + error = git_tree_lookup(&c_tree, repository, git_object_id(obj)); + if (error) goto cleanup; - err = git_diff_tree_to_index( + error = git_diff_tree_to_index( &diff, repository, c_tree, /* index= */ NULL, /* opts= */ NULL); - if (err) + if (error) goto cleanup; - if (isNull(filename)) { - SEXP s_new = Rf_install("new"); - - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_diff"))); + if (Rf_isNull(filename)) { + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff)); nprotect++; - SET_SLOT(result, Rf_install("old"), tree); - SET_SLOT(result, s_new, mkString("index")); - err = git2r_diff_format_to_r(diff, result); - } else if (0 == length(filename)) { - git_buf buf = GIT_BUF_INIT; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff)); + + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__old, + tree); + + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__new, + Rf_mkString("index")); + + error = git2r_diff_format_to_r(diff, result); + } else if (0 == Rf_length(filename)) { + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); - err = git_diff_print( + error = git_diff_to_buf( + &buf, diff, - GIT_DIFF_FORMAT_PATCH, - git_diff_print_callback__to_buf, - &buf); - if (0 == err) { - PROTECT(result = mkString(buf.ptr)); + GIT_DIFF_FORMAT_PATCH); + if (!error) { + PROTECT(result = Rf_mkString(buf.ptr)); nprotect++; } @@ -476,7 +486,7 @@ } else { FILE *fp = fopen(CHAR(STRING_ELT(filename, 0)), "w+"); - err = git_diff_print( + error = git_diff_print( diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_file_handle, @@ -487,22 +497,15 @@ } cleanup: - if (diff) - git_diff_free(diff); - - if (c_tree) - git_tree_free(c_tree); - - if (obj) - git_object_free(obj); - - if (repository) - git_repository_free(repository); + git_diff_free(diff); + git_tree_free(c_tree); + git_object_free(obj); + git_repository_free(repository); if (nprotect) UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -511,26 +514,26 @@ /** * Create a diff with the difference between two tree objects * - * @param tree1 S4 class git_tree - * @param tree2 S4 class git_tree + * @param tree1 S3 class git_tree + * @param tree2 S3 class git_tree * @param filename Determines where to write the diff. If filename is - * R_NilValue, then the diff is written to a S4 class git_diff + * R_NilValue, then the diff is written to a S3 class git_diff * object. If filename is a character vector of length 0, then the * diff is written to a character vector. If filename is a character * vector of length one with non-NA value, the diff is written to a * file with name filename (the file is overwritten if it exists). - * @return A S4 class git_diff object if filename equals R_NilValue. A + * @return A S3 class git_diff object if filename equals R_NilValue. A * character vector with diff if filename has length 0. Oterwise NULL. */ SEXP git2r_diff_tree_to_tree(SEXP tree1, SEXP tree2, SEXP filename) { - int err, nprotect = 0; + int error, nprotect = 0; git_repository *repository = NULL; git_diff *diff = NULL; git_object *obj1 = NULL, *obj2 = NULL; git_tree *c_tree1 = NULL, *c_tree2 = NULL; SEXP result = R_NilValue; - SEXP repo; + SEXP tree1_repo, tree2_repo; SEXP sha1, sha2; if (git2r_arg_check_tree(tree1)) @@ -540,55 +543,68 @@ if (git2r_arg_check_filename(filename)) git2r_error(__func__, NULL, "'filename'", git2r_err_filename_arg); - /* We already checked that tree2 is from the same repo, in R */ - repo = GET_SLOT(tree1, Rf_install("repo")); - repository = git2r_repository_open(repo); + tree1_repo = git2r_get_list_element(tree1, "repo"); + tree2_repo = git2r_get_list_element(tree2, "repo"); + if (git2r_arg_check_same_repo(tree1_repo, tree2_repo)) + git2r_error(__func__, NULL, "'tree1' and 'tree2' not from same repository", NULL); + + repository = git2r_repository_open(tree1_repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha1 = GET_SLOT(tree1, Rf_install("sha")); - err = git_revparse_single(&obj1, repository, CHAR(STRING_ELT(sha1, 0))); - if (err) + sha1 = git2r_get_list_element(tree1, "sha"); + error = git_revparse_single(&obj1, repository, CHAR(STRING_ELT(sha1, 0))); + if (error) goto cleanup; - sha2 = GET_SLOT(tree2, Rf_install("sha")); - err = git_revparse_single(&obj2, repository, CHAR(STRING_ELT(sha2, 0))); - if (err) + sha2 = git2r_get_list_element(tree2, "sha"); + error = git_revparse_single(&obj2, repository, CHAR(STRING_ELT(sha2, 0))); + if (error) goto cleanup; - err = git_tree_lookup(&c_tree1, repository, git_object_id(obj1)); - if (err) + error = git_tree_lookup(&c_tree1, repository, git_object_id(obj1)); + if (error) goto cleanup; - err = git_tree_lookup(&c_tree2, repository, git_object_id(obj2)); - if (err) + error = git_tree_lookup(&c_tree2, repository, git_object_id(obj2)); + if (error) goto cleanup; - err = git_diff_tree_to_tree( + error = git_diff_tree_to_tree( &diff, repository, c_tree1, c_tree2, /* opts= */ NULL); - if (err) + if (error) goto cleanup; - if (isNull(filename)) { - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_diff"))); + if (Rf_isNull(filename)) { + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff)); nprotect++; - SET_SLOT(result, Rf_install("old"), tree1); - SET_SLOT(result, Rf_install("new"), tree2); - err = git2r_diff_format_to_r(diff, result); - } else if (0 == length(filename)) { - git_buf buf = GIT_BUF_INIT; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff)); - err = git_diff_print( + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__old, + tree1); + + SET_VECTOR_ELT( + result, + git2r_S3_item__git_diff__new, + tree2); + + error = git2r_diff_format_to_r(diff, result); + } else if (0 == Rf_length(filename)) { + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); + + error = git_diff_to_buf( + &buf, diff, - GIT_DIFF_FORMAT_PATCH, - git_diff_print_callback__to_buf, - &buf); - if (0 == err) { - PROTECT(result = mkString(buf.ptr)); + GIT_DIFF_FORMAT_PATCH); + if (!error) { + PROTECT(result = Rf_mkString(buf.ptr)); nprotect++; } @@ -596,7 +612,7 @@ } else { FILE *fp = fopen(CHAR(STRING_ELT(filename, 0)), "w+"); - err = git_diff_print( + error = git_diff_print( diff, GIT_DIFF_FORMAT_PATCH, git_diff_print_callback__to_file_handle, @@ -607,28 +623,17 @@ } cleanup: - if (diff) - git_diff_free(diff); - - if (c_tree1) - git_tree_free(c_tree1); - - if (c_tree2) - git_tree_free(c_tree2); - - if (obj1) - git_object_free(obj1); - - if (obj2) - git_object_free(obj2); - - if (repository) - git_repository_free(repository); + git_diff_free(diff); + git_tree_free(c_tree1); + git_tree_free(c_tree2); + git_object_free(obj1); + git_object_free(obj2); + git_repository_free(repository); if (nprotect) UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -659,9 +664,6 @@ { git2r_diff_count_payload *n = payload; - GIT_UNUSED(delta); - GIT_UNUSED(progress); - n->num_files += 1; n->num_hunks = n->num_lines = 0; return 0; @@ -681,9 +683,6 @@ { git2r_diff_count_payload *n = payload; - GIT_UNUSED(delta); - GIT_UNUSED(hunk); - n->num_hunks += 1; if (n->num_hunks > n->max_hunks) { n->max_hunks = n->num_hunks; } n->num_lines = 0; @@ -707,12 +706,9 @@ { git2r_diff_count_payload *n = payload; - GIT_UNUSED(delta); - GIT_UNUSED(hunk); - GIT_UNUSED(line); - n->num_lines += 1; - if (n->num_lines > n->max_lines) { n->max_lines = n->num_lines; } + if (n->num_lines > n->max_lines) + n->max_lines = n->num_lines; return 0; } @@ -731,17 +727,17 @@ size_t *max_hunks, size_t *max_lines) { - int err; + int error; git2r_diff_count_payload n = { 0, 0, 0 }; - err = git_diff_foreach(diff, + error = git_diff_foreach(diff, git2r_diff_count_file_cb, /* binary_cb */ NULL, git2r_diff_count_hunk_cb, git2r_diff_count_line_cb, /* payload= */ (void*) &n); - if (err) + if (error) return -1; *num_files = n.num_files; @@ -785,8 +781,6 @@ { git2r_diff_payload *p = (git2r_diff_payload *) payload; - GIT_UNUSED(progress); - /* Save previous hunk's lines in hunk_tmp, we just call the hunk callback, with a NULL hunk */ git2r_diff_get_hunk_cb(delta, /* hunk= */ 0, payload); @@ -795,13 +789,12 @@ temporary storage. */ if (p->file_ptr != 0) { SEXP hunks; - SEXP s_hunks = Rf_install("hunks"); size_t len=p->hunk_ptr, i; - SET_SLOT( - VECTOR_ELT(p->result, p->file_ptr-1), - s_hunks, - hunks = allocVector(VECSXP, p->hunk_ptr)); + SET_VECTOR_ELT( + VECTOR_ELT(p->result, p->file_ptr - 1), + git2r_S3_item__git_diff_file__hunks, + hunks = Rf_allocVector(VECSXP, p->hunk_ptr)); for (i = 0; i < len ; i++) SET_VECTOR_ELT(hunks, i, VECTOR_ELT(p->hunk_tmp, i)); } @@ -809,14 +802,23 @@ /* OK, ready for next file, if any */ if (delta) { SEXP file_obj; - SEXP s_new_file = Rf_install("new_file"); - SEXP s_old_file = Rf_install("old_file"); - PROTECT(file_obj = NEW_OBJECT(MAKE_CLASS("git_diff_file"))); - SET_VECTOR_ELT(p->result, p->file_ptr, file_obj); - SET_SLOT(file_obj, s_old_file, mkString(delta->old_file.path)); - SET_SLOT(file_obj, s_new_file, mkString(delta->new_file.path)); - UNPROTECT(1); + SET_VECTOR_ELT( + p->result, + p->file_ptr, + file_obj = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff_file)); + Rf_setAttrib(file_obj, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff_file)); + + SET_VECTOR_ELT( + file_obj, + git2r_S3_item__git_diff_file__old_file, + Rf_mkString(delta->old_file.path)); + + SET_VECTOR_ELT( + file_obj, + git2r_S3_item__git_diff_file__new_file, + Rf_mkString(delta->new_file.path)); p->file_ptr++; p->hunk_ptr = 0; @@ -843,39 +845,55 @@ { git2r_diff_payload *p = (git2r_diff_payload *) payload; - GIT_UNUSED(delta); - /* Save previous hunk's lines in hunk_tmp, from the line_tmp temporary storage. */ if (p->hunk_ptr != 0) { SEXP lines; size_t len=p->line_ptr, i; - SEXP s_lines = Rf_install("lines"); - PROTECT(lines = allocVector(VECSXP, p->line_ptr)); - SET_SLOT(VECTOR_ELT(p->hunk_tmp, p->hunk_ptr-1), s_lines, lines); + SET_VECTOR_ELT( + VECTOR_ELT(p->hunk_tmp, p->hunk_ptr-1), + git2r_S3_item__git_diff_hunk__lines, + lines = Rf_allocVector(VECSXP, p->line_ptr)); for (i = 0; i < len; i++) SET_VECTOR_ELT(lines, i, VECTOR_ELT(p->line_tmp, i)); - UNPROTECT(1); } /* OK, ready for the next hunk, if any */ if (hunk) { SEXP hunk_obj; - SEXP s_old_start = Rf_install("old_start"); - SEXP s_old_lines = Rf_install("old_lines"); - SEXP s_new_start = Rf_install("new_start"); - SEXP s_new_lines = Rf_install("new_lines"); - SEXP s_header = Rf_install("header"); - - PROTECT(hunk_obj = NEW_OBJECT(MAKE_CLASS("git_diff_hunk"))); - SET_VECTOR_ELT(p->hunk_tmp, p->hunk_ptr, hunk_obj); - SET_SLOT(hunk_obj, s_old_start, ScalarInteger(hunk->old_start)); - SET_SLOT(hunk_obj, s_old_lines, ScalarInteger(hunk->old_lines)); - SET_SLOT(hunk_obj, s_new_start, ScalarInteger(hunk->new_start)); - SET_SLOT(hunk_obj, s_new_lines, ScalarInteger(hunk->new_lines)); - SET_SLOT(hunk_obj, s_header, mkString(hunk->header)); - UNPROTECT(1); + + SET_VECTOR_ELT( + p->hunk_tmp, + p->hunk_ptr, + hunk_obj = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff_hunk)); + Rf_setAttrib(hunk_obj, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff_hunk)); + + SET_VECTOR_ELT( + hunk_obj, + git2r_S3_item__git_diff_hunk__old_start, + Rf_ScalarInteger(hunk->old_start)); + + SET_VECTOR_ELT( + hunk_obj, + git2r_S3_item__git_diff_hunk__old_lines, + Rf_ScalarInteger(hunk->old_lines)); + + SET_VECTOR_ELT( + hunk_obj, + git2r_S3_item__git_diff_hunk__new_start, + Rf_ScalarInteger(hunk->new_start)); + + SET_VECTOR_ELT( + hunk_obj, + git2r_S3_item__git_diff_hunk__new_lines, + Rf_ScalarInteger(hunk->new_lines)); + + SET_VECTOR_ELT( + hunk_obj, + git2r_S3_item__git_diff_hunk__header, + Rf_mkString(hunk->header)); p->hunk_ptr += 1; p->line_ptr = 0; @@ -906,35 +924,47 @@ static char short_buffer[200]; char *buffer = short_buffer; SEXP line_obj; - SEXP s_origin = Rf_install("origin"); - SEXP s_old_lineno = Rf_install("old_lineno"); - SEXP s_new_lineno = Rf_install("new_lineno"); - SEXP s_num_lines = Rf_install("num_lines"); - SEXP s_content = Rf_install("content"); - - GIT_UNUSED(delta); - GIT_UNUSED(hunk); - - PROTECT(line_obj = NEW_OBJECT(MAKE_CLASS("git_diff_line"))); - SET_VECTOR_ELT(p->line_tmp, p->line_ptr++, line_obj); - - SET_SLOT(line_obj, s_origin, ScalarInteger(line->origin)); - SET_SLOT(line_obj, s_old_lineno, ScalarInteger(line->old_lineno)); - SET_SLOT(line_obj, s_new_lineno, ScalarInteger(line->new_lineno)); - SET_SLOT(line_obj, s_num_lines, ScalarInteger(line->num_lines)); + + SET_VECTOR_ELT( + p->line_tmp, + p->line_ptr++, + line_obj = Rf_mkNamed(VECSXP, git2r_S3_items__git_diff_line)); + Rf_setAttrib(line_obj, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_diff_line)); + + SET_VECTOR_ELT( + line_obj, + git2r_S3_item__git_diff_line__origin, + Rf_ScalarInteger(line->origin)); + + SET_VECTOR_ELT( + line_obj, + git2r_S3_item__git_diff_line__old_lineno, + Rf_ScalarInteger(line->old_lineno)); + + SET_VECTOR_ELT( + line_obj, + git2r_S3_item__git_diff_line__new_lineno, + Rf_ScalarInteger(line->new_lineno)); + + SET_VECTOR_ELT( + line_obj, + git2r_S3_item__git_diff_line__num_lines, + Rf_ScalarInteger(line->num_lines)); if (line->content_len > sizeof(buffer)) buffer = malloc(line->content_len+1); memcpy(buffer, line->content, line->content_len); buffer[line->content_len] = 0; - SET_SLOT(line_obj, s_content, mkString(buffer)); + SET_VECTOR_ELT( + line_obj, + git2r_S3_item__git_diff_line__content, + Rf_mkString(buffer)); if (buffer != short_buffer) free(buffer); - UNPROTECT(1); - return 0; } @@ -953,12 +983,12 @@ * list that we use for temporary storage. * * @param diff Pointer to the diff - * @param dest The S4 class git_diff to hold the formated diff + * @param dest The S3 class git_diff to hold the formated diff * @return 0 if OK, else error code */ int git2r_diff_format_to_r(git_diff *diff, SEXP dest) { - int err; + int error, nprotect = 0; git2r_diff_payload payload = { /* result= */ R_NilValue, /* hunk_tmp= */ R_NilValue, /* line_tmp= */ R_NilValue, @@ -968,32 +998,37 @@ size_t num_files, max_hunks, max_lines; - err = git2r_diff_count(diff, &num_files, &max_hunks, &max_lines); + error = git2r_diff_count(diff, &num_files, &max_hunks, &max_lines); - if (err) - return err; + if (error) + return error; - PROTECT(payload.result = allocVector(VECSXP, num_files)); - SET_SLOT(dest, Rf_install("files"), payload.result); - PROTECT(payload.hunk_tmp = allocVector(VECSXP, max_hunks)); - PROTECT(payload.line_tmp = allocVector(VECSXP, max_lines)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_diff__files, + payload.result = Rf_allocVector(VECSXP, num_files)); + PROTECT(payload.hunk_tmp = Rf_allocVector(VECSXP, max_hunks)); + nprotect++; + PROTECT(payload.line_tmp = Rf_allocVector(VECSXP, max_lines)); + nprotect++; - err = git_diff_foreach( + error = git_diff_foreach( diff, git2r_diff_get_file_cb, /* binary_cb */ NULL, git2r_diff_get_hunk_cb, git2r_diff_get_line_cb, &payload); - if (GIT_OK == err) { + if (!error) { /* Need to call them once more, to put in the last lines/hunks/files. */ - err = git2r_diff_get_file_cb( + error = git2r_diff_get_file_cb( /* delta= */ NULL, /* progress= */ 100, &payload); } - UNPROTECT(3); + if (nprotect) + UNPROTECT(nprotect); - return err; + return error; } diff -Nru r-cran-git2r-0.21.0/src/git2r_diff.h r-cran-git2r-0.22.1/src/git2r_diff.h --- r-cran-git2r-0.21.0/src/git2r_diff.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_diff.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -19,10 +19,6 @@ #ifndef INCLUDE_git2r_diff_h #define INCLUDE_git2r_diff_h -#include - -#include "git2.h" - SEXP git2r_diff(SEXP repo, SEXP tree1, SEXP tree2, SEXP index, SEXP filename); #endif diff -Nru r-cran-git2r-0.21.0/src/git2r_error.c r-cran-git2r-0.22.1/src/git2r_error.c --- r-cran-git2r-0.21.0/src/git2r_error.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_error.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -17,7 +17,7 @@ */ #include -#include "git2.h" +#include /** * Error messages @@ -45,17 +45,19 @@ * Error messages specific to argument checking */ const char git2r_err_blob_arg[] = - "must be a S4 class git_blob"; + "must be an S3 class git_blob"; const char git2r_err_branch_arg[] = - "must be a S4 class git_branch"; + "must be an S3 class git_branch"; const char git2r_err_commit_arg[] = - "must be a S4 class git_commit"; + "must be an S3 class git_commit"; +const char git2r_err_commit_stash_arg[] = + "must be an S3 class git_commit or an S3 class git_stash"; const char git2r_err_credentials_arg[] = - "must be a S4 class with credentials"; + "must be an S3 class with credentials"; const char git2r_err_diff_arg[] = "Invalid diff parameters"; const char git2r_err_fetch_heads_arg[] = - "must be a list of S4 git_fetch_head objects"; + "must be a list of S3 git_fetch_head objects"; const char git2r_err_filename_arg[] = "must be either 1) NULL, or 2) a character vector of length 0 or 3) a character vector of length 1 and nchar > 0"; const char git2r_err_sha_arg[] = @@ -69,17 +71,17 @@ const char git2r_err_logical_arg[] = "must be logical vector of length one with non NA value"; const char git2r_err_note_arg[] = - "must be a S4 class git_note"; + "must be an S3 class git_note"; const char git2r_err_signature_arg[] = - "must be a S4 class git_signature"; + "must be an S3 class git_signature"; const char git2r_err_string_arg[] = "must be a character vector of length one with non NA value"; const char git2r_err_string_vec_arg[] = "must be a character vector"; const char git2r_err_tag_arg[] = - "must be a S4 class git_tag"; + "must be an S3 class git_tag"; const char git2r_err_tree_arg[] = - "must be a S4 class git_tree"; + "must be an S3 class git_tree"; /** * Raise error diff -Nru r-cran-git2r-0.21.0/src/git2r_error.h r-cran-git2r-0.22.1/src/git2r_error.h --- r-cran-git2r-0.21.0/src/git2r_error.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_error.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -19,7 +19,7 @@ #ifndef INCLUDE_git2r_error_h #define INCLUDE_git2r_error_h -#include "git2.h" +#include /** * Error messages @@ -47,6 +47,7 @@ extern const char git2r_err_blob_arg[]; extern const char git2r_err_branch_arg[]; extern const char git2r_err_commit_arg[]; +extern const char git2r_err_commit_stash_arg[]; extern const char git2r_err_credentials_arg[]; extern const char git2r_err_diff_arg[]; extern const char git2r_err_fetch_heads_arg[]; diff -Nru r-cran-git2r-0.21.0/src/git2r_graph.c r-cran-git2r-0.22.1/src/git2r_graph.c --- r-cran-git2r-0.21.0/src/git2r_graph.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_graph.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,13 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" #include "git2r_oid.h" #include "git2r_repository.h" +#include "git2r_S3.h" /** * Count the number of unique commits between two commit objects @@ -35,11 +35,11 @@ SEXP git2r_graph_ahead_behind(SEXP local, SEXP upstream) { size_t ahead, behind; - int err; + int error, nprotect = 0; SEXP result = R_NilValue; - SEXP slot; - git_oid local_oid; - git_oid upstream_oid; + SEXP local_repo, local_sha; + SEXP upstream_repo, upstream_sha; + git_oid local_oid, upstream_oid; git_repository *repository = NULL; if (git2r_arg_check_commit(local)) @@ -47,34 +47,38 @@ if (git2r_arg_check_commit(upstream)) git2r_error(__func__, NULL, "'upstream'", git2r_err_commit_arg); - slot = GET_SLOT(local, Rf_install("repo")); - repository = git2r_repository_open(slot); + local_repo = git2r_get_list_element(local, "repo"); + upstream_repo = git2r_get_list_element(upstream, "repo"); + if (git2r_arg_check_same_repo(local_repo, upstream_repo)) + git2r_error(__func__, NULL, "'local' and 'upstream' not from same repository", NULL); + + repository = git2r_repository_open(local_repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - slot = GET_SLOT(local, Rf_install("sha")); - git2r_oid_from_sha_sexp(slot, &local_oid); + local_sha = git2r_get_list_element(local, "sha"); + git2r_oid_from_sha_sexp(local_sha, &local_oid); - slot = GET_SLOT(upstream, Rf_install("sha")); - git2r_oid_from_sha_sexp(slot, &upstream_oid); + upstream_sha = git2r_get_list_element(upstream, "sha"); + git2r_oid_from_sha_sexp(upstream_sha, &upstream_oid); - err = git_graph_ahead_behind(&ahead, &behind, repository, &local_oid, + error = git_graph_ahead_behind(&ahead, &behind, repository, &local_oid, &upstream_oid); - if (err) + if (error) goto cleanup; - PROTECT(result = allocVector(INTSXP, 2)); + PROTECT(result = Rf_allocVector(INTSXP, 2)); + nprotect++; INTEGER(result)[0] = ahead; INTEGER(result)[1] = behind; cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -89,11 +93,10 @@ */ SEXP git2r_graph_descendant_of(SEXP commit, SEXP ancestor) { - int err; - SEXP slot; - SEXP result = R_NilValue; - git_oid commit_oid; - git_oid ancestor_oid; + int error, descendant_of = 0; + SEXP commit_repo, commit_sha; + SEXP ancestor_repo, ancestor_sha; + git_oid commit_oid, ancestor_oid; git_repository *repository = NULL; if (git2r_arg_check_commit(commit)) @@ -101,34 +104,32 @@ if (git2r_arg_check_commit(ancestor)) git2r_error(__func__, NULL, "'ancestor'", git2r_err_commit_arg); - slot = GET_SLOT(commit, Rf_install("repo")); - repository = git2r_repository_open(slot); + commit_repo = git2r_get_list_element(commit, "repo"); + ancestor_repo = git2r_get_list_element(ancestor, "repo"); + if (git2r_arg_check_same_repo(commit_repo, ancestor_repo)) + git2r_error(__func__, NULL, "'commit' and 'ancestor' not from same repository", NULL); + + repository = git2r_repository_open(commit_repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - slot = GET_SLOT(commit, Rf_install("sha")); - git2r_oid_from_sha_sexp(slot, &commit_oid); + commit_sha = git2r_get_list_element(commit, "sha"); + git2r_oid_from_sha_sexp(commit_sha, &commit_oid); - slot = GET_SLOT(ancestor, Rf_install("sha")); - git2r_oid_from_sha_sexp(slot, &ancestor_oid); + ancestor_sha = git2r_get_list_element(ancestor, "sha"); + git2r_oid_from_sha_sexp(ancestor_sha, &ancestor_oid); - err = git_graph_descendant_of(repository, &commit_oid, &ancestor_oid); - if (0 > err || 1 < err) + error = git_graph_descendant_of(repository, &commit_oid, &ancestor_oid); + if (0 > error || 1 < error) goto cleanup; - - PROTECT(result = allocVector(LGLSXP, 1)); - LOGICAL(result)[0] = err; - err = GIT_OK; + descendant_of = error; + error = 0; cleanup: - if (repository) - git_repository_free(repository); - - if (!isNull(result)) - UNPROTECT(1); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); - return result; + return Rf_ScalarLogical(descendant_of); } diff -Nru r-cran-git2r-0.21.0/src/git2r_index.c r-cran-git2r-0.22.1/src/git2r_index.c --- r-cran-git2r-0.21.0/src/git2r_index.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_index.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2016 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" @@ -27,14 +27,14 @@ * Add or update index entries matching files in the working * directory. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param path array of path patterns * @param force if TRUE, add ignored files. * @return R_NilValue */ SEXP git2r_index_add_all(SEXP repo, SEXP path, SEXP force) { - int err = GIT_OK; + int error = 0; unsigned int flags = 0; git_strarray pathspec = {0}; git_index *index = NULL; @@ -49,34 +49,29 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_copy_string_vec(&pathspec, path); - if (err || !pathspec.count) + error = git2r_copy_string_vec(&pathspec, path); + if (error || !pathspec.count) goto cleanup; - err = git_repository_index(&index, repository); - if (err) + error = git_repository_index(&index, repository); + if (error) goto cleanup; if (LOGICAL(force)[0]) flags |= GIT_INDEX_ADD_FORCE; - err = git_index_add_all(index, &pathspec, flags, NULL, NULL); - if (err) + error = git_index_add_all(index, &pathspec, flags, NULL, NULL); + if (error) goto cleanup; - err = git_index_write(index); + error = git_index_write(index); cleanup: - if (pathspec.strings) - free(pathspec.strings); + free(pathspec.strings); + git_index_free(index); + git_repository_free(repository); - if (index) - git_index_free(index); - - if (repository) - git_repository_free(repository); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -86,13 +81,13 @@ * Remove an index entry corresponding to a file relative to the * repository's working folder. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param path array of path patterns * @return R_NilValue */ SEXP git2r_index_remove_bypath(SEXP repo, SEXP path) { - int err; + int error = 0; size_t i, len; git_index *index = NULL; git_repository *repository = NULL; @@ -100,33 +95,33 @@ if (git2r_arg_check_string_vec(path)) git2r_error(__func__, NULL, "'path'", git2r_err_string_vec_arg); + len = Rf_length(path); + if (!len) + goto cleanup; + repository= git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_repository_index(&index, repository); - if (err) + error = git_repository_index(&index, repository); + if (error) goto cleanup; - len = length(path); for (i = 0; i < len; i++) { if (NA_STRING != STRING_ELT(path, i)) { - err = git_index_remove_bypath(index, CHAR(STRING_ELT(path, i))); - if (err) + error = git_index_remove_bypath(index, CHAR(STRING_ELT(path, i))); + if (error) goto cleanup; } } - err = git_index_write(index); + error = git_index_write(index); cleanup: - if (index) - git_index_free(index); - - if (repository) - git_repository_free(repository); + git_index_free(index); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; diff -Nru r-cran-git2r-0.21.0/src/git2r_libgit2.c r-cran-git2r-0.22.1/src/git2r_libgit2.c --- r-cran-git2r-0.21.0/src/git2r_libgit2.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_libgit2.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" #include "git2r_libgit2.h" @@ -32,26 +32,26 @@ int value; value = git_libgit2_features(); - PROTECT(features = allocVector(VECSXP, 3)); - setAttrib(features, R_NamesSymbol, names = allocVector(STRSXP, 3)); + PROTECT(features = Rf_allocVector(VECSXP, 3)); + Rf_setAttrib(features, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3)); - SET_STRING_ELT(names, 0, mkChar("threads")); + SET_STRING_ELT(names, 0, Rf_mkChar("threads")); if (value & GIT_FEATURE_THREADS) - SET_VECTOR_ELT(features, 0, ScalarLogical(1)); + SET_VECTOR_ELT(features, 0, Rf_ScalarLogical(1)); else - SET_VECTOR_ELT(features, 0, ScalarLogical(0)); + SET_VECTOR_ELT(features, 0, Rf_ScalarLogical(0)); - SET_STRING_ELT(names, 1, mkChar("https")); + SET_STRING_ELT(names, 1, Rf_mkChar("https")); if (value & GIT_FEATURE_HTTPS) - SET_VECTOR_ELT(features, 1, ScalarLogical(1)); + SET_VECTOR_ELT(features, 1, Rf_ScalarLogical(1)); else - SET_VECTOR_ELT(features, 1, ScalarLogical(0)); + SET_VECTOR_ELT(features, 1, Rf_ScalarLogical(0)); - SET_STRING_ELT(names, 2, mkChar("ssh")); + SET_STRING_ELT(names, 2, Rf_mkChar("ssh")); if (value & GIT_FEATURE_SSH) - SET_VECTOR_ELT(features, 2, ScalarLogical(1)); + SET_VECTOR_ELT(features, 2, Rf_ScalarLogical(1)); else - SET_VECTOR_ELT(features, 2, ScalarLogical(0)); + SET_VECTOR_ELT(features, 2, Rf_ScalarLogical(0)); UNPROTECT(1); @@ -69,14 +69,14 @@ int major, minor, rev; git_libgit2_version(&major, &minor, &rev); - PROTECT(version = allocVector(VECSXP, 3)); - setAttrib(version, R_NamesSymbol, names = allocVector(STRSXP, 3)); - SET_VECTOR_ELT(version, 0, ScalarInteger(major)); - SET_VECTOR_ELT(version, 1, ScalarInteger(minor)); - SET_VECTOR_ELT(version, 2, ScalarInteger(rev)); - SET_STRING_ELT(names, 0, mkChar("major")); - SET_STRING_ELT(names, 1, mkChar("minor")); - SET_STRING_ELT(names, 2, mkChar("rev")); + PROTECT(version = Rf_allocVector(VECSXP, 3)); + Rf_setAttrib(version, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3)); + SET_VECTOR_ELT(version, 0, Rf_ScalarInteger(major)); + SET_VECTOR_ELT(version, 1, Rf_ScalarInteger(minor)); + SET_VECTOR_ELT(version, 2, Rf_ScalarInteger(rev)); + SET_STRING_ELT(names, 0, Rf_mkChar("major")); + SET_STRING_ELT(names, 1, Rf_mkChar("minor")); + SET_STRING_ELT(names, 2, Rf_mkChar("rev")); UNPROTECT(1); return version; @@ -97,13 +97,13 @@ const char *f = NULL; const char *p = NULL; - if (!isNull(filename)) { + if (!Rf_isNull(filename)) { if (git2r_arg_check_string(filename)) git2r_error(__func__, NULL, "'filename'", git2r_err_string_arg); f = CHAR(STRING_ELT(filename, 0)); } - if (!isNull(path)) { + if (!Rf_isNull(path)) { if (git2r_arg_check_string(path)) git2r_error(__func__, NULL, "'path'", git2r_err_string_arg); p = CHAR(STRING_ELT(path, 0)); diff -Nru r-cran-git2r-0.21.0/src/git2r_merge.c r-cran-git2r-0.22.1/src/git2r_merge.c --- r-cran-git2r-0.21.0/src/git2r_merge.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_merge.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,15 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "buffer.h" +#include #include "git2r_arg.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_merge.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" int git2r_commit_create( @@ -45,13 +44,11 @@ */ SEXP git2r_merge_base(SEXP one, SEXP two) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; - SEXP repo; + SEXP repo_one, repo_two; SEXP sha; - git_oid oid; - git_oid oid_one; - git_oid oid_two; + git_oid oid, oid_one, oid_two; git_commit *commit = NULL; git_repository *repository = NULL; @@ -60,46 +57,50 @@ if (git2r_arg_check_commit(two)) git2r_error(__func__, NULL, "'two'", git2r_err_commit_arg); - repo = GET_SLOT(one, Rf_install("repo")); - repository = git2r_repository_open(repo); + repo_one = git2r_get_list_element(one, "repo"); + repo_two = git2r_get_list_element(two, "repo"); + if (git2r_arg_check_same_repo(repo_one, repo_two)) + git2r_error(__func__, NULL, "'one' and 'two' not from same repository", NULL); + + repository = git2r_repository_open(repo_one); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(one, Rf_install("sha")); - err = git_oid_fromstr(&oid_one, CHAR(STRING_ELT(sha, 0))); - if (err) + sha = git2r_get_list_element(one, "sha"); + error = git_oid_fromstr(&oid_one, CHAR(STRING_ELT(sha, 0))); + if (error) goto cleanup; - sha = GET_SLOT(two, Rf_install("sha")); - err = git_oid_fromstr(&oid_two, CHAR(STRING_ELT(sha, 0))); - if (err) + sha = git2r_get_list_element(two, "sha"); + error = git_oid_fromstr(&oid_two, CHAR(STRING_ELT(sha, 0))); + if (error) goto cleanup; - err = git_merge_base(&oid, repository, &oid_one, &oid_two); - if (err) { - if (GIT_ENOTFOUND == err) - err = GIT_OK; + error = git_merge_base(&oid, repository, &oid_one, &oid_two); + if (error) { + if (GIT_ENOTFOUND == error) + error = GIT_OK; goto cleanup; } - err = git_commit_lookup(&commit, repository, &oid); - if (err) + error = git_commit_lookup(&commit, repository, &oid); + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_commit"))); - git2r_commit_init(commit, repo, result); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); + git2r_commit_init(commit, repo_one, result); cleanup: - if (commit) - git_commit_free(commit); - - if (repository) - git_repository_free(repository); + git_commit_free(commit); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -108,7 +109,7 @@ /** * Perform a fast-forward merge * - * @param merge_result S4 class git_merge_result + * @param merge_result S3 class git_merge_result * @param merge_head The merge head to fast-forward merge * @param repository The repository * @param log_message First part of the one line long message in the reflog @@ -120,88 +121,99 @@ git_repository *repository, const char *log_message) { - int err; + int error; const git_oid *oid; - git_buf buf = GIT_BUF_INIT; + char *buf = NULL; + size_t buf_len; git_commit *commit = NULL; git_tree *tree = NULL; git_reference *reference = NULL; git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT; oid = git_annotated_commit_id(merge_head); - err = git_commit_lookup(&commit, repository, oid); - if (err) + error = git_commit_lookup(&commit, repository, oid); + if (error) goto cleanup; - err = git_commit_tree(&tree, commit); - if (err) + error = git_commit_tree(&tree, commit); + if (error) goto cleanup; opts.checkout_strategy = GIT_CHECKOUT_SAFE; - err = git_checkout_tree(repository, (git_object*)tree, &opts); - if (err) + error = git_checkout_tree(repository, (git_object*)tree, &opts); + if (error) goto cleanup; - err = git_repository_head(&reference, repository); - if (err) { - if (GIT_ENOTFOUND != err) + error = git_repository_head(&reference, repository); + if (error) { + if (GIT_ENOTFOUND != error) goto cleanup; } - err = git_buf_printf(&buf, "%s: Fast-forward", log_message); - if (err) + buf_len = strlen(log_message) + sizeof(": Fast-forward"); + buf = malloc(buf_len); + if (!buf) { + giterr_set_oom(); + error = GITERR_NOMEMORY; + goto cleanup; + } + error = snprintf(buf, buf_len, "%s: Fast-forward", log_message); + if (error < 0 || error >= buf_len) { + giterr_set_str(GITERR_OS, "Failed to snprintf log message."); + error = GITERR_OS; goto cleanup; + } - if (GIT_ENOTFOUND == err) { - err = git_reference_create( + if (GIT_ENOTFOUND == error) { + error = git_reference_create( &reference, repository, "HEAD", git_commit_id(commit), 0, /* force */ - buf.ptr); + buf); } else { git_reference *target_ref = NULL; - err = git_reference_set_target( + error = git_reference_set_target( &target_ref, reference, git_commit_id(commit), - buf.ptr); + buf); if (target_ref) git_reference_free(target_ref); } - SET_SLOT( + SET_VECTOR_ELT( merge_result, - Rf_install("fast_forward"), - ScalarLogical(1)); + git2r_S3_item__git_merge_result__fast_forward, + Rf_ScalarLogical(1)); - SET_SLOT( + SET_VECTOR_ELT( merge_result, - Rf_install("conflicts"), - ScalarLogical(0)); - -cleanup: - git_buf_free(&buf); - - if (commit) - git_commit_free(commit); + git2r_S3_item__git_merge_result__conflicts, + Rf_ScalarLogical(0)); - if (reference) - git_reference_free(reference); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__sha, + Rf_ScalarString(NA_STRING)); - if (tree) - git_tree_free(tree); +cleanup: + if (buf) + free(buf); + git_commit_free(commit); + git_reference_free(reference); + git_tree_free(tree); - return err; + return error; } /** * Perform a normal merge * - * @param merge_result S4 class git_merge_result + * @param merge_result S3 class git_merge_result * @param merge_heads The merge heads to merge * @param n The number of merge heads * @param repository The repository @@ -222,63 +234,90 @@ const git_checkout_options *checkout_opts, const git_merge_options *merge_opts) { - int err; + int error; git_commit *commit = NULL; git_index *index = NULL; - SET_SLOT(merge_result, Rf_install("fast_forward"), ScalarLogical(0)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__fast_forward, + Rf_ScalarLogical(0)); - err = git_merge( + error = git_merge( repository, merge_heads, n, merge_opts, checkout_opts); - if (err) + if (error) { + if (error == GIT_EMERGECONFLICT) { + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__conflicts, + Rf_ScalarLogical(1)); + + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__sha, + Rf_ScalarString(NA_STRING)); + + error = 0; + } goto cleanup; + } - err = git_repository_index(&index, repository); - if (err) + error = git_repository_index(&index, repository); + if (error) goto cleanup; if (git_index_has_conflicts(index)) { - SET_SLOT(merge_result, Rf_install("conflicts"), ScalarLogical(1)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__conflicts, + Rf_ScalarLogical(1)); + + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__sha, + Rf_ScalarString(NA_STRING)); } else { - SET_SLOT(merge_result, Rf_install("conflicts"), ScalarLogical(0)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__conflicts, + Rf_ScalarLogical(0)); if (commit_on_success) { char sha[GIT_OID_HEXSZ + 1]; git_oid oid; - SEXP s_sha = Rf_install("sha"); - err = git2r_commit_create( + error = git2r_commit_create( &oid, repository, index, message, merger, merger); - if (err) + if (error) goto cleanup; git_oid_fmt(sha, &oid); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(merge_result, s_sha, mkString(sha)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__sha, + Rf_mkString(sha)); } } cleanup: - if (commit) - git_commit_free(commit); - - if (index) - git_index_free(index); + git_commit_free(commit); + git_index_free(index); - return err; + return error; } /** - * @param merge_result S4 class git_merge_result + * @param merge_result S3 class git_merge_result * @repository The repository * @param merge_head The merge head to merge * @param n The number of merge heads @@ -288,6 +327,8 @@ * @param merger Who is performing the merge * @param commit_on_success Commit merge commit, if one was created * during a normal merge + * @param fail If a conflict occurs, exit immediately instead of attempting to + * continue resolving conflicts. * @return 0 on success, or error code */ static int git2r_merge( @@ -298,9 +339,10 @@ git_merge_preference_t preference, const char *name, git_signature *merger, - int commit_on_success) + int commit_on_success, + int fail) { - int err; + int error; git_merge_analysis_t merge_analysis; git_merge_preference_t merge_preference; git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT; @@ -308,27 +350,43 @@ merge_opts.rename_threshold = 50; merge_opts.target_limit = 200; + if (fail) + merge_opts.flags |= GIT_MERGE_FAIL_ON_CONFLICT; checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE; - err = git_merge_analysis( + error = git_merge_analysis( &merge_analysis, &merge_preference, repository, merge_heads, n); - if (err) - return err; + if (error) + return error; if (merge_analysis & GIT_MERGE_ANALYSIS_UP_TO_DATE) { - SET_SLOT(merge_result, - Rf_install("up_to_date"), - ScalarLogical(1)); - return GIT_OK; + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__up_to_date, + Rf_ScalarLogical(1)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__fast_forward, + Rf_ScalarLogical(0)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__conflicts, + Rf_ScalarLogical(0)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__sha, + Rf_ScalarString(NA_STRING)); + return 0; } else { - SET_SLOT(merge_result, - Rf_install("up_to_date"), - ScalarLogical(0)); + SET_VECTOR_ELT( + merge_result, + git2r_S3_item__git_merge_result__up_to_date, + Rf_ScalarLogical(0)); } if (GIT_MERGE_PREFERENCE_NONE == preference) @@ -345,13 +403,13 @@ return GIT_ERROR; } - err = git2r_fast_forward_merge( + error = git2r_fast_forward_merge( merge_result, merge_heads[0], repository, name); } else if (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL) { - err = git2r_normal_merge( + error = git2r_normal_merge( merge_result, merge_heads, n, @@ -365,7 +423,7 @@ break; case GIT_MERGE_PREFERENCE_NO_FASTFORWARD: if (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL) { - err = git2r_normal_merge( + error = git2r_normal_merge( merge_result, merge_heads, n, @@ -387,7 +445,7 @@ return GIT_ERROR; } - err = git2r_fast_forward_merge( + error = git2r_fast_forward_merge( merge_result, merge_heads[0], repository, @@ -430,18 +488,21 @@ /** * Merge branch into HEAD * - * @param branch S4 class git_branch to merge into HEAD. + * @param branch S3 class git_branch to merge into HEAD. * @param merger Who is performing the merge * @param commit_on_success Commit merge commit, if one was created * during a normal merge - * @return S4 class git_merge_result + * @param fail If a conflict occurs, exit immediately instead of attempting to + * continue resolving conflicts. + * @return S3 class git_merge_result */ -SEXP git2r_merge_branch(SEXP branch, SEXP merger, SEXP commit_on_success) +SEXP git2r_merge_branch(SEXP branch, SEXP merger, SEXP commit_on_success, SEXP fail) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const char *name; - git_buf buf = GIT_BUF_INIT; + char *buf = NULL; + size_t buf_len; git_branch_t type; git_annotated_commit **merge_heads = NULL; git_reference *reference = NULL; @@ -455,18 +516,18 @@ if (git2r_arg_check_signature(merger)) git2r_error(__func__, NULL, "'merger'", git2r_err_signature_arg); - err = git2r_signature_from_arg(&who, merger); - if (err) + error = git2r_signature_from_arg(&who, merger); + if (error) goto cleanup; - repository = git2r_repository_open(GET_SLOT(branch, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(branch, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - name = CHAR(STRING_ELT(GET_SLOT(branch, Rf_install("name")), 0)); - type = INTEGER(GET_SLOT(branch, Rf_install("type")))[0]; - err = git_branch_lookup(&reference, repository, name, type); - if (err) + name = CHAR(STRING_ELT(git2r_get_list_element(branch, "name"), 0)); + type = INTEGER(git2r_get_list_element(branch, "type"))[0]; + error = git_branch_lookup(&reference, repository, name, type); + if (error) goto cleanup; merge_heads = calloc(1, sizeof(git_annotated_commit*)); @@ -475,47 +536,54 @@ goto cleanup; } - err = git_annotated_commit_from_ref( + error = git_annotated_commit_from_ref( &(merge_heads[0]), repository, reference); - if (err) + if (error) goto cleanup; - err = git_buf_printf(&buf, "merge %s", name); - if (err) + buf_len = strlen(name) + sizeof("merge "); + buf = malloc(buf_len); + if (!buf) { + giterr_set_oom(); + error = GITERR_NOMEMORY; + goto cleanup; + } + error = snprintf(buf, buf_len, "merge %s", name); + if (error < 0 || error >= buf_len) { + giterr_set_str(GITERR_OS, "Failed to snprintf log message."); + error = GITERR_OS; goto cleanup; + } - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_merge_result"))); - err = git2r_merge( + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_merge_result)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_merge_result)); + error = git2r_merge( result, repository, (const git_annotated_commit **)merge_heads, 1, GIT_MERGE_PREFERENCE_NONE, - buf.ptr, + buf, who, - LOGICAL(commit_on_success)[0]); + LOGICAL(commit_on_success)[0], + LOGICAL(fail)[0]); cleanup: - git_buf_free(&buf); - - if (who) - git_signature_free(who); - - if (merge_heads) - git2r_merge_heads_free(merge_heads, 1); - - if (reference) - git_reference_free(reference); + if (buf) + free(buf); + git_signature_free(who); + git2r_merge_heads_free(merge_heads, 1); + git_reference_free(reference); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -527,7 +595,7 @@ * * @param out Pointer the vector of git_annotated_commit objects. * @param repository The repository. - * @param fetch_heads List of S4 class git_fetch_head objects. + * @param fetch_heads List of S3 class git_fetch_head objects. * @param n Length of fetch_heads list. * @return 0 on success, or error code */ @@ -537,7 +605,7 @@ SEXP fetch_heads, size_t n) { - int err = GIT_OK; + int error = GIT_OK; size_t i; *merge_heads = calloc(n, sizeof(git_annotated_commit*)); @@ -547,48 +615,47 @@ } for (i = 0; i < n; i++) { - int err; git_oid oid; SEXP fh = VECTOR_ELT(fetch_heads, i); - err = git_oid_fromstr( + error = git_oid_fromstr( &oid, - CHAR(STRING_ELT(GET_SLOT(fh, Rf_install("sha")), 0))); - if (err) + CHAR(STRING_ELT(git2r_get_list_element(fh, "sha"), 0))); + if (error) goto cleanup; - err = git_annotated_commit_from_fetchhead( + error = git_annotated_commit_from_fetchhead( &((*merge_heads)[i]), repository, - CHAR(STRING_ELT(GET_SLOT(fh, Rf_install("ref_name")), 0)), - CHAR(STRING_ELT(GET_SLOT(fh, Rf_install("remote_url")), 0)), + CHAR(STRING_ELT(git2r_get_list_element(fh, "ref_name"), 0)), + CHAR(STRING_ELT(git2r_get_list_element(fh, "remote_url"), 0)), &oid); - if (err) + if (error) goto cleanup; } cleanup: - if (err) { + if (error) { if (*merge_heads) git2r_merge_heads_free(*merge_heads, n); *merge_heads = NULL; } - return err; + return error; } /** * Merge the given fetch head data into HEAD * - * @param fetch_heads List of S4 class git_fetch_head objects. + * @param fetch_heads List of S3 class git_fetch_head objects. * @param merger Who made the merge, if the merge is non-fast forward * merge that creates a merge commit. * @return List of git_annotated_commit objects. */ SEXP git2r_merge_fetch_heads(SEXP fetch_heads, SEXP merger) { - int err; - size_t n; + int error, nprotect = 0; + size_t n = 0; SEXP result = R_NilValue; git_annotated_commit **merge_heads = NULL; git_repository *repository = NULL; @@ -599,28 +666,31 @@ if (git2r_arg_check_signature(merger)) git2r_error(__func__, NULL, "'merger'", git2r_err_signature_arg); - err = git2r_signature_from_arg(&who, merger); - if (err) + error = git2r_signature_from_arg(&who, merger); + if (error) goto cleanup; n = LENGTH(fetch_heads); if (n) { - SEXP repo = GET_SLOT(VECTOR_ELT(fetch_heads, 0), Rf_install("repo")); + SEXP repo = git2r_get_list_element(VECTOR_ELT(fetch_heads, 0), "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); } - err = git2r_merge_heads_from_fetch_heads( + error = git2r_merge_heads_from_fetch_heads( &merge_heads, repository, fetch_heads, n); - if (err) + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_merge_result"))); - err = git2r_merge( + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_merge_result)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_merge_result)); + error = git2r_merge( result, repository, (const git_annotated_commit **)merge_heads, @@ -628,24 +698,20 @@ GIT_MERGE_PREFERENCE_NONE, "pull", who, - 1); /* Commit on success */ - if (err) + 1, /* Commit on success */ + 0); /* Don't fail on conflicts */ + if (error) goto cleanup; cleanup: - if (who) - git_signature_free(who); - - if (merge_heads) - git2r_merge_heads_free(merge_heads, n); - - if (repository) - git_repository_free(repository); + git_signature_free(who); + git2r_merge_heads_free(merge_heads, n); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_merge.h r-cran-git2r-0.22.1/src/git2r_merge.h --- r-cran-git2r-0.21.0/src/git2r_merge.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_merge.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -23,7 +23,7 @@ #include SEXP git2r_merge_base(SEXP one, SEXP two); -SEXP git2r_merge_branch(SEXP branch, SEXP merger, SEXP commit_on_success); +SEXP git2r_merge_branch(SEXP branch, SEXP merger, SEXP commit_on_success, SEXP fail); SEXP git2r_merge_fetch_heads(SEXP fetch_heads, SEXP merger); #endif diff -Nru r-cran-git2r-0.21.0/src/git2r_note.c r-cran-git2r-0.22.1/src/git2r_note.c --- r-cran-git2r-0.21.0/src/git2r_note.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_note.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,14 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "buffer.h" +#include #include "git2r_arg.h" #include "git2r_error.h" #include "git2r_note.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" /** @@ -39,13 +38,13 @@ } git2r_note_foreach_cb_data; /** - * Init slots in S4 class git_note + * Init slots in S3 class git_note * * @param blob_id Oid of the blob containing the message * @param annotated_object_id Oid of the git object being annotated * @param repository - * @param repo S4 class git_repository that contains the stash - * @param dest S4 class git_note to initialize + * @param repo S3 class git_repository that contains the stash + * @param dest S3 class git_note to initialize * @return int 0 on success, or an error code. */ static int git2r_note_init( @@ -56,31 +55,41 @@ SEXP repo, SEXP dest) { - int err; + int error; git_note *note = NULL; char sha[GIT_OID_HEXSZ + 1]; - SEXP s_sha = Rf_install("sha"); - SEXP s_annotated = Rf_install("annotated"); - SEXP s_message = Rf_install("message"); - SEXP s_refname = Rf_install("refname"); - SEXP s_repo = Rf_install("repo"); - - err = git_note_read(¬e, repository, notes_ref, annotated_object_id); - if (err) - return err; + + error = git_note_read(¬e, repository, notes_ref, annotated_object_id); + if (error) + return error; git_oid_fmt(sha, blob_id); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(dest, s_sha, mkString(sha)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_note__sha, + Rf_mkString(sha)); + git_oid_fmt(sha, annotated_object_id); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(dest, s_annotated, mkString(sha)); - SET_SLOT(dest, s_message, mkString(git_note_message(note))); - SET_SLOT(dest, s_refname, mkString(notes_ref)); - SET_SLOT(dest, s_repo, repo); + SET_VECTOR_ELT(dest, git2r_S3_item__git_note__annotated, Rf_mkString(sha)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_note__message, + Rf_mkString(git_note_message(note))); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_note__refname, + Rf_mkString(notes_ref)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_note__repo, + Rf_duplicate(repo)); - if (note) - git_note_free(note); + git_note_free(note); return 0; } @@ -88,15 +97,15 @@ /** * Add a note for an object * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param sha The sha string of object - * @param commit S4 class git_commit + * @param commit S3 class git_commit * @param message Content of the note to add * @param ref Canonical name of the reference to use * @param author Signature of the notes note author * @param committer Signature of the notes note committer * @param force Overwrite existing note - * @return S4 class git_note + * @return S3 class git_note */ SEXP git2r_note_create( SEXP repo, @@ -107,7 +116,7 @@ SEXP committer, SEXP force) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; int overwrite = 0; git_oid note_oid; @@ -133,22 +142,22 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_signature_from_arg(&sig_author, author); - if (err) + error = git2r_signature_from_arg(&sig_author, author); + if (error) goto cleanup; - err = git2r_signature_from_arg(&sig_committer, committer); - if (err) + error = git2r_signature_from_arg(&sig_committer, committer); + if (error) goto cleanup; - err = git_oid_fromstr(&object_oid, CHAR(STRING_ELT(sha, 0))); - if (err) + error = git_oid_fromstr(&object_oid, CHAR(STRING_ELT(sha, 0))); + if (error) goto cleanup; if (LOGICAL(force)[0]) overwrite = 1; - err = git_note_create( + error = git_note_create( ¬e_oid, repository, CHAR(STRING_ELT(ref, 0)), @@ -157,11 +166,14 @@ &object_oid, CHAR(STRING_ELT(message, 0)), overwrite); - if (err) + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_note"))); - err = git2r_note_init(¬e_oid, + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_note)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_note)); + error = git2r_note_init(¬e_oid, &object_oid, repository, CHAR(STRING_ELT(ref, 0)), @@ -169,19 +181,14 @@ result); cleanup: - if (sig_author) - git_signature_free(sig_author); - - if (sig_committer) - git_signature_free(sig_committer); - - if (repository) - git_repository_free(repository); + git_signature_free(sig_author); + git_signature_free(sig_committer); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -191,38 +198,37 @@ * Default notes reference * * Get the default notes reference for a repository - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return Character vector of length one with name of default * reference */ SEXP git2r_note_default_ref(SEXP repo) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; - git_buf buf = GIT_BUF_INIT; + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); git_repository *repository = NULL; repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_note_default_ref(&buf, repository); - if (err) + error = git_note_default_ref(&buf, repository); + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(buf.ptr)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(buf.ptr)); cleanup: git_buf_free(&buf); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -244,24 +250,26 @@ git2r_note_foreach_cb_data *cb_data = (git2r_note_foreach_cb_data*)payload; /* Check if we have a list to populate */ - if (!isNull(cb_data->list)) { - int err; + if (!Rf_isNull(cb_data->list)) { + int error; SEXP note; SET_VECTOR_ELT( cb_data->list, cb_data->n, - note = NEW_OBJECT(MAKE_CLASS("git_note"))); + note = Rf_mkNamed(VECSXP, git2r_S3_items__git_note)); + Rf_setAttrib(note, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_note)); - err = git2r_note_init( + error = git2r_note_init( blob_id, annotated_object_id, cb_data->repository, cb_data->notes_ref, cb_data->repo, note); - if (err) - return err; + if (error) + return error; } cb_data->n += 1; @@ -272,19 +280,20 @@ /** * List all the notes within a specified namespace. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param ref Optional reference to read from. - * @return VECXSP with S4 objects of class git_note + * @return VECXSP with S3 objects of class git_note */ SEXP git2r_notes(SEXP repo, SEXP ref) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; - git_buf buf = GIT_BUF_INIT; + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); + const char *notes_ref; git2r_note_foreach_cb_data cb_data = {0, R_NilValue, R_NilValue, NULL, NULL}; git_repository *repository = NULL; - if (!isNull(ref)) { + if (!Rf_isNull(ref)) { if (git2r_arg_check_string(ref)) git2r_error(__func__, NULL, "'ref'", git2r_err_string_arg); } @@ -293,48 +302,49 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - if (!isNull(ref)) { - git_buf_sets(&buf, CHAR(STRING_ELT(ref, 0))); + if (!Rf_isNull(ref)) { + notes_ref = CHAR(STRING_ELT(ref, 0)); } else { - err = git_note_default_ref(&buf, repository); - if (err) + error = git_note_default_ref(&buf, repository); + if (error) goto cleanup; + notes_ref = buf.ptr; } /* Count number of notes before creating the list */ - err = git_note_foreach( + error = git_note_foreach( repository, - git_buf_cstr(&buf), + notes_ref, &git2r_note_foreach_cb, &cb_data); - if (err) { - if (GIT_ENOTFOUND == err) { - err = GIT_OK; - PROTECT(result = allocVector(VECSXP, 0)); + if (error) { + if (GIT_ENOTFOUND == error) { + error = GIT_OK; + PROTECT(result = Rf_allocVector(VECSXP, 0)); + nprotect++; } goto cleanup; } - PROTECT(result = allocVector(VECSXP, cb_data.n)); + PROTECT(result = Rf_allocVector(VECSXP, cb_data.n)); + nprotect++; cb_data.n = 0; cb_data.list = result; cb_data.repo = repo; cb_data.repository = repository; - cb_data.notes_ref = git_buf_cstr(&buf); - err = git_note_foreach(repository, git_buf_cstr(&buf), + cb_data.notes_ref = notes_ref; + error = git_note_foreach(repository, notes_ref, &git2r_note_foreach_cb, &cb_data); cleanup: git_buf_free(&buf); + git_repository_free(repository); - if (repository) - git_repository_free(repository); - - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -343,14 +353,14 @@ /** * Remove the note for an object * - * @param note S4 class git_note + * @param note S3 class git_note * @param author Signature of the notes commit author * @param committer Signature of the notes commit committer * @return R_NilValue */ SEXP git2r_note_remove(SEXP note, SEXP author, SEXP committer) { - int err; + int error; SEXP repo; SEXP annotated; git_oid note_oid; @@ -365,42 +375,37 @@ if (git2r_arg_check_signature(committer)) git2r_error(__func__, NULL, "'committer'", git2r_err_signature_arg); - repo = GET_SLOT(note, Rf_install("repo")); + repo = git2r_get_list_element(note, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_signature_from_arg(&sig_author, author); - if (err) + error = git2r_signature_from_arg(&sig_author, author); + if (error) goto cleanup; - err = git2r_signature_from_arg(&sig_committer, committer); - if (err) + error = git2r_signature_from_arg(&sig_committer, committer); + if (error) goto cleanup; - annotated = GET_SLOT(note, Rf_install("annotated")); - err = git_oid_fromstr(¬e_oid, CHAR(STRING_ELT(annotated, 0))); - if (err) + annotated = git2r_get_list_element(note, "annotated"); + error = git_oid_fromstr(¬e_oid, CHAR(STRING_ELT(annotated, 0))); + if (error) goto cleanup; - err = git_note_remove( + error = git_note_remove( repository, - CHAR(STRING_ELT(GET_SLOT(note, Rf_install("refname")), 0)), + CHAR(STRING_ELT(git2r_get_list_element(note, "refname"), 0)), sig_author, sig_committer, ¬e_oid); cleanup: - if (sig_author) - git_signature_free(sig_author); - - if (sig_committer) - git_signature_free(sig_committer); - - if (repository) - git_repository_free(repository); + git_signature_free(sig_author); + git_signature_free(sig_committer); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; diff -Nru r-cran-git2r-0.21.0/src/git2r_object.c r-cran-git2r-0.22.1/src/git2r_object.c --- r-cran-git2r-0.21.0/src/git2r_object.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_object.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,27 +16,27 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_blob.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_tag.h" #include "git2r_tree.h" /** * Lookup an object in a repository * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param sha 4 to 40 char hexadecimal string - * @return S4 object with lookup + * @return S3 object with lookup */ SEXP git2r_object_lookup(SEXP repo, SEXP sha) { - int err; + int error, nprotect = 0; size_t len; SEXP result = R_NilValue; git_object *object = NULL; @@ -53,31 +53,43 @@ len = LENGTH(STRING_ELT(sha, 0)); if (GIT_OID_HEXSZ == len) { git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); - err = git_object_lookup(&object, repository, &oid, GIT_OBJ_ANY); - if (err) + error = git_object_lookup(&object, repository, &oid, GIT_OBJ_ANY); + if (error) goto cleanup; } else { git_oid_fromstrn(&oid, CHAR(STRING_ELT(sha, 0)), len); - err = git_object_lookup_prefix(&object, repository, &oid, len, GIT_OBJ_ANY); - if (err) + error = git_object_lookup_prefix(&object, repository, &oid, len, GIT_OBJ_ANY); + if (error) goto cleanup; } switch (git_object_type(object)) { case GIT_OBJ_COMMIT: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_commit"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init((git_commit*)object, repo, result); break; case GIT_OBJ_TREE: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_tree"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_tree)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tree)); git2r_tree_init((git_tree*)object, repo, result); break; case GIT_OBJ_BLOB: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_blob"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_blob)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blob)); git2r_blob_init((git_blob*)object, repo, result); break; case GIT_OBJ_TAG: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_tag"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_tag)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tag)); git2r_tag_init((git_tag*)object, repo, result); break; default: @@ -85,16 +97,13 @@ } cleanup: - if (object) - git_object_free(object); + git_object_free(object); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_odb.c r-cran-git2r-0.22.1/src/git2r_odb.c --- r-cran-git2r-0.21.0/src/git2r_odb.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_odb.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,9 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "buffer.h" +#include #include "git2r_arg.h" #include "git2r_error.h" @@ -35,7 +33,7 @@ SEXP git2r_odb_hash(SEXP data) { SEXP result; - int err = GIT_OK; + int error = GIT_OK; size_t len, i; char sha[GIT_OID_HEXSZ + 1]; git_oid oid; @@ -43,28 +41,28 @@ if (git2r_arg_check_string_vec(data)) git2r_error(__func__, NULL, "'data'", git2r_err_string_vec_arg); - len = length(data); - PROTECT(result = allocVector(STRSXP, len)); + len = Rf_length(data); + PROTECT(result = Rf_allocVector(STRSXP, len)); for (i = 0; i < len; i++) { if (NA_STRING == STRING_ELT(data, i)) { SET_STRING_ELT(result, i, NA_STRING); } else { - err = git_odb_hash(&oid, + error = git_odb_hash(&oid, CHAR(STRING_ELT(data, i)), LENGTH(STRING_ELT(data, i)), GIT_OBJ_BLOB); - if (err) + if (error) break; git_oid_fmt(sha, &oid); sha[GIT_OID_HEXSZ] = '\0'; - SET_STRING_ELT(result, i, mkChar(sha)); + SET_STRING_ELT(result, i, Rf_mkChar(sha)); } } UNPROTECT(1); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -80,7 +78,7 @@ SEXP git2r_odb_hashfile(SEXP path) { SEXP result; - int err = GIT_OK; + int error = GIT_OK; size_t len, i; char sha[GIT_OID_HEXSZ + 1]; git_oid oid; @@ -88,27 +86,27 @@ if (git2r_arg_check_string_vec(path)) git2r_error(__func__, NULL, "'path'", git2r_err_string_vec_arg); - len = length(path); - PROTECT(result = allocVector(STRSXP, len)); + len = Rf_length(path); + PROTECT(result = Rf_allocVector(STRSXP, len)); for (i = 0; i < len; i++) { if (NA_STRING == STRING_ELT(path, i)) { SET_STRING_ELT(result, i, NA_STRING); } else { - err = git_odb_hashfile(&oid, + error = git_odb_hashfile(&oid, CHAR(STRING_ELT(path, i)), GIT_OBJ_BLOB); - if (err) + if (error) break; git_oid_fmt(sha, &oid); sha[GIT_OID_HEXSZ] = '\0'; - SET_STRING_ELT(result, i, mkChar(sha)); + SET_STRING_ELT(result, i, Rf_mkChar(sha)); } } UNPROTECT(1); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -127,11 +125,11 @@ * Add object * * @param oid Oid of the object - * @param list The list to hold the S4 class git_object + * @param list The list to hold the S3 class git_object * @param i The index to the list item * @param type The type of the object * @param len The length of the object - * @param repo The S4 class that contains the object + * @param repo The S3 class that contains the object * @return void */ static void git2r_add_object( @@ -147,10 +145,10 @@ /* Sha */ git_oid_fmt(sha, oid); sha[GIT_OID_HEXSZ] = '\0'; - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(sha)); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(sha)); /* Type */ - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(type)); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(type)); /* Length */ INTEGER(VECTOR_ELT(list, j++))[i] = len; @@ -165,30 +163,30 @@ */ static int git2r_odb_objects_cb(const git_oid *oid, void *payload) { - int err; + int error; size_t len; git_otype type; git2r_odb_objects_cb_data *p = (git2r_odb_objects_cb_data*)payload; - err = git_odb_read_header(&len, &type, p->odb, oid); - if (err) - return err; + error = git_odb_read_header(&len, &type, p->odb, oid); + if (error) + return error; switch(type) { case GIT_OBJ_COMMIT: - if (!isNull(p->list)) + if (!Rf_isNull(p->list)) git2r_add_object(oid, p->list, p->n, "commit", len); break; case GIT_OBJ_TREE: - if (!isNull(p->list)) + if (!Rf_isNull(p->list)) git2r_add_object(oid, p->list, p->n, "tree", len); break; case GIT_OBJ_BLOB: - if (!isNull(p->list)) + if (!Rf_isNull(p->list)) git2r_add_object(oid, p->list, p->n, "blob", len); break; case GIT_OBJ_TAG: - if (!isNull(p->list)) + if (!Rf_isNull(p->list)) git2r_add_object(oid, p->list, p->n, "tag", len); break; default: @@ -203,12 +201,12 @@ /** * List all objects available in the database * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return list with sha's for commit's, tree's, blob's and tag's */ SEXP git2r_odb_objects(SEXP repo) { - int i, err; + int i, error, nprotect = 0; SEXP result = R_NilValue; SEXP names = R_NilValue; git2r_odb_objects_cb_data cb_data = {0, R_NilValue, NULL}; @@ -219,42 +217,40 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_repository_odb(&odb, repository); - if (err) + error = git_repository_odb(&odb, repository); + if (error) goto cleanup; cb_data.odb = odb; /* Count number of objects before creating the list */ - err = git_odb_foreach(odb, &git2r_odb_objects_cb, &cb_data); - if (err) + error = git_odb_foreach(odb, &git2r_odb_objects_cb, &cb_data); + if (error) goto cleanup; - PROTECT(result = allocVector(VECSXP, 3)); - setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, 3)); + PROTECT(result = Rf_allocVector(VECSXP, 3)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3)); i = 0; - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("sha")); - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("type")); - SET_VECTOR_ELT(result, i, allocVector(INTSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("len")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("sha")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("type")); + SET_VECTOR_ELT(result, i, Rf_allocVector(INTSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("len")); cb_data.list = result; cb_data.n = 0; - err = git_odb_foreach(odb, &git2r_odb_objects_cb, &cb_data); + error = git_odb_foreach(odb, &git2r_odb_objects_cb, &cb_data); cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); + git_odb_free(odb); - if (odb) - git_odb_free(odb); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -293,7 +289,7 @@ const char *author, double when) { - int err; + int error; int j = 0; size_t len; git_otype type; @@ -302,25 +298,25 @@ /* Sha */ git_oid_fmt(sha, git_tree_entry_id(entry)); sha[GIT_OID_HEXSZ] = '\0'; - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(sha)); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(sha)); /* Path */ - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(path)); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(path)); /* Name */ - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(git_tree_entry_name(entry))); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(git_tree_entry_name(entry))); /* Length */ - err = git_odb_read_header(&len, &type, odb, git_tree_entry_id(entry)); - if (err) - return err; + error = git_odb_read_header(&len, &type, odb, git_tree_entry_id(entry)); + if (error) + return error; INTEGER(VECTOR_ELT(list, j++))[i] = len; /* Commit sha */ - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(commit)); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(commit)); /* Author */ - SET_STRING_ELT(VECTOR_ELT(list, j++), i, mkChar(author)); + SET_STRING_ELT(VECTOR_ELT(list, j++), i, Rf_mkChar(author)); /* When */ REAL(VECTOR_ELT(list, j++))[i] = when; @@ -347,7 +343,7 @@ double when, git2r_odb_blobs_cb_data *data) { - int err; + int error; size_t i, n; n = git_tree_entrycount(tree); @@ -358,41 +354,58 @@ switch (git_tree_entry_type(entry)) { case GIT_OBJ_TREE: { - git_buf buf = GIT_BUF_INIT; + char *buf = NULL; + size_t path_len, buf_len; + const char *entry_name; + const char *sep; git_tree *sub_tree = NULL; - err = git_tree_lookup( + error = git_tree_lookup( &sub_tree, data->repository, git_tree_entry_id(entry)); - if (err) - return err; - - err = git_buf_joinpath(&buf, path, git_tree_entry_name(entry)); + if (error) + return error; - if (GIT_OK == err) { - err = git2r_odb_tree_blobs( + entry_name = git_tree_entry_name(entry); + path_len = strlen(path); + buf_len = path_len + strlen(entry_name) + 2; + buf = malloc(buf_len); + if (!buf) { + git_tree_free(sub_tree); + giterr_set_oom(); + return GITERR_NOMEMORY; + } + if (path_len) { + sep = "/"; + } else { + sep = ""; + } + error = snprintf(buf, buf_len, "%s%s%s", path, sep, entry_name); + if (0 <= error && error < buf_len) { + error = git2r_odb_tree_blobs( sub_tree, - buf.ptr, + buf, commit, author, when, data); + } else { + giterr_set_str(GITERR_OS, "Failed to snprintf tree path."); + error = GITERR_OS; } - git_buf_free(&buf); + free(buf); + git_tree_free(sub_tree); - if (sub_tree) - git_tree_free(sub_tree); - - if (err) - return err; + if (error) + return error; break; } case GIT_OBJ_BLOB: - if (!isNull(data->list)) { - err = git2r_odb_add_blob( + if (!Rf_isNull(data->list)) { + error = git2r_odb_add_blob( entry, data->odb, data->list, @@ -401,8 +414,8 @@ commit, author, when); - if (err) - return err; + if (error) + return error; } data->n += 1; break; @@ -423,14 +436,14 @@ */ static int git2r_odb_blobs_cb(const git_oid *oid, void *payload) { - int err = GIT_OK; + int error = GIT_OK; size_t len; git_otype type; git2r_odb_blobs_cb_data *p = (git2r_odb_blobs_cb_data*)payload; - err = git_odb_read_header(&len, &type, p->odb, oid); - if (err) - return err; + error = git_odb_read_header(&len, &type, p->odb, oid); + if (error) + return error; if (GIT_OBJ_COMMIT == type) { const git_signature *author; @@ -438,12 +451,12 @@ git_tree *tree = NULL; char sha[GIT_OID_HEXSZ + 1]; - err = git_commit_lookup(&commit, p->repository, oid); - if (err) + error = git_commit_lookup(&commit, p->repository, oid); + if (error) goto cleanup; - err = git_commit_tree(&tree, commit); - if (err) + error = git_commit_tree(&tree, commit); + if (error) goto cleanup; git_oid_fmt(sha, oid); @@ -452,7 +465,7 @@ author = git_commit_author(commit); /* Recursively iterate over all tree's */ - err = git2r_odb_tree_blobs( + error = git2r_odb_tree_blobs( tree, "", sha, @@ -461,14 +474,11 @@ p); cleanup: - if (commit) - git_commit_free(commit); - - if (tree) - git_tree_free(tree); + git_commit_free(commit); + git_tree_free(tree); } - return err; + return error; } /** @@ -477,12 +487,12 @@ * List all blobs reachable from the commits in the object * database. First list all commits. Then iterate over each blob from * the tree and sub-trees of each commit. - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return A list with blob entries */ SEXP git2r_odb_blobs(SEXP repo) { - int i, err; + int i, error, nprotect = 0; SEXP result = R_NilValue; SEXP names = R_NilValue; git2r_odb_blobs_cb_data cb_data = {0, R_NilValue, NULL, NULL}; @@ -493,51 +503,49 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_repository_odb(&odb, repository); - if (err) + error = git_repository_odb(&odb, repository); + if (error) goto cleanup; cb_data.odb = odb; /* Count number of blobs before creating the list */ cb_data.repository = repository; - err = git_odb_foreach(odb, &git2r_odb_blobs_cb, &cb_data); - if (err) + error = git_odb_foreach(odb, &git2r_odb_blobs_cb, &cb_data); + if (error) goto cleanup; - PROTECT(result = allocVector(VECSXP, 7)); - setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, 7)); + PROTECT(result = Rf_allocVector(VECSXP, 7)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, 7)); i = 0; - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("sha")); - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("path")); - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("name")); - SET_VECTOR_ELT(result, i, allocVector(INTSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("len")); - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("commit")); - SET_VECTOR_ELT(result, i, allocVector(STRSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("author")); - SET_VECTOR_ELT(result, i, allocVector(REALSXP, cb_data.n)); - SET_STRING_ELT(names, i++, mkChar("when")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("sha")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("path")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("name")); + SET_VECTOR_ELT(result, i, Rf_allocVector(INTSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("len")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("commit")); + SET_VECTOR_ELT(result, i, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("author")); + SET_VECTOR_ELT(result, i, Rf_allocVector(REALSXP, cb_data.n)); + SET_STRING_ELT(names, i++, Rf_mkChar("when")); cb_data.list = result; cb_data.n = 0; - err = git_odb_foreach(odb, &git2r_odb_blobs_cb, &cb_data); + error = git_odb_foreach(odb, &git2r_odb_blobs_cb, &cb_data); cleanup: - if (repository) - git_repository_free(repository); - - if (odb) - git_odb_free(odb); + git_repository_free(repository); + git_odb_free(odb); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_oid.h r-cran-git2r-0.22.1/src/git2r_oid.h --- r-cran-git2r-0.21.0/src/git2r_oid.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_oid.h 2018-07-10 13:23:34.000000000 +0000 @@ -21,7 +21,7 @@ #include #include -#include "git2.h" +#include void git2r_oid_from_sha_sexp(SEXP sha, git_oid *oid); diff -Nru r-cran-git2r-0.21.0/src/git2r_push.c r-cran-git2r-0.22.1/src/git2r_push.c --- r-cran-git2r-0.21.0/src/git2r_push.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_push.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2016 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,8 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_cred.h" @@ -37,7 +36,7 @@ { size_t i, n; - n = length(refspec); + n = Rf_length(refspec); if (0 == n) return 1; /* Nothing to push */ @@ -53,7 +52,7 @@ /** * Push * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The remote to push to * @param refspec The string vector of refspec to push * @param credentials The credentials for remote repository access. @@ -61,7 +60,7 @@ */ SEXP git2r_push(SEXP repo, SEXP name, SEXP refspec, SEXP credentials) { - int err; + int error; git_remote *remote = NULL; git_repository *repository = NULL; git_strarray c_refspecs = {0}; @@ -82,23 +81,22 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_lookup(&remote, repository, CHAR(STRING_ELT(name, 0))); - if (err) + error = git_remote_lookup(&remote, repository, CHAR(STRING_ELT(name, 0))); + if (error) goto cleanup; payload.credentials = credentials; opts.callbacks.payload = &payload; opts.callbacks.credentials = &git2r_cred_acquire_cb; - err = git2r_copy_string_vec(&c_refspecs, refspec); - if (err) + error = git2r_copy_string_vec(&c_refspecs, refspec); + if (error) goto cleanup; - err = git_remote_push(remote, &c_refspecs, &opts); + error = git_remote_push(remote, &c_refspecs, &opts); cleanup: - if (c_refspecs.strings) - free(c_refspecs.strings); + free(c_refspecs.strings); if (remote) { if (git_remote_connected(remote)) @@ -106,10 +104,9 @@ git_remote_free(remote); } - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error( __func__, giterr_last(), diff -Nru r-cran-git2r-0.21.0/src/git2r_reference.c r-cran-git2r-0.22.1/src/git2r_reference.c --- r-cran-git2r-0.21.0/src/git2r_reference.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_reference.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,25 +16,25 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" #include "git2r_reference.h" #include "git2r_repository.h" +#include "git2r_S3.h" /** * Lookup the full name of a reference by DWIMing its short name * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param shorthand The short name for the reference * @return Character vector of length one with the full name of the * reference */ SEXP git2r_reference_dwim(SEXP repo, SEXP shorthand) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git_reference* reference = NULL; git_repository *repository = NULL; @@ -46,76 +46,97 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_reference_dwim( + error = git_reference_dwim( &reference, repository, CHAR(STRING_ELT(shorthand, 0))); - if (err) + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(git_reference_name(reference))); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(git_reference_name(reference))); cleanup: - if (reference) - git_reference_free(reference); + git_reference_free(reference); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; } /** - * Init slots in S4 class git_reference. + * Init slots in S3 class git_reference. * * @param source A git_reference pointer - * @param dest S4 class git_reference to initialize + * @param dest S3 class git_reference to initialize * @return void */ void git2r_reference_init(git_reference *source, SEXP dest) { char sha[GIT_OID_HEXSZ + 1]; - SEXP s_name = Rf_install("name"); - SEXP s_shorthand = Rf_install("shorthand"); - SEXP s_type = Rf_install("type"); - SEXP s_sha = Rf_install("sha"); - SEXP s_target = Rf_install("target"); - SET_SLOT(dest, s_name, mkString(git_reference_name(source))); - SET_SLOT(dest, s_shorthand, mkString(git_reference_shorthand(source))); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__name, + Rf_mkString(git_reference_name(source))); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__shorthand, + Rf_mkString(git_reference_shorthand(source))); switch (git_reference_type(source)) { case GIT_REF_OID: - SET_SLOT(dest, s_type, ScalarInteger(GIT_REF_OID)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__type, + Rf_ScalarInteger(GIT_REF_OID)); + git_oid_fmt(sha, git_reference_target(source)); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(dest, s_sha, mkString(sha)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__sha, + Rf_mkString(sha)); break; case GIT_REF_SYMBOLIC: - SET_SLOT(dest, s_type, ScalarInteger(GIT_REF_SYMBOLIC)); - SET_SLOT(dest, s_target, mkString(git_reference_symbolic_target(source))); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__type, + Rf_ScalarInteger(GIT_REF_SYMBOLIC)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__target, + Rf_mkString(git_reference_symbolic_target(source))); break; default: git2r_error(__func__, NULL, git2r_err_reference, NULL); } + + if (Rf_isNull(VECTOR_ELT(dest, git2r_S3_item__git_reference__target))) { + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reference__target, + Rf_ScalarString(NA_STRING)); + } } /** * Get all references that can be found in a repository. * - * @param repo S4 class git_repository - * @return VECXSP with S4 objects of class git_reference + * @param repo S3 class git_repository + * @return VECXSP with S3 objects of class git_reference */ SEXP git2r_reference_list(SEXP repo) { - int err; + int error, nprotect = 0; size_t i; git_strarray ref_list; SEXP result = R_NilValue; @@ -126,45 +147,45 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_reference_list(&ref_list, repository); - if (err) + error = git_reference_list(&ref_list, repository); + if (error) goto cleanup; - PROTECT(result = allocVector(VECSXP, ref_list.count)); - setAttrib( + PROTECT(result = Rf_allocVector(VECSXP, ref_list.count)); + nprotect++; + Rf_setAttrib( result, R_NamesSymbol, - names = allocVector(STRSXP, ref_list.count)); + names = Rf_allocVector(STRSXP, ref_list.count)); for (i = 0; i < ref_list.count; i++) { SEXP reference; git_reference *ref = NULL; - err = git_reference_lookup(&ref, repository, ref_list.strings[i]); - if (err) + error = git_reference_lookup(&ref, repository, ref_list.strings[i]); + if (error) goto cleanup; SET_VECTOR_ELT( result, i, - reference = NEW_OBJECT(MAKE_CLASS("git_reference"))); + reference = Rf_mkNamed(VECSXP, git2r_S3_items__git_reference)); + Rf_setAttrib(reference, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_reference)); git2r_reference_init(ref, reference); - SET_STRING_ELT(names, i, mkChar(ref_list.strings[i])); + SET_STRING_ELT(names, i, Rf_mkChar(ref_list.strings[i])); - if (ref) - git_reference_free(ref); + git_reference_free(ref); } cleanup: git_strarray_free(&ref_list); + git_repository_free(repository); - if (repository) - git_repository_free(repository); - - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_reflog.c r-cran-git2r-0.22.1/src/git2r_reflog.c --- r-cran-git2r-0.21.0/src/git2r_reflog.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_reflog.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,23 +16,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_error.h" #include "git2r_reflog.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" /** - * Init slots in S4 class git_reflog_entry + * Init slots in S3 class git_reflog_entry * * @param source The source reflog entry * @param index The entry index - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param ref Reference to read from - * @param dest S4 class git_reflog_entry to initialize + * @param dest S3 class git_reflog_entry to initialize * @return void */ void git2r_reflog_entry_init( @@ -46,44 +46,71 @@ const char *message; const git_signature *committer; char sha[GIT_OID_HEXSZ + 1]; - SEXP s_sha = Rf_install("sha"); - SEXP s_index = Rf_install("index"); - SEXP s_committer = Rf_install("committer"); - SEXP s_message = Rf_install("message"); - SEXP s_refname = Rf_install("refname"); - SEXP s_repo = Rf_install("repo"); git_oid_fmt(sha, git_reflog_entry_id_new(source)); sha[GIT_OID_HEXSZ] = '\0'; - SET_SLOT(dest, s_sha, mkString(sha)); - - SET_SLOT(dest, s_index, i = allocVector(INTSXP, 1)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__sha, + Rf_mkString(sha)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__index, + i = Rf_allocVector(INTSXP, 1)); INTEGER(i)[0] = index; committer = git_reflog_entry_committer(source); - if (committer) - git2r_signature_init(committer, GET_SLOT(dest, s_committer)); + if (committer) { + if (Rf_isNull(VECTOR_ELT(dest, git2r_S3_item__git_reflog_entry__committer))) { + SEXP item; + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__committer, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); + } + git2r_signature_init( + committer, + VECTOR_ELT(dest, git2r_S3_item__git_reflog_entry__committer)); + } message = git_reflog_entry_message(source); - if (message) - SET_SLOT(dest, s_message, mkString(message)); - else - SET_SLOT(dest, s_message, ScalarString(NA_STRING)); + if (message) { + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__message, + Rf_mkString(message)); + } else { + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__message, + Rf_ScalarString(NA_STRING)); + } - SET_SLOT(dest, s_refname, ref); - SET_SLOT(dest, s_repo, repo); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__refname, + ref); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_reflog_entry__repo, + Rf_duplicate(repo)); } /** * List the reflog within a specified reference. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param ref Reference to read from. - * @return VECXSP with S4 objects of class git_reflog + * @return VECXSP with S3 objects of class git_reflog */ SEXP git2r_reflog_list(SEXP repo, SEXP ref) { - int err; + int error, nprotect = 0; size_t i, n; SEXP result = R_NilValue; git_reflog *reflog = NULL; @@ -96,36 +123,38 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_reflog_read(&reflog, repository, CHAR(STRING_ELT(ref, 0))); - if (err) + error = git_reflog_read(&reflog, repository, CHAR(STRING_ELT(ref, 0))); + if (error) goto cleanup; n = git_reflog_entrycount(reflog); - PROTECT(result = allocVector(VECSXP, n)); + PROTECT(result = Rf_allocVector(VECSXP, n)); + nprotect++; + for (i = 0; i < n; i++) { const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, i); if (entry) { SEXP item; - SET_VECTOR_ELT(result, - i, - item = NEW_OBJECT(MAKE_CLASS("git_reflog_entry"))); + SET_VECTOR_ELT( + result, + i, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_reflog_entry)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_reflog_entry)); git2r_reflog_entry_init(entry, i, repo, ref, item); } } cleanup: - if (reflog) - git_reflog_free(reflog); - - if (repository) - git_repository_free(repository); + git_reflog_free(reflog); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_remote.c r-cran-git2r-0.22.1/src/git2r_remote.c --- r-cran-git2r-0.21.0/src/git2r_remote.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_remote.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,15 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "common.h" +#include #include "git2r_arg.h" #include "git2r_cred.h" #include "git2r_error.h" #include "git2r_remote.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" #include "git2r_transfer.h" @@ -32,14 +31,14 @@ * Add a remote with the default fetch refspec to the repository's * configuration. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The name of the remote * @param url The url of the remote * @return R_NilValue */ SEXP git2r_remote_add(SEXP repo, SEXP name, SEXP url) { - int err; + int error; git_repository *repository = NULL; git_remote *remote = NULL; @@ -55,19 +54,16 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_create( + error = git_remote_create( &remote, repository, CHAR(STRING_ELT(name, 0)), CHAR(STRING_ELT(url, 0))); - if (remote) - git_remote_free(remote); + git_remote_free(remote); + git_repository_free(repository); - if (repository) - git_repository_free(repository); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -114,7 +110,7 @@ /** * Fetch new data and update tips * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The name of the remote to fetch from * @param credentials The credentials for remote repository access. * @param msg The one line long message to be appended to the reflog @@ -131,7 +127,7 @@ SEXP verbose, SEXP refspecs) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; const git_transfer_progress *stats; git_remote *remote = NULL; @@ -148,22 +144,22 @@ git2r_error(__func__, NULL, "'msg'", git2r_err_string_arg); if (git2r_arg_check_logical(verbose)) git2r_error(__func__, NULL, "'verbose'", git2r_err_logical_arg); - if ((!isNull(refspecs)) && git2r_arg_check_string_vec(refspecs)) + if ((!Rf_isNull(refspecs)) && git2r_arg_check_string_vec(refspecs)) git2r_error(__func__, NULL, "'refspecs'", git2r_err_string_vec_arg); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_lookup(&remote, repository, CHAR(STRING_ELT(name, 0))); - if (err) + error = git_remote_lookup(&remote, repository, CHAR(STRING_ELT(name, 0))); + if (error) goto cleanup; - if (!isNull(refspecs)) { + if (!Rf_isNull(refspecs)) { size_t i, len; /* Count number of non NA values */ - len = length(refspecs); + len = Rf_length(refspecs); for (i = 0; i < len; i++) if (NA_STRING != STRING_ELT(refspecs, i)) refs.count++; @@ -173,7 +169,7 @@ refs.strings = malloc(refs.count * sizeof(char*)); if (!refs.strings) { giterr_set_str(GITERR_NONE, git2r_err_alloc_memory_buffer); - err = GIT_ERROR; + error = GIT_ERROR; goto cleanup; } @@ -190,31 +186,29 @@ fetch_opts.callbacks.payload = &payload; fetch_opts.callbacks.credentials = &git2r_cred_acquire_cb; fetch_opts.callbacks.update_tips = &git2r_update_tips_cb; - err = git_remote_fetch(remote, &refs, &fetch_opts, CHAR(STRING_ELT(msg, 0))); - if (err) + error = git_remote_fetch(remote, &refs, &fetch_opts, CHAR(STRING_ELT(msg, 0))); + if (error) goto cleanup; stats = git_remote_stats(remote); - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_transfer_progress"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_transfer_progress)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_transfer_progress)); git2r_transfer_progress_init(stats, result); cleanup: - if (refs.strings) - free(refs.strings); - - if (remote) { - if (git_remote_connected(remote)) - git_remote_disconnect(remote); - git_remote_free(remote); - } + free(refs.strings); - if (repository) - git_repository_free(repository); + if (remote && git_remote_connected(remote)) + git_remote_disconnect(remote); + git_remote_free(remote); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error( __func__, giterr_last(), @@ -227,12 +221,12 @@ /** * Get the configured remotes for a repo * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return Character vector with name of the remotes */ SEXP git2r_remote_list(SEXP repo) { - int err; + int error, nprotect = 0; size_t i; git_strarray rem_list; SEXP list = R_NilValue; @@ -242,24 +236,23 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_list(&rem_list, repository); - if (err) + error = git_remote_list(&rem_list, repository); + if (error) goto cleanup; - PROTECT(list = allocVector(STRSXP, rem_list.count)); + PROTECT(list = Rf_allocVector(STRSXP, rem_list.count)); + nprotect++; for (i = 0; i < rem_list.count; i++) - SET_STRING_ELT(list, i, mkChar(rem_list.strings[i])); + SET_STRING_ELT(list, i, Rf_mkChar(rem_list.strings[i])); cleanup: git_strarray_free(&rem_list); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(list)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return list; @@ -270,13 +263,13 @@ * * All remote-tracking branches and configuration settings for the * remote will be removed. - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The name of the remote to remove * @return R_NilValue */ SEXP git2r_remote_remove(SEXP repo, SEXP name) { - int err; + int error; git_repository *repository = NULL; if (git2r_arg_check_string(name)) @@ -286,12 +279,11 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_delete(repository, CHAR(STRING_ELT(name, 0))); + error = git_remote_delete(repository, CHAR(STRING_ELT(name, 0))); - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -300,14 +292,14 @@ /** * Give the remote a new name * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param oldname The old name of the remote * @param newname The new name of the remote * @return R_NilValue */ SEXP git2r_remote_rename(SEXP repo, SEXP oldname, SEXP newname) { - int err; + int error; git_strarray problems = {0}; git_repository *repository = NULL; @@ -320,21 +312,20 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_rename( + error = git_remote_rename( &problems, repository, CHAR(STRING_ELT(oldname, 0)), CHAR(STRING_ELT(newname, 0))); - if (err) + if (error) goto cleanup; git_strarray_free(&problems); cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -345,14 +336,14 @@ * * This assumes the common case of a single-url remote and * will otherwise raise an error. - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name The name of the remote * @param url The url to set * @return R_NilValue */ SEXP git2r_remote_set_url(SEXP repo, SEXP name, SEXP url) { - int err; + int error; git_repository *repository = NULL; if (git2r_arg_check_string(name)) @@ -364,15 +355,14 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_remote_set_url( + error = git_remote_set_url( repository, CHAR(STRING_ELT(name, 0)), CHAR(STRING_ELT(url, 0))); - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -381,7 +371,7 @@ /** * Get the remote's url * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param remote Character vector with name of remote. NA values are * ok and give NA values as result at corresponding index in url * vector @@ -389,7 +379,7 @@ */ SEXP git2r_remote_url(SEXP repo, SEXP remote) { - int err = GIT_OK; + int error = GIT_OK; SEXP url; size_t len; size_t i = 0; @@ -404,31 +394,30 @@ git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); len = LENGTH(remote); - PROTECT(url = allocVector(STRSXP, len)); + PROTECT(url = Rf_allocVector(STRSXP, len)); for (; i < len; i++) { if (NA_STRING == STRING_ELT(remote, i)) { SET_STRING_ELT(url, i, NA_STRING); } else { - err = git_remote_lookup( + error = git_remote_lookup( &tmp_remote, repository, CHAR(STRING_ELT(remote, i))); - if (err) + if (error) goto cleanup; - SET_STRING_ELT(url, i, mkChar(git_remote_url(tmp_remote))); + SET_STRING_ELT(url, i, Rf_mkChar(git_remote_url(tmp_remote))); git_remote_free(tmp_remote); } } cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); UNPROTECT(1); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return url; @@ -438,13 +427,9 @@ * Get the remote's url * * Based on https://github.com/libgit2/libgit2/blob/babdc376c7/examples/network/ls-remote.c - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name Character vector with URL of remote. * @return Character vector for each reference with the associated commit IDs. - * - * FIXME: When updating to libgit 0.26 + 1, change code to use - * 'git_remote_create_detached()' when repo is NULL, see CHANGELOG in - * libgit2. */ SEXP git2r_remote_ls(SEXP name, SEXP repo, SEXP credentials) { @@ -452,7 +437,7 @@ SEXP result = R_NilValue; SEXP names = R_NilValue; git_remote *remote = NULL; - int err; + int error, nprotect = 0; const git_remote_head **refs; size_t refs_len, i; git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT; @@ -464,15 +449,24 @@ if (git2r_arg_check_credentials(credentials)) git2r_error(__func__, NULL, "'credentials'", git2r_err_credentials_arg); - repository = git2r_repository_open(repo); - if (!repository) - git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); + if (!Rf_isNull(repo)) { + repository = git2r_repository_open(repo); + if (!repository) + git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); + } name_ = CHAR(STRING_ELT(name, 0)); - err = git_remote_lookup(&remote, repository, name_); - if (err) { - err = git_remote_create_anonymous(&remote, repository, name_); - if (err) + + if (repository) { + error = git_remote_lookup(&remote, repository, name_); + if (error) { + error = git_remote_create_anonymous(&remote, repository, name_); + if (error) + goto cleanup; + } + } else { + error = git_remote_create_anonymous(&remote, repository, name_); + if (error) goto cleanup; } @@ -480,32 +474,32 @@ callbacks.payload = &payload; callbacks.credentials = &git2r_cred_acquire_cb; - err = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL, NULL); - if (err) + error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL, NULL); + if (error) goto cleanup; - err = git_remote_ls(&refs, &refs_len, remote); - if (err) + error = git_remote_ls(&refs, &refs_len, remote); + if (error) goto cleanup; - PROTECT(result = allocVector(STRSXP, refs_len)); - setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, refs_len)); + PROTECT(result = Rf_allocVector(STRSXP, refs_len)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, refs_len)); for (i = 0; i < refs_len; i++) { char oid[GIT_OID_HEXSZ + 1] = {0}; git_oid_fmt(oid, &refs[i]->oid); - SET_STRING_ELT(result, i, mkChar(oid)); - SET_STRING_ELT(names, i, mkChar(refs[i]->name)); + SET_STRING_ELT(result, i, Rf_mkChar(oid)); + SET_STRING_ELT(names, i, Rf_mkChar(refs[i]->name)); } cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_repository.c r-cran-git2r-0.22.1/src/git2r_repository.c --- r-cran-git2r-0.21.0/src/git2r_repository.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_repository.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include #include "git2r_arg.h" #include "git2r_blob.h" @@ -24,36 +24,38 @@ #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" #include "git2r_tag.h" #include "git2r_tree.h" -#include "buffer.h" /** - * Get repo slot from S4 class git_repository + * Get repo from S3 class git_repository * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return a git_repository pointer on success else NULL */ git_repository* git2r_repository_open(SEXP repo) { - SEXP class_name; + int error; SEXP path; - git_repository *repository; - - if (isNull(repo) || S4SXP != TYPEOF(repo)) - return NULL; - - class_name = getAttrib(repo, R_ClassSymbol); - if (0 != strcmp(CHAR(STRING_ELT(class_name, 0)), "git_repository")) - return NULL; + git_repository *repository = NULL; - path = GET_SLOT(repo, Rf_install("path")); - if (git2r_arg_check_string(path)) + if (git2r_arg_check_repository(repo)) { + Rprintf("The repo argument is unexpectedly invalid\n"); return NULL; + } - if (git_repository_open(&repository, CHAR(STRING_ELT(path, 0))) < 0) + path = git2r_get_list_element(repo, "path"); + error = git_repository_open(&repository, CHAR(STRING_ELT(path, 0))); + if (error) { + if (error == GIT_ENOTFOUND) + Rf_warning("Could not find repository at path '%s'", CHAR(STRING_ELT(path, 0))); + else + Rf_warning("Unable to open repository: %s", giterr_last()->message); + git_repository_free(repository); return NULL; + } return repository; } @@ -88,24 +90,37 @@ git2r_fetch_head_cb_data *cb_data = (git2r_fetch_head_cb_data*)payload; /* Check if we have a list to populate */ - if (!isNull(cb_data->list)) { + if (!Rf_isNull(cb_data->list)) { char sha[GIT_OID_HEXSZ + 1]; SEXP fetch_head; - SEXP s_ref_name = Rf_install("ref_name"); - SEXP s_remote_url = Rf_install("remote_url"); - SEXP s_sha = Rf_install("sha"); - SEXP s_is_merge = Rf_install("is_merge"); - SEXP s_repo = Rf_install("repo"); - - PROTECT(fetch_head = NEW_OBJECT(MAKE_CLASS("git_fetch_head"))); - SET_VECTOR_ELT(cb_data->list, cb_data->n, fetch_head); - SET_SLOT(fetch_head, s_ref_name, mkString(ref_name)); - SET_SLOT(fetch_head, s_remote_url, mkString(remote_url)); + + SET_VECTOR_ELT( + cb_data->list, + cb_data->n, + fetch_head = Rf_mkNamed(VECSXP, git2r_S3_items__git_fetch_head)); + Rf_setAttrib(fetch_head, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_fetch_head)); + SET_VECTOR_ELT( + fetch_head, + git2r_S3_item__git_fetch_head__ref_name, + Rf_mkString(ref_name)); + SET_VECTOR_ELT( + fetch_head, + git2r_S3_item__git_fetch_head__remote_url, + Rf_mkString(remote_url)); git_oid_tostr(sha, sizeof(sha), oid); - SET_SLOT(fetch_head, s_sha, mkString(sha)); - SET_SLOT(fetch_head, s_is_merge, ScalarLogical(is_merge)); - SET_SLOT(fetch_head, s_repo, cb_data->repo); - UNPROTECT(1); + SET_VECTOR_ELT( + fetch_head, + git2r_S3_item__git_fetch_head__sha, + Rf_mkString(sha)); + SET_VECTOR_ELT( + fetch_head, + git2r_S3_item__git_fetch_head__is_merge, + Rf_ScalarLogical(is_merge)); + SET_VECTOR_ELT( + fetch_head, + git2r_S3_item__git_fetch_head__repo, + Rf_duplicate(cb_data->repo)); } cb_data->n += 1; @@ -116,13 +131,13 @@ /** * Get entries in FETCH_HEAD file * - * @param repo S4 class git_repository - * @return list with the S4 class git_fetch_head entries. R_NilValue + * @param repo S3 class git_repository + * @return list with the S3 class git_fetch_head entries. R_NilValue * if there is no FETCH_HEAD file. */ SEXP git2r_repository_fetch_heads(SEXP repo) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git2r_fetch_head_cb_data cb_data = {0, R_NilValue, R_NilValue}; git_repository *repository = NULL; @@ -132,34 +147,34 @@ git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); /* Count number of fetch heads before creating the list */ - err = git_repository_fetchhead_foreach( + error = git_repository_fetchhead_foreach( repository, git2r_repository_fetchhead_foreach_cb, &cb_data); - if (err) { - if (GIT_ENOTFOUND == err) - err = GIT_OK; + if (error) { + if (GIT_ENOTFOUND == error) + error = GIT_OK; goto cleanup; } - PROTECT(result = allocVector(VECSXP, cb_data.n)); + PROTECT(result = Rf_allocVector(VECSXP, cb_data.n)); + nprotect++; cb_data.n = 0; cb_data.list = result; cb_data.repo = repo; - err = git_repository_fetchhead_foreach( + error = git_repository_fetchhead_foreach( repository, git2r_repository_fetchhead_foreach_cb, &cb_data); cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -168,14 +183,14 @@ /** * Get head of repository * - * @param repo S4 class git_repository - * @return R_NilValue if unborn branch or not found. S4 class - * git_branch if not a detached head. S4 class git_commit if detached + * @param repo S3 class git_repository + * @return R_NilValue if unborn branch or not found. S3 class + * git_branch if not a detached head. S3 class git_commit if detached * head */ SEXP git2r_repository_head(SEXP repo) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git_commit *commit = NULL; git_reference *reference = NULL; @@ -185,10 +200,10 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_repository_head(&reference, repository); - if (err) { - if (GIT_EUNBORNBRANCH == err || GIT_ENOTFOUND == err) - err = GIT_OK; + error = git_repository_head(&reference, repository); + if (error) { + if (GIT_EUNBORNBRANCH == error || GIT_ENOTFOUND == error) + error = GIT_OK; goto cleanup; } @@ -196,33 +211,34 @@ git_branch_t type = GIT_BRANCH_LOCAL; if (git_reference_is_remote(reference)) type = GIT_BRANCH_REMOTE; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_branch"))); - err = git2r_branch_init(reference, type, repo, result); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_branch)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_branch)); + error = git2r_branch_init(reference, type, repo, result); } else { - err = git_commit_lookup( + error = git_commit_lookup( &commit, repository, git_reference_target(reference)); - if (err) + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_commit"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init(commit, repo, result); } cleanup: - if (commit) - git_commit_free(commit); - - if (reference) - git_reference_free(reference); - - if (repository) - git_repository_free(repository); + git_commit_free(commit); + git_reference_free(reference); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -240,7 +256,7 @@ */ SEXP git2r_repository_init(SEXP path, SEXP bare) { - int err; + int error; git_repository *repository = NULL; if (git2r_arg_check_string(path)) @@ -248,14 +264,13 @@ if (git2r_arg_check_logical(bare)) git2r_error(__func__, NULL, "'bare'", git2r_err_logical_arg); - err = git_repository_init(&repository, - CHAR(STRING_ELT(path, 0)), - LOGICAL(bare)[0]); - if (err) + error = git_repository_init(&repository, + CHAR(STRING_ELT(path, 0)), + LOGICAL(bare)[0]); + if (error) git2r_error(__func__, NULL, git2r_err_repo_init, NULL); - if (repository) - git_repository_free(repository); + git_repository_free(repository); return R_NilValue; } @@ -263,12 +278,11 @@ /** * Check if repository is bare. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return TRUE if bare else FALSE */ SEXP git2r_repository_is_bare(SEXP repo) { - SEXP result; int is_bare; git_repository *repository; @@ -278,26 +292,19 @@ is_bare = git_repository_is_bare(repository); git_repository_free(repository); - - PROTECT(result = allocVector(LGLSXP, 1)); - if (1 == is_bare) - LOGICAL(result)[0] = 1; - else - LOGICAL(result)[0] = 0; - UNPROTECT(1); - - return result; + if (is_bare < 0) + git2r_error(__func__, giterr_last(), NULL, NULL); + return Rf_ScalarLogical(is_bare); } /** * Determine if the repository was a shallow clone. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return TRUE if shallow else FALSE */ SEXP git2r_repository_is_shallow(SEXP repo) { - SEXP result; int is_shallow; git_repository *repository; @@ -309,26 +316,17 @@ git_repository_free(repository); if (is_shallow < 0) git2r_error(__func__, giterr_last(), NULL, NULL); - - PROTECT(result = allocVector(LGLSXP, 1)); - if (1 == is_shallow) - LOGICAL(result)[0] = 1; - else - LOGICAL(result)[0] = 0; - UNPROTECT(1); - - return result; + return Rf_ScalarLogical(is_shallow); } /** * Check if head of repository is detached * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return TRUE if detached else FALSE */ SEXP git2r_repository_head_detached(SEXP repo) { - SEXP result; int head_detached; git_repository *repository; @@ -340,26 +338,17 @@ git_repository_free(repository); if (head_detached < 0) git2r_error(__func__, giterr_last(), NULL, NULL); - - PROTECT(result = allocVector(LGLSXP, 1)); - if (1 == head_detached) - LOGICAL(result)[0] = 1; - else - LOGICAL(result)[0] = 0; - UNPROTECT(1); - - return result; + return Rf_ScalarLogical(head_detached); } /** * Check if repository is empty. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return TRUE if empty else FALSE */ SEXP git2r_repository_is_empty(SEXP repo) { - SEXP result; int is_empty; git_repository *repository; @@ -371,15 +360,7 @@ git_repository_free(repository); if (is_empty < 0) git2r_error(__func__, giterr_last(), NULL, NULL); - - PROTECT(result = allocVector(LGLSXP, 1)); - if (1 == is_empty) - LOGICAL(result)[0] = 1; - else - LOGICAL(result)[0] = 0; - UNPROTECT(1); - - return result; + return Rf_ScalarLogical(is_empty); } /** @@ -390,37 +371,30 @@ */ SEXP git2r_repository_can_open(SEXP path) { - SEXP result; - int can_open; + int error; git_repository *repository = NULL; if (git2r_arg_check_string(path)) git2r_error(__func__, NULL, "'path'", git2r_err_string_arg); - can_open = git_repository_open(&repository, CHAR(STRING_ELT(path, 0))); - if (repository) - git_repository_free(repository); - - PROTECT(result = allocVector(LGLSXP, 1)); - if (0 != can_open) - LOGICAL(result)[0] = 0; - else - LOGICAL(result)[0] = 1; - UNPROTECT(1); + error = git_repository_open(&repository, CHAR(STRING_ELT(path, 0))); + git_repository_free(repository); - return result; + if (error) + return Rf_ScalarLogical(0); + return Rf_ScalarLogical(1); } /** * Make the repository HEAD point to the specified reference. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param ref_name Canonical name of the reference the HEAD should point at * @return R_NilValue */ SEXP git2r_repository_set_head(SEXP repo, SEXP ref_name) { - int err; + int error; git_repository *repository = NULL; if (git2r_arg_check_string(ref_name)) @@ -432,12 +406,11 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_repository_set_head(repository, CHAR(STRING_ELT(ref_name, 0))); + error = git_repository_set_head(repository, CHAR(STRING_ELT(ref_name, 0))); - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -446,12 +419,12 @@ /** * Make the repository HEAD directly point to the commit. * - * @param commit S4 class git_commit + * @param commit S3 class git_commit * @return R_NilValue */ SEXP git2r_repository_set_head_detached(SEXP commit) { - int err; + int error; SEXP sha; git_oid oid; git_commit *treeish = NULL; @@ -460,31 +433,28 @@ if (git2r_arg_check_commit(commit)) git2r_error(__func__, NULL, "'commit'", git2r_err_commit_arg); - repository = git2r_repository_open(GET_SLOT(commit, Rf_install("repo"))); + repository = git2r_repository_open(git2r_get_list_element(commit, "repo")); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - sha = GET_SLOT(commit, Rf_install("sha")); - err = git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); - if (err) + sha = git2r_get_list_element(commit, "sha"); + error = git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); + if (error) goto cleanup; - err = git_commit_lookup(&treeish, repository, &oid); - if (err) + error = git_commit_lookup(&treeish, repository, &oid); + if (error) goto cleanup; - err = git_repository_set_head_detached( + error = git_repository_set_head_detached( repository, git_commit_id(treeish)); cleanup: - if (treeish) - git_commit_free(treeish); - - if (repository) - git_repository_free(repository); + git_commit_free(treeish); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -493,7 +463,7 @@ /** * Get workdir of repository. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @return R_NilValue if bare repository, else character vector * of length one with path. */ @@ -509,9 +479,9 @@ if (!git_repository_is_bare(repository)) { const char *wd = git_repository_workdir(repository); - PROTECT(result = allocVector(STRSXP, 1)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); nprotect++; - SET_STRING_ELT(result, 0, mkChar(wd)); + SET_STRING_ELT(result, 0, Rf_mkChar(wd)); } git_repository_free(repository); @@ -533,14 +503,14 @@ */ SEXP git2r_repository_discover(SEXP path, SEXP ceiling) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; - git_buf buf = GIT_BUF_INIT; + git_buf buf = GIT_BUF_INIT_CONST(NULL, 0); const char *ceiling_dirs = NULL; if (git2r_arg_check_string(path)) git2r_error(__func__, NULL, "'path'", git2r_err_string_arg); - if (!isNull(ceiling)) { + if (!Rf_isNull(ceiling)) { if (git2r_arg_check_string(ceiling)) git2r_error(__func__, NULL, "'ceiling'", git2r_err_string_arg); ceiling_dirs = CHAR(STRING_ELT(ceiling, 0)); @@ -549,28 +519,29 @@ /* note that across_fs (arg #3) is set to 0 so this will stop when * a filesystem device change is detected while exploring parent * directories */ - err = git_repository_discover( + error = git_repository_discover( &buf, CHAR(STRING_ELT(path, 0)), 0, ceiling_dirs); - if (err) { + if (error) { /* NB just return R_NilValue if we can't discover the repo */ - if (GIT_ENOTFOUND == err) - err = GIT_OK; + if (GIT_ENOTFOUND == error) + error = GIT_OK; goto cleanup; } - PROTECT(result = allocVector(STRSXP, 1)); - SET_STRING_ELT(result, 0, mkChar(buf.ptr)); + PROTECT(result = Rf_allocVector(STRSXP, 1)); + nprotect++; + SET_STRING_ELT(result, 0, Rf_mkChar(buf.ptr)); cleanup: git_buf_free(&buf); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_repository.h r-cran-git2r-0.22.1/src/git2r_repository.h --- r-cran-git2r-0.21.0/src/git2r_repository.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_repository.h 2018-07-10 13:23:34.000000000 +0000 @@ -22,7 +22,7 @@ #include #include -#include "git2.h" +#include git_repository* git2r_repository_open(SEXP repo); SEXP git2r_repository_can_open(SEXP path); diff -Nru r-cran-git2r-0.21.0/src/git2r_reset.c r-cran-git2r-0.22.1/src/git2r_reset.c --- r-cran-git2r-0.21.0/src/git2r_reset.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_reset.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2016 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,14 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" #include "git2r_reset.h" +#include "git2r_S3.h" #include "git2r_signature.h" /** @@ -39,7 +39,7 @@ */ SEXP git2r_reset(SEXP commit, SEXP reset_type) { - int err; + int error; SEXP repo; git_commit *target = NULL; git_repository *repository = NULL; @@ -49,29 +49,26 @@ if (git2r_arg_check_integer(reset_type)) git2r_error(__func__, NULL, "'reset_type'", git2r_err_integer_arg); - repo = GET_SLOT(commit, Rf_install("repo")); + repo = git2r_get_list_element(commit, "repo"); repository = git2r_repository_open(repo); if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_commit_lookup(&target, repository, commit); - if (err) + error = git2r_commit_lookup(&target, repository, commit); + if (error) goto cleanup; - err = git_reset( + error = git_reset( repository, (git_object*)target, INTEGER(reset_type)[0], NULL); cleanup: - if (target) - git_commit_free(target); + git_commit_free(target); + git_repository_free(repository); - if (repository) - git_repository_free(repository); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -80,13 +77,13 @@ /** * Updates some entries in the index from the HEAD commit tree. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param path The paths to reset * @return R_NilValue */ SEXP git2r_reset_default(SEXP repo, SEXP path) { - int err = 0; + int error = 0; git_strarray pathspec = {0}; git_reference *head = NULL; git_object *head_commit = NULL; @@ -99,34 +96,27 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_copy_string_vec(&pathspec, path); - if (err || !pathspec.count) + error = git2r_copy_string_vec(&pathspec, path); + if (error || !pathspec.count) goto cleanup; - err = git_repository_head(&head, repository); - if (err) + error = git_repository_head(&head, repository); + if (error) goto cleanup; - err = git_reference_peel(&head_commit, head, GIT_OBJ_COMMIT); - if (err) + error = git_reference_peel(&head_commit, head, GIT_OBJ_COMMIT); + if (error) goto cleanup; - err = git_reset_default(repository, head_commit, &pathspec); + error = git_reset_default(repository, head_commit, &pathspec); cleanup: - if (head) - git_reference_free(head); - - if (head_commit) - git_object_free(head_commit); - - if (pathspec.strings) - free(pathspec.strings); - - if (repository) - git_repository_free(repository); + git_reference_free(head); + git_object_free(head_commit); + free(pathspec.strings); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; diff -Nru r-cran-git2r-0.21.0/src/git2r_revparse.c r-cran-git2r-0.22.1/src/git2r_revparse.c --- r-cran-git2r-0.21.0/src/git2r_revparse.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_revparse.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,27 +16,28 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" +#include "git2r_blob.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_tag.h" #include "git2r_tree.h" /** * Find object specified by revision * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param revision The revision string, see * http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions - * @return S4 object of class git_commit, git_tag or git_tree. + * @return S3 object of class git_commit, git_tag or git_tree. */ SEXP git2r_revparse_single(SEXP repo, SEXP revision) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git_repository *repository = NULL; git_object *treeish = NULL; @@ -48,44 +49,57 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_revparse_single( + error = git_revparse_single( &treeish, repository, CHAR(STRING_ELT(revision, 0))); - if (err) + if (error) goto cleanup; switch (git_object_type(treeish)) { + case GIT_OBJ_BLOB: + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_blob)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blob)); + git2r_blob_init((git_blob*)treeish, repo, result); + break; case GIT_OBJ_COMMIT: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_commit"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init((git_commit*)treeish, repo, result); break; case GIT_OBJ_TAG: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_tag"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_tag)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tag)); git2r_tag_init((git_tag*)treeish, repo, result); break; case GIT_OBJ_TREE: - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_tree"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_tree)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tree)); git2r_tree_init((git_tree*)treeish, repo, result); break; default: giterr_set_str(GITERR_NONE, git2r_err_revparse_single); - err = GIT_ERROR; + error = GIT_ERROR; break; } cleanup: - if (treeish) - git_object_free(treeish); - - if (repository) - git_repository_free(repository); + git_object_free(treeish); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) { - if (GIT_ENOTFOUND == err) { + if (error) { + if (GIT_ENOTFOUND == error) { git2r_error( __func__, NULL, diff -Nru r-cran-git2r-0.21.0/src/git2r_revwalk.c r-cran-git2r-0.22.1/src/git2r_revwalk.c --- r-cran-git2r-0.21.0/src/git2r_revwalk.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_revwalk.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,13 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" +#include #include "git2r_arg.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" /** * Count number of revisions. @@ -50,7 +50,7 @@ /** * List revisions * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param topological Sort the commits by topological order; Can be * combined with time. * @param time Sort the commits by commit time; can be combined with @@ -58,7 +58,7 @@ * @param reverse Sort the commits in reverse order * @param max_n n The upper limit of the number of commits to * output. Use max_n < 0 for unlimited number of commits. - * @return list with S4 class git_commit objects + * @return list with S3 class git_commit objects */ SEXP git2r_revwalk_list( SEXP repo, @@ -67,7 +67,7 @@ SEXP reverse, SEXP max_n) { - int err = GIT_OK; + int error = GIT_OK, nprotect = 0; SEXP result = R_NilValue; int i, n; unsigned int sort_mode = GIT_SORT_NONE; @@ -89,7 +89,8 @@ if (git_repository_is_empty(repository)) { /* No commits, create empty list */ - PROTECT(result = allocVector(VECSXP, 0)); + PROTECT(result = Rf_allocVector(VECSXP, 0)); + nprotect++; goto cleanup; } @@ -100,12 +101,12 @@ if (LOGICAL(reverse)[0]) sort_mode |= GIT_SORT_REVERSE; - err = git_revwalk_new(&walker, repository); - if (err) + error = git_revwalk_new(&walker, repository); + if (error) goto cleanup; - err = git_revwalk_push_head(walker); - if (err) + error = git_revwalk_push_head(walker); + if (error) goto cleanup; git_revwalk_sorting(walker, sort_mode); @@ -113,11 +114,12 @@ n = git2r_revwalk_count(walker, INTEGER(max_n)[0]); /* Create list to store result */ - PROTECT(result = allocVector(VECSXP, n)); + PROTECT(result = Rf_allocVector(VECSXP, n)); + nprotect++; git_revwalk_reset(walker); - err = git_revwalk_push_head(walker); - if (err) + error = git_revwalk_push_head(walker); + if (error) goto cleanup; git_revwalk_sorting(walker, sort_mode); @@ -126,33 +128,35 @@ SEXP item; git_oid oid; - err = git_revwalk_next(&oid, walker); - if (err) { - if (GIT_ITEROVER == err) - err = GIT_OK; + error = git_revwalk_next(&oid, walker); + if (error) { + if (GIT_ITEROVER == error) + error = GIT_OK; goto cleanup; } - err = git_commit_lookup(&commit, repository, &oid); - if (err) + error = git_commit_lookup(&commit, repository, &oid); + if (error) goto cleanup; - SET_VECTOR_ELT(result, i, item = NEW_OBJECT(MAKE_CLASS("git_commit"))); + SET_VECTOR_ELT( + result, + i, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init(commit, repo, item); git_commit_free(commit); } cleanup: - if (walker) - git_revwalk_free(walker); + git_revwalk_free(walker); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -161,13 +165,13 @@ /** * Get list with contributions. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param topological Sort the commits by topological order; Can be * combined with time. * @param time Sort the commits by commit time; can be combined with * topological. * @param reverse Sort the commits in reverse order - * @return list with S4 class git_commit objects + * @return list with S3 class git_commit objects */ SEXP git2r_revwalk_contributions( SEXP repo, @@ -175,7 +179,7 @@ SEXP time, SEXP reverse) { - int err = GIT_OK; + int error = GIT_OK, nprotect = 0; SEXP result = R_NilValue; SEXP names = R_NilValue; SEXP when = R_NilValue; @@ -207,12 +211,12 @@ if (LOGICAL(reverse)[0]) sort_mode |= GIT_SORT_REVERSE; - err = git_revwalk_new(&walker, repository); - if (err) + error = git_revwalk_new(&walker, repository); + if (error) goto cleanup; - err = git_revwalk_push_head(walker); - if (err) + error = git_revwalk_push_head(walker); + if (error) goto cleanup; git_revwalk_sorting(walker, sort_mode); @@ -220,18 +224,19 @@ n = git2r_revwalk_count(walker, -1); /* Create vectors to store result */ - PROTECT(result = allocVector(VECSXP, 3)); - setAttrib(result, R_NamesSymbol, names = allocVector(STRSXP, 3)); - SET_VECTOR_ELT(result, 0, when = allocVector(REALSXP, n)); - SET_STRING_ELT(names, 0, mkChar("when")); - SET_VECTOR_ELT(result, 1, author = allocVector(STRSXP, n)); - SET_STRING_ELT(names, 1, mkChar("author")); - SET_VECTOR_ELT(result, 2, email = allocVector(STRSXP, n)); - SET_STRING_ELT(names, 2, mkChar("email")); + PROTECT(result = Rf_allocVector(VECSXP, 3)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, 3)); + SET_VECTOR_ELT(result, 0, when = Rf_allocVector(REALSXP, n)); + SET_STRING_ELT(names, 0, Rf_mkChar("when")); + SET_VECTOR_ELT(result, 1, author = Rf_allocVector(STRSXP, n)); + SET_STRING_ELT(names, 1, Rf_mkChar("author")); + SET_VECTOR_ELT(result, 2, email = Rf_allocVector(STRSXP, n)); + SET_STRING_ELT(names, 2, Rf_mkChar("email")); git_revwalk_reset(walker); - err = git_revwalk_push_head(walker); - if (err) + error = git_revwalk_push_head(walker); + if (error) goto cleanup; git_revwalk_sorting(walker, sort_mode); @@ -240,37 +245,34 @@ const git_signature *c_author; git_oid oid; - err = git_revwalk_next(&oid, walker); - if (err) { - if (GIT_ITEROVER == err) - err = GIT_OK; + error = git_revwalk_next(&oid, walker); + if (error) { + if (GIT_ITEROVER == error) + error = GIT_OK; goto cleanup; } - err = git_commit_lookup(&commit, repository, &oid); - if (err) + error = git_commit_lookup(&commit, repository, &oid); + if (error) goto cleanup; c_author = git_commit_author(commit); REAL(when)[i] = (double)(c_author->when.time) + 60.0 * (double)(c_author->when.offset); - SET_STRING_ELT(author, i, mkChar(c_author->name)); - SET_STRING_ELT(author, i, mkChar(c_author->email)); + SET_STRING_ELT(author, i, Rf_mkChar(c_author->name)); + SET_STRING_ELT(author, i, Rf_mkChar(c_author->email)); git_commit_free(commit); } cleanup: - if (walker) - git_revwalk_free(walker); - - if (repository) - git_repository_free(repository); + git_revwalk_free(walker); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_S3.c r-cran-git2r-0.22.1/src/git2r_S3.c --- r-cran-git2r-0.21.0/src/git2r_S3.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_S3.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,126 @@ +/* + * git2r, R bindings to the libgit2 library. + * Copyright (C) 2013-2018 The git2r contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * git2r is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +#include "git2r_S3.h" + +const char *git2r_S3_class__git_blame = "git_blame"; +const char *git2r_S3_items__git_blame[] = { + "path", "hunks", "repo", ""}; + +const char *git2r_S3_class__git_blame_hunk = "git_blame_hunk"; +const char *git2r_S3_items__git_blame_hunk[] = { + "lines_in_hunk", "final_commit_id", "final_start_line_number", + "final_signature", "orig_commit_id", "orig_start_line_number", + "orig_signature", "orig_path", "boundary", "repo", ""}; + +const char *git2r_S3_class__git_blob = "git_blob"; +const char *git2r_S3_items__git_blob[] = { + "sha", "repo", ""}; + +const char *git2r_S3_class__git_branch = "git_branch"; +const char *git2r_S3_items__git_branch[] = { + "name", "type", "repo", ""}; + +const char *git2r_S3_class__git_commit = "git_commit"; +const char *git2r_S3_items__git_commit[] = { + "sha", "author", "committer", "summary", "message", "repo", ""}; + +const char *git2r_S3_class__git_diff = "git_diff"; +const char *git2r_S3_items__git_diff[] = { + "old", "new", "files", ""}; + +const char *git2r_S3_class__git_diff_file = "git_diff_file"; +const char *git2r_S3_items__git_diff_file[] = { + "old_file", "new_file", "hunks", ""}; + +const char *git2r_S3_class__git_diff_hunk = "git_diff_hunk"; +const char *git2r_S3_items__git_diff_hunk[] = { + "old_start", "old_lines", "new_start", "new_lines", "header", "lines", ""}; + +const char *git2r_S3_class__git_diff_line = "git_diff_line"; +const char *git2r_S3_items__git_diff_line[] = { + "origin", "old_lineno", "new_lineno", "num_lines", "content", ""}; + +const char *git2r_S3_class__git_fetch_head = "git_fetch_head"; +const char *git2r_S3_items__git_fetch_head[] = { + "ref_name", "remote_url", "sha", "is_merge", "repo", ""}; + +const char *git2r_S3_class__git_merge_result = "git_merge_result"; +const char *git2r_S3_items__git_merge_result[] = { + "up_to_date", "fast_forward", "conflicts", "sha", ""}; + +const char *git2r_S3_class__git_note = "git_note"; +const char *git2r_S3_items__git_note[] = { + "sha", "annotated", "message", "refname", "repo", ""}; + +const char *git2r_S3_class__git_reference = "git_reference"; +const char *git2r_S3_items__git_reference[] = { + "name", "type", "sha", "target", "shorthand", ""}; + +const char *git2r_S3_class__git_reflog_entry = "git_reflog_entry"; +const char *git2r_S3_items__git_reflog_entry[] = { + "sha", "message", "index", "committer", "refname", "repo", ""}; + +const char *git2r_S3_class__git_repository = "git_repository"; +const char *git2r_S3_items__git_repository[] = { + "path", ""}; + +const char *git2r_S3_class__git_signature = "git_signature"; +const char *git2r_S3_items__git_signature[] = { + "name", "email", "when", ""}; + +const char *git2r_S3_class__git_tag = "git_tag"; +const char *git2r_S3_items__git_tag[] = { + "sha", "message", "name", "tagger", "target", "repo", ""}; + +const char *git2r_S3_class__git_time = "git_time"; +const char *git2r_S3_items__git_time[] = { + "time", "offset", ""}; + +const char *git2r_S3_class__git_transfer_progress = "git_transfer_progress"; +const char *git2r_S3_items__git_transfer_progress[] = { + "total_objects", "indexed_objects", "received_objects", + "local_objects", "total_deltas", "indexed_deltas", + "received_bytes", ""}; + +const char *git2r_S3_class__git_tree = "git_tree"; +const char *git2r_S3_items__git_tree[] = { + "sha", "filemode", "type", "id", "name", "repo", ""}; + +/** + * Get the list element named str, or return NULL. + * + * From the manual 'Writing R Extensions' + * (https://cran.r-project.org/doc/manuals/r-release/R-exts.html) + */ +SEXP git2r_get_list_element(SEXP list, const char *str) +{ + int i = 0; + SEXP elmt = R_NilValue, names = Rf_getAttrib(list, R_NamesSymbol); + + for (; i < Rf_length(list); i++) { + if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) { + elmt = VECTOR_ELT(list, i); + break; + } + } + + return elmt; +} diff -Nru r-cran-git2r-0.21.0/src/git2r_S3.h r-cran-git2r-0.22.1/src/git2r_S3.h --- r-cran-git2r-0.21.0/src/git2r_S3.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_S3.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,198 @@ +/* + * git2r, R bindings to the libgit2 library. + * Copyright (C) 2013-2018 The git2r contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, + * as published by the Free Software Foundation. + * + * git2r is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef INCLUDE_git2r_S3_h +#define INCLUDE_git2r_S3_h + +#include +#include + +extern const char *git2r_S3_class__git_blame; +extern const char *git2r_S3_items__git_blame[]; +enum { + git2r_S3_item__git_blame__path, + git2r_S3_item__git_blame__hunks, + git2r_S3_item__git_blame__repo}; + +extern const char *git2r_S3_class__git_blame_hunk; +extern const char *git2r_S3_items__git_blame_hunk[]; +enum { + git2r_S3_item__git_blame_hunk__lines_in_hunk, + git2r_S3_item__git_blame_hunk__final_commit_id, + git2r_S3_item__git_blame_hunk__final_start_line_number, + git2r_S3_item__git_blame_hunk__final_signature, + git2r_S3_item__git_blame_hunk__orig_commit_id, + git2r_S3_item__git_blame_hunk__orig_start_line_number, + git2r_S3_item__git_blame_hunk__orig_signature, + git2r_S3_item__git_blame_hunk__orig_path, + git2r_S3_item__git_blame_hunk__boundary, + git2r_S3_item__git_blame_hunk__repo}; + +extern const char *git2r_S3_class__git_blob; +extern const char *git2r_S3_items__git_blob[]; +enum { + git2r_S3_item__git_blob__sha, + git2r_S3_item__git_blob__repo}; + +extern const char *git2r_S3_class__git_branch; +extern const char *git2r_S3_items__git_branch[]; +enum { + git2r_S3_item__git_branch__name, + git2r_S3_item__git_branch__type, + git2r_S3_item__git_branch__repo}; + +extern const char *git2r_S3_class__git_commit; +extern const char *git2r_S3_items__git_commit[]; +enum { + git2r_S3_item__git_commit__sha, + git2r_S3_item__git_commit__author, + git2r_S3_item__git_commit__committer, + git2r_S3_item__git_commit__summary, + git2r_S3_item__git_commit__message, + git2r_S3_item__git_commit__repo}; + +extern const char *git2r_S3_class__git_diff; +extern const char *git2r_S3_items__git_diff[]; +enum { + git2r_S3_item__git_diff__old, + git2r_S3_item__git_diff__new, + git2r_S3_item__git_diff__files}; + +extern const char *git2r_S3_class__git_diff_file; +extern const char *git2r_S3_items__git_diff_file[]; +enum { + git2r_S3_item__git_diff_file__old_file, + git2r_S3_item__git_diff_file__new_file, + git2r_S3_item__git_diff_file__hunks}; + +extern const char *git2r_S3_class__git_diff_hunk; +extern const char *git2r_S3_items__git_diff_hunk[]; +enum { + git2r_S3_item__git_diff_hunk__old_start, + git2r_S3_item__git_diff_hunk__old_lines, + git2r_S3_item__git_diff_hunk__new_start, + git2r_S3_item__git_diff_hunk__new_lines, + git2r_S3_item__git_diff_hunk__header, + git2r_S3_item__git_diff_hunk__lines}; + +extern const char *git2r_S3_class__git_diff_line; +extern const char *git2r_S3_items__git_diff_line[]; +enum { + git2r_S3_item__git_diff_line__origin, + git2r_S3_item__git_diff_line__old_lineno, + git2r_S3_item__git_diff_line__new_lineno, + git2r_S3_item__git_diff_line__num_lines, + git2r_S3_item__git_diff_line__content}; + +extern const char *git2r_S3_class__git_fetch_head; +extern const char *git2r_S3_items__git_fetch_head[]; +enum { + git2r_S3_item__git_fetch_head__ref_name, + git2r_S3_item__git_fetch_head__remote_url, + git2r_S3_item__git_fetch_head__sha, + git2r_S3_item__git_fetch_head__is_merge, + git2r_S3_item__git_fetch_head__repo}; + +extern const char *git2r_S3_class__git_merge_result; +extern const char *git2r_S3_items__git_merge_result[]; +enum { + git2r_S3_item__git_merge_result__up_to_date, + git2r_S3_item__git_merge_result__fast_forward, + git2r_S3_item__git_merge_result__conflicts, + git2r_S3_item__git_merge_result__sha}; + +extern const char *git2r_S3_class__git_note; +extern const char *git2r_S3_items__git_note[]; +enum { + git2r_S3_item__git_note__sha, + git2r_S3_item__git_note__annotated, + git2r_S3_item__git_note__message, + git2r_S3_item__git_note__refname, + git2r_S3_item__git_note__repo}; + +extern const char *git2r_S3_class__git_reference; +extern const char *git2r_S3_items__git_reference[]; +enum { + git2r_S3_item__git_reference__name, + git2r_S3_item__git_reference__type, + git2r_S3_item__git_reference__sha, + git2r_S3_item__git_reference__target, + git2r_S3_item__git_reference__shorthand}; + +extern const char *git2r_S3_class__git_reflog_entry; +extern const char *git2r_S3_items__git_reflog_entry[]; +enum { + git2r_S3_item__git_reflog_entry__sha, + git2r_S3_item__git_reflog_entry__message, + git2r_S3_item__git_reflog_entry__index, + git2r_S3_item__git_reflog_entry__committer, + git2r_S3_item__git_reflog_entry__refname, + git2r_S3_item__git_reflog_entry__repo}; + +extern const char *git2r_S3_class__git_repository; +extern const char *git2r_S3_items__git_repository[]; +enum { + git2r_S3_item__git_repository__path}; + +extern const char *git2r_S3_class__git_signature; +extern const char *git2r_S3_items__git_signature[]; +enum { + git2r_S3_item__git_signature__name, + git2r_S3_item__git_signature__email, + git2r_S3_item__git_signature__when}; + +extern const char *git2r_S3_class__git_tag; +extern const char *git2r_S3_items__git_tag[]; +enum { + git2r_S3_item__git_tag__sha, + git2r_S3_item__git_tag__message, + git2r_S3_item__git_tag__name, + git2r_S3_item__git_tag__tagger, + git2r_S3_item__git_tag__target, + git2r_S3_item__git_tag__repo}; + +extern const char *git2r_S3_class__git_time; +extern const char *git2r_S3_items__git_time[]; +enum { + git2r_S3_item__git_time__time, + git2r_S3_item__git_time__offset}; + +extern const char *git2r_S3_class__git_transfer_progress; +extern const char *git2r_S3_items__git_transfer_progress[]; +enum { + git2r_S3_item__git_transfer_progress__total_objects, + git2r_S3_item__git_transfer_progress__indexed_objects, + git2r_S3_item__git_transfer_progress__received_objects, + git2r_S3_item__git_transfer_progress__local_objects, + git2r_S3_item__git_transfer_progress__total_deltas, + git2r_S3_item__git_transfer_progress__indexed_deltas, + git2r_S3_item__git_transfer_progress__received_bytes}; + +extern const char *git2r_S3_class__git_tree; +extern const char *git2r_S3_items__git_tree[]; +enum { + git2r_S3_item__git_tree__sha, + git2r_S3_item__git_tree__filemode, + git2r_S3_item__git_tree__type, + git2r_S3_item__git_tree__id, + git2r_S3_item__git_tree__name, + git2r_S3_item__git_tree__repo}; + +SEXP git2r_get_list_element(SEXP list, const char *str); + +#endif diff -Nru r-cran-git2r-0.21.0/src/git2r_signature.c r-cran-git2r-0.22.1/src/git2r_signature.c --- r-cran-git2r-0.21.0/src/git2r_signature.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_signature.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,20 +16,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" /** * Get the configured signature for a repository * - * @param repo S4 class git_repository - * @return S4 class git_signature + * @param repo S3 class git_repository + * @return S3 class git_signature */ SEXP git2r_signature_default(SEXP repo) { - int err; + int error, nprotect = 0; git_repository *repository = NULL; git_signature *signature = NULL; SEXP result = R_NilValue; @@ -38,24 +38,24 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_signature_default(&signature, repository); - if (err) + error = git_signature_default(&signature, repository); + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_signature"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); git2r_signature_init(signature, result); cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); + git_signature_free(signature); - if (signature) - git_signature_free(signature); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -65,44 +65,59 @@ * Init signature from SEXP signature argument * * @param out new signature - * @param signature SEXP argument with S4 class git_signature - * @return void + * @param signature SEXP argument with S3 class git_signature + * @return 0 or an error code */ int git2r_signature_from_arg(git_signature **out, SEXP signature) { - int err; - SEXP when; + SEXP when = git2r_get_list_element(signature, "when"); - when = GET_SLOT(signature, Rf_install("when")); - err = git_signature_new( + return git_signature_new( out, - CHAR(STRING_ELT(GET_SLOT(signature, Rf_install("name")), 0)), - CHAR(STRING_ELT(GET_SLOT(signature, Rf_install("email")), 0)), - REAL(GET_SLOT(when, Rf_install("time")))[0], - REAL(GET_SLOT(when, Rf_install("offset")))[0]); - - return err; + CHAR(STRING_ELT(git2r_get_list_element(signature, "name"), 0)), + CHAR(STRING_ELT(git2r_get_list_element(signature, "email"), 0)), + REAL(git2r_get_list_element(when, "time"))[0], + REAL(git2r_get_list_element(when, "offset"))[0]); } /** - * Init slots in S4 class git_signature. + * Init slots in S3 class git_signature. * * @param source A git signature - * @param dest S4 class git_signature to initialize + * @param dest S3 class git_signature to initialize * @return void */ void git2r_signature_init(const git_signature *source, SEXP dest) { SEXP when; - SEXP s_name = Rf_install("name"); - SEXP s_email = Rf_install("email"); - SEXP s_time = Rf_install("time"); - SEXP s_offset = Rf_install("offset"); - - SET_SLOT(dest, s_name, mkString(source->name)); - SET_SLOT(dest, s_email, mkString(source->email)); - - when = GET_SLOT(dest, Rf_install("when")); - SET_SLOT(when, s_time, ScalarReal((double)source->when.time)); - SET_SLOT(when, s_offset, ScalarReal((double)source->when.offset)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_signature__name, + Rf_mkString(source->name)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_signature__email, + Rf_mkString(source->email)); + + when = VECTOR_ELT(dest, git2r_S3_item__git_signature__when); + if (Rf_isNull(when)) { + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_signature__when, + when = Rf_mkNamed(VECSXP, git2r_S3_items__git_time)); + Rf_setAttrib(when, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_time)); + } + + SET_VECTOR_ELT( + when, + git2r_S3_item__git_time__time, + Rf_ScalarReal((double)source->when.time)); + + SET_VECTOR_ELT( + when, + git2r_S3_item__git_time__offset, + Rf_ScalarReal((double)source->when.offset)); } diff -Nru r-cran-git2r-0.21.0/src/git2r_signature.h r-cran-git2r-0.22.1/src/git2r_signature.h --- r-cran-git2r-0.21.0/src/git2r_signature.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_signature.h 2018-07-10 13:23:34.000000000 +0000 @@ -21,7 +21,7 @@ #include #include -#include "git2.h" +#include SEXP git2r_signature_default(SEXP repo); int git2r_signature_from_arg(git_signature **out, SEXP signature); diff -Nru r-cran-git2r-0.21.0/src/git2r_stash.c r-cran-git2r-0.22.1/src/git2r_stash.c --- r-cran-git2r-0.21.0/src/git2r_stash.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_stash.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,14 +16,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include "git2.h" -#include "cc-compat.h" +#include #include "git2r_arg.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" #include "git2r_stash.h" @@ -39,15 +38,44 @@ } git2r_stash_list_cb_data; /** + * Apply a single stashed state from the stash list. + * + * @param repo S3 class git_repository that contains the stash + * @param index The index to the stash. 0 is the most recent stash. + * @return R_NilValue + */ +SEXP git2r_stash_apply(SEXP repo, SEXP index) +{ + int error; + git_repository *repository = NULL; + + if (git2r_arg_check_integer_gte_zero(index)) + git2r_error(__func__, NULL, "'index'", git2r_err_integer_gte_zero_arg); + + repository = git2r_repository_open(repo); + if (!repository) + git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); + + error = git_stash_apply(repository, INTEGER(index)[0], NULL); + if (error == GIT_ENOTFOUND) + error = 0; + git_repository_free(repository); + if (error) + git2r_error(__func__, giterr_last(), NULL, NULL); + + return R_NilValue; +} + +/** * Remove a stash from the stash list * - * @param repo S4 class git_repository that contains the stash + * @param repo S3 class git_repository that contains the stash * @param index The index to the stash. 0 is the most recent stash. * @return R_NilValue */ SEXP git2r_stash_drop(SEXP repo, SEXP index) { - int err; + int error; git_repository *repository = NULL; if (git2r_arg_check_integer_gte_zero(index)) @@ -57,21 +85,51 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_stash_drop(repository, INTEGER(index)[0]); + error = git_stash_drop(repository, INTEGER(index)[0]); git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; } /** - * Init slots in S4 class git_stash + * Apply a single stashed state from the stash list and remove it from + * the list if successful. + * + * @param repo S3 class git_repository that contains the stash + * @param index The index to the stash. 0 is the most recent stash. + * @return R_NilValue + */ +SEXP git2r_stash_pop(SEXP repo, SEXP index) +{ + int error; + git_repository *repository = NULL; + + if (git2r_arg_check_integer_gte_zero(index)) + git2r_error(__func__, NULL, "'index'", git2r_err_integer_gte_zero_arg); + + repository = git2r_repository_open(repo); + if (!repository) + git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); + + error = git_stash_pop(repository, INTEGER(index)[0], NULL); + if (error == GIT_ENOTFOUND) + error = 0; + git_repository_free(repository); + if (error) + git2r_error(__func__, giterr_last(), NULL, NULL); + + return R_NilValue; +} + +/** + * Init slots in S3 class git_stash * * @param source The commit oid of the stashed state. * @param repository The repository - * @param repo S4 class git_repository that contains the stash - * @param dest S4 class git_stash to initialize + * @param repo S3 class git_repository that contains the stash + * @param dest S3 class git_stash to initialize * @return int 0 on success, or an error code. */ int git2r_stash_init( @@ -80,12 +138,12 @@ SEXP repo, SEXP dest) { - int err; + int error; git_commit *commit = NULL; - err = git_commit_lookup(&commit, repository, source); - if (err) - return err; + error = git_commit_lookup(&commit, repository, source); + if (error) + return error; git2r_commit_init(commit, repo, dest); git_commit_free(commit); @@ -110,25 +168,26 @@ { git2r_stash_list_cb_data *cb_data = (git2r_stash_list_cb_data*)payload; - GIT_UNUSED(index); - GIT_UNUSED(message); - /* Check if we have a list to populate */ - if (!isNull(cb_data->list)) { - int err; - SEXP stash; + if (!Rf_isNull(cb_data->list)) { + int error; + SEXP stash, class; SET_VECTOR_ELT( cb_data->list, cb_data->n, - stash = NEW_OBJECT(MAKE_CLASS("git_stash"))); - err = git2r_stash_init( + stash = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + Rf_setAttrib(stash, R_ClassSymbol, class = Rf_allocVector(STRSXP, 2)); + SET_STRING_ELT(class, 0, Rf_mkChar("git_stash")); + SET_STRING_ELT(class, 1, Rf_mkChar("git_commit")); + + error = git2r_stash_init( stash_id, cb_data->repository, cb_data->repo, stash); - if (err) - return err; + if (error) + return error; } cb_data->n += 1; @@ -139,13 +198,13 @@ /** * List stashes in a repository * - * @param repo S4 class git_repository - * @return VECXSP with S4 objects of class git_stash + * @param repo S3 class git_repository + * @return VECXSP with S3 objects of class git_stash */ SEXP git2r_stash_list(SEXP repo) { SEXP list = R_NilValue; - int err; + int error, nprotect = 0; git2r_stash_list_cb_data cb_data = {0, R_NilValue, R_NilValue, NULL}; git_repository *repository = NULL; @@ -154,25 +213,25 @@ git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); /* Count number of stashes before creating the list */ - err = git_stash_foreach(repository, &git2r_stash_list_cb, &cb_data); - if (err) + error = git_stash_foreach(repository, &git2r_stash_list_cb, &cb_data); + if (error) goto cleanup; - PROTECT(list = allocVector(VECSXP, cb_data.n)); + PROTECT(list = Rf_allocVector(VECSXP, cb_data.n)); + nprotect++; cb_data.n = 0; cb_data.list = list; cb_data.repo = repo; cb_data.repository = repository; - err = git_stash_foreach(repository, &git2r_stash_list_cb, &cb_data); + error = git_stash_foreach(repository, &git2r_stash_list_cb, &cb_data); cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(list)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return list; @@ -190,7 +249,7 @@ * @param ignored All ignored files are also stashed and then cleaned * up from the working directory. Default is FALSE * @param stasher Signature with stasher and time of stash - * @return S4 class git_stash + * @return S3 class git_stash */ SEXP git2r_stash_save( SEXP repo, @@ -200,8 +259,8 @@ SEXP ignored, SEXP stasher) { - int err; - SEXP result = R_NilValue; + int error, nprotect = 0; + SEXP result = R_NilValue, class; git_oid oid; git_stash_flags flags = GIT_STASH_DEFAULT; git_commit *commit = NULL; @@ -228,39 +287,38 @@ if (LOGICAL(ignored)[0]) flags |= GIT_STASH_INCLUDE_IGNORED; - err = git2r_signature_from_arg(&c_stasher, stasher); - if (err) + error = git2r_signature_from_arg(&c_stasher, stasher); + if (error) goto cleanup; - err = git_stash_save( + error = git_stash_save( &oid, repository, c_stasher, CHAR(STRING_ELT(message, 0)), flags); - if (err) { - if (GIT_ENOTFOUND == err) - err = GIT_OK; + if (error) { + if (GIT_ENOTFOUND == error) + error = GIT_OK; goto cleanup; } - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_stash"))); - err = git2r_stash_init(&oid, repository, repo, result); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, class = Rf_allocVector(STRSXP, 2)); + SET_STRING_ELT(class, 0, Rf_mkChar("git_stash")); + SET_STRING_ELT(class, 1, Rf_mkChar("git_commit")); + error = git2r_stash_init(&oid, repository, repo, result); cleanup: - if (commit) - git_commit_free(commit); - - if (c_stasher) - git_signature_free(c_stasher); - - if (repository) - git_repository_free(repository); + git_commit_free(commit); + git_signature_free(c_stasher); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_stash.h r-cran-git2r-0.22.1/src/git2r_stash.h --- r-cran-git2r-0.21.0/src/git2r_stash.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_stash.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -22,7 +22,9 @@ #include #include +SEXP git2r_stash_apply(SEXP repo, SEXP index); SEXP git2r_stash_drop(SEXP repo, SEXP index); +SEXP git2r_stash_pop(SEXP repo, SEXP index); SEXP git2r_stash_save(SEXP repo, SEXP message, SEXP index, SEXP untracked, SEXP ignored, SEXP stasher); SEXP git2r_stash_list(SEXP repo); diff -Nru r-cran-git2r-0.21.0/src/git2r_status.c r-cran-git2r-0.22.1/src/git2r_status.c --- r-cran-git2r-0.21.0/src/git2r_status.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_status.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -152,8 +152,8 @@ /* Create list with the correct number of entries */ count = git2r_status_count_ignored(status_list); - SET_VECTOR_ELT(list, list_index, item = allocVector(VECSXP, count)); - setAttrib(item, R_NamesSymbol, names = allocVector(STRSXP, count)); + SET_VECTOR_ELT(list, list_index, item = Rf_allocVector(VECSXP, count)); + Rf_setAttrib(item, R_NamesSymbol, names = Rf_allocVector(STRSXP, count)); /* i index the entrycount. j index the added change in list */ count = git_status_list_entrycount(status_list); @@ -161,8 +161,8 @@ const git_status_entry *s = git_status_byindex(status_list, i); if (s->status == GIT_STATUS_IGNORED) { - SET_STRING_ELT(names, j, mkChar("ignored")); - SET_VECTOR_ELT(item, j, mkString(s->index_to_workdir->old_file.path)); + SET_STRING_ELT(names, j, Rf_mkChar("ignored")); + SET_VECTOR_ELT(item, j, Rf_mkString(s->index_to_workdir->old_file.path)); j++; } } @@ -187,8 +187,8 @@ /* Create list with the correct number of entries */ n = git2r_status_count_staged(status_list); - SET_VECTOR_ELT(list, list_index, sub_list = allocVector(VECSXP, n)); - setAttrib(sub_list, R_NamesSymbol, sub_list_names = allocVector(STRSXP, n)); + SET_VECTOR_ELT(list, list_index, sub_list = Rf_allocVector(VECSXP, n)); + Rf_setAttrib(sub_list, R_NamesSymbol, sub_list_names = Rf_allocVector(STRSXP, n)); /* i index the entrycount. j index the added change in list */ n = git_status_list_entrycount(status_list); @@ -213,20 +213,20 @@ if (!istatus) continue; - SET_STRING_ELT(sub_list_names, j, mkChar(istatus)); + SET_STRING_ELT(sub_list_names, j, Rf_mkChar(istatus)); old_path = s->head_to_index->old_file.path; new_path = s->head_to_index->new_file.path; if (old_path && new_path && strcmp(old_path, new_path)) { SEXP item; - SET_VECTOR_ELT(sub_list, j, item = allocVector(STRSXP, 2)); - SET_STRING_ELT(item, 0, mkChar(old_path)); - SET_STRING_ELT(item, 1, mkChar(new_path)); + SET_VECTOR_ELT(sub_list, j, item = Rf_allocVector(STRSXP, 2)); + SET_STRING_ELT(item, 0, Rf_mkChar(old_path)); + SET_STRING_ELT(item, 1, Rf_mkChar(new_path)); } else { SEXP item; - SET_VECTOR_ELT(sub_list, j, item = allocVector(STRSXP, 1)); - SET_STRING_ELT(item, 0, mkChar(old_path ? old_path : new_path)); + SET_VECTOR_ELT(sub_list, j, item = Rf_allocVector(STRSXP, 1)); + SET_STRING_ELT(item, 0, Rf_mkChar(old_path ? old_path : new_path)); } j++; @@ -252,8 +252,8 @@ /* Create list with the correct number of entries */ n = git2r_status_count_unstaged(status_list); - SET_VECTOR_ELT(list, list_index, sub_list = allocVector(VECSXP, n)); - setAttrib(sub_list, R_NamesSymbol, sub_list_names = allocVector(STRSXP, n)); + SET_VECTOR_ELT(list, list_index, sub_list = Rf_allocVector(VECSXP, n)); + Rf_setAttrib(sub_list, R_NamesSymbol, sub_list_names = Rf_allocVector(STRSXP, n)); /* i index the entrycount. j index the added change in list */ n = git_status_list_entrycount(status_list); @@ -280,20 +280,20 @@ if (!wstatus) continue; - SET_STRING_ELT(sub_list_names, j, mkChar(wstatus)); + SET_STRING_ELT(sub_list_names, j, Rf_mkChar(wstatus)); old_path = s->index_to_workdir->old_file.path; new_path = s->index_to_workdir->new_file.path; if (old_path && new_path && strcmp(old_path, new_path)) { SEXP item; - SET_VECTOR_ELT(sub_list, j, item = allocVector(STRSXP, 2)); - SET_STRING_ELT(item, 0, mkChar(old_path)); - SET_STRING_ELT(item, 1, mkChar(new_path)); + SET_VECTOR_ELT(sub_list, j, item = Rf_allocVector(STRSXP, 2)); + SET_STRING_ELT(item, 0, Rf_mkChar(old_path)); + SET_STRING_ELT(item, 1, Rf_mkChar(new_path)); } else { SEXP item; - SET_VECTOR_ELT(sub_list, j, item = allocVector(STRSXP, 1)); - SET_STRING_ELT(item, 0, mkChar(old_path ? old_path : new_path)); + SET_VECTOR_ELT(sub_list, j, item = Rf_allocVector(STRSXP, 1)); + SET_STRING_ELT(item, 0, Rf_mkChar(old_path ? old_path : new_path)); } j++; @@ -319,8 +319,8 @@ /* Create list with the correct number of entries */ n = git2r_status_count_untracked(status_list); - SET_VECTOR_ELT(list, list_index, sub_list = allocVector(VECSXP, n)); - setAttrib(sub_list, R_NamesSymbol, sub_list_names = allocVector(STRSXP, n)); + SET_VECTOR_ELT(list, list_index, sub_list = Rf_allocVector(VECSXP, n)); + Rf_setAttrib(sub_list, R_NamesSymbol, sub_list_names = Rf_allocVector(STRSXP, n)); /* i index the entrycount. j index the added change in list */ n = git_status_list_entrycount(status_list); @@ -331,8 +331,8 @@ SET_VECTOR_ELT( sub_list, j, - mkString(s->index_to_workdir->old_file.path)); - SET_STRING_ELT(sub_list_names, j, mkChar("untracked")); + Rf_mkString(s->index_to_workdir->old_file.path)); + SET_STRING_ELT(sub_list_names, j, Rf_mkChar("untracked")); j++; } } @@ -341,7 +341,7 @@ /** * Get state of the repository working directory and the staging area. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param staged Include staged files. * @param unstaged Include unstaged files. * @param untracked Include untracked files and directories. @@ -358,7 +358,7 @@ SEXP all_untracked, SEXP ignored) { - int err; + int error, nprotect = 0; size_t i=0, count; SEXP list = R_NilValue; SEXP list_names = R_NilValue; @@ -392,8 +392,8 @@ } if (LOGICAL(ignored)[0]) opts.flags |= GIT_STATUS_OPT_INCLUDE_IGNORED; - err = git_status_list_new(&status_list, repository, &opts); - if (err) + error = git_status_list_new(&status_list, repository, &opts); + if (error) goto cleanup; count = LOGICAL(staged)[0] + @@ -401,44 +401,42 @@ LOGICAL(untracked)[0] + LOGICAL(ignored)[0]; - PROTECT(list = allocVector(VECSXP, count)); - setAttrib(list, R_NamesSymbol, list_names = allocVector(STRSXP, count)); + PROTECT(list = Rf_allocVector(VECSXP, count)); + nprotect++; + Rf_setAttrib(list, R_NamesSymbol, list_names = Rf_allocVector(STRSXP, count)); if (LOGICAL(staged)[0]) { - SET_STRING_ELT(list_names, i, mkChar("staged")); + SET_STRING_ELT(list_names, i, Rf_mkChar("staged")); git2r_status_list_staged(list, i, status_list); i++; } if (LOGICAL(unstaged)[0]) { - SET_STRING_ELT(list_names, i, mkChar("unstaged")); + SET_STRING_ELT(list_names, i, Rf_mkChar("unstaged")); git2r_status_list_unstaged(list, i, status_list); i++; } if (LOGICAL(untracked)[0]) { - SET_STRING_ELT(list_names, i, mkChar("untracked")); + SET_STRING_ELT(list_names, i, Rf_mkChar("untracked")); git2r_status_list_untracked(list, i, status_list); i++; } if (LOGICAL(ignored)[0]) { - SET_STRING_ELT(list_names, i, mkChar("ignored")); + SET_STRING_ELT(list_names, i, Rf_mkChar("ignored")); git2r_status_list_ignored(list, i, status_list); } cleanup: - if (status_list) - git_status_list_free(status_list); + git_status_list_free(status_list); + git_repository_free(repository); - if (repository) - git_repository_free(repository); + if (nprotect) + UNPROTECT(nprotect); - if (!isNull(list)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return list; diff -Nru r-cran-git2r-0.21.0/src/git2r_tag.c r-cran-git2r-0.22.1/src/git2r_tag.c --- r-cran-git2r-0.21.0/src/git2r_tag.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_tag.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,25 +16,24 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include #include "git2r_arg.h" #include "git2r_blob.h" #include "git2r_commit.h" #include "git2r_error.h" #include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_signature.h" #include "git2r_tag.h" #include "git2r_tree.h" -#include "util.h" - /** - * Init slots in S4 class git_tag + * Init slots in S3 class git_tag * * @param source a tag - * @param repo S4 class git_repository that contains the tag - * @param dest S4 class git_tag to initialize + * @param repo S3 class git_repository that contains the tag + * @param dest S3 class git_tag to initialize * @return void */ void git2r_tag_init(git_tag *source, SEXP repo, SEXP dest) @@ -43,44 +42,58 @@ const git_oid *oid; char sha[GIT_OID_HEXSZ + 1]; char target[GIT_OID_HEXSZ + 1]; - SEXP s_sha = Rf_install("sha"); - SEXP s_message = Rf_install("message"); - SEXP s_name = Rf_install("name"); - SEXP s_tagger = Rf_install("tagger"); - SEXP s_target = Rf_install("target"); - SEXP s_repo = Rf_install("repo"); oid = git_tag_id(source); git_oid_tostr(sha, sizeof(sha), oid); - SET_SLOT(dest, s_sha, mkString(sha)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_tag__sha, Rf_mkString(sha)); - SET_SLOT(dest, s_message, mkString(git_tag_message(source))); - SET_SLOT(dest, s_name, mkString(git_tag_name(source))); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tag__message, + Rf_mkString(git_tag_message(source))); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tag__name, + Rf_mkString(git_tag_name(source))); tagger = git_tag_tagger(source); - if (tagger) - git2r_signature_init(tagger, GET_SLOT(dest, s_tagger)); + if (tagger) { + if (Rf_isNull(VECTOR_ELT(dest, git2r_S3_item__git_tag__tagger))) { + SEXP item; + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tag__tagger, + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_signature)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_signature)); + } + git2r_signature_init( + tagger, + VECTOR_ELT(dest, git2r_S3_item__git_tag__tagger)); + } oid = git_tag_target_id(source); git_oid_tostr(target, sizeof(target), oid);; - SET_SLOT(dest, s_target, mkString(target)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_tag__target, Rf_mkString(target)); - SET_SLOT(dest, s_repo, repo); + SET_VECTOR_ELT(dest, git2r_S3_item__git_tag__repo, Rf_duplicate(repo)); } /** * Create tag targeting HEAD commit in repository. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name Name for the tag. * @param message The tag message. * @param tagger The tagger (author) of the tag - * @return S4 object of class git_tag + * @return S3 object of class git_tag */ SEXP git2r_tag_create(SEXP repo, SEXP name, SEXP message, SEXP tagger) { SEXP result = R_NilValue; - int err; + int error, nprotect = 0; git_oid oid; git_repository *repository = NULL; git_signature *sig_tagger = NULL; @@ -98,15 +111,15 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git2r_signature_from_arg(&sig_tagger, tagger); - if (err) + error = git2r_signature_from_arg(&sig_tagger, tagger); + if (error) goto cleanup; - err = git_revparse_single(&target, repository, "HEAD^{commit}"); - if (err) + error = git_revparse_single(&target, repository, "HEAD^{commit}"); + if (error) goto cleanup; - err = git_tag_create( + error = git_tag_create( &oid, repository, CHAR(STRING_ELT(name, 0)), @@ -114,33 +127,29 @@ sig_tagger, CHAR(STRING_ELT(message, 0)), 0); - if (err) + if (error) goto cleanup; - err = git_tag_lookup(&tag, repository, &oid); - if (err) + error = git_tag_lookup(&tag, repository, &oid); + if (error) goto cleanup; - PROTECT(result = NEW_OBJECT(MAKE_CLASS("git_tag"))); + PROTECT(result = Rf_mkNamed(VECSXP, git2r_S3_items__git_tag)); + nprotect++; + Rf_setAttrib(result, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tag)); git2r_tag_init(tag, repo, result); cleanup: - if (tag) - git_tag_free(tag); - - if (sig_tagger) - git_signature_free(sig_tagger); + git_tag_free(tag); + git_signature_free(sig_tagger); + git_object_free(target); + git_repository_free(repository); - if (target) - git_object_free(target); + if (nprotect) + UNPROTECT(nprotect); - if (repository) - git_repository_free(repository); - - if (!isNull(result)) - UNPROTECT(1); - - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; @@ -149,13 +158,13 @@ /** * Delete an existing tag reference. * - * @param repo S4 class git_repository + * @param repo S3 class git_repository * @param name Name of the tag to be deleted * @return R_NilValue */ SEXP git2r_tag_delete(SEXP repo, SEXP name) { - int err; + int error; git_repository *repository = NULL; if (git2r_arg_check_string(name)) @@ -165,12 +174,11 @@ if (!repository) git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); - err = git_tag_delete(repository, CHAR(STRING_ELT(name, 0))); + error = git_tag_delete(repository, CHAR(STRING_ELT(name, 0))); - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return R_NilValue; @@ -196,17 +204,17 @@ */ static int git2r_tag_foreach_cb(const char *name, git_oid *oid, void *payload) { - int err = 0; + int error = 0; git_object *object = NULL; git2r_tag_foreach_cb_data *cb_data = (git2r_tag_foreach_cb_data*)payload; /* Check if we have a list to populate */ - if (!isNull(cb_data->tags)) { + if (!Rf_isNull(cb_data->tags)) { int skip = 0; SEXP item, tag; - err = git_object_lookup(&object, cb_data->repository, oid, GIT_OBJ_ANY); - if (err) + error = git_object_lookup(&object, cb_data->repository, oid, GIT_OBJ_ANY); + if (error) goto cleanup; switch (git_object_type(object)) { @@ -214,39 +222,47 @@ SET_VECTOR_ELT( cb_data->tags, cb_data->n, - item = NEW_OBJECT(MAKE_CLASS("git_commit"))); + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_commit)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_commit)); git2r_commit_init((git_commit*)object, cb_data->repo, item); break; case GIT_OBJ_TREE: SET_VECTOR_ELT( cb_data->tags, cb_data->n, - item = NEW_OBJECT(MAKE_CLASS("git_tree"))); + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_tree)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tree)); git2r_tree_init((git_tree*)object, cb_data->repo, item); break; case GIT_OBJ_BLOB: SET_VECTOR_ELT( cb_data->tags, cb_data->n, - item = NEW_OBJECT(MAKE_CLASS("git_blob"))); + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_blob)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_blob)); git2r_blob_init((git_blob*)object, cb_data->repo, item); break; case GIT_OBJ_TAG: SET_VECTOR_ELT( cb_data->tags, cb_data->n, - item = NEW_OBJECT(MAKE_CLASS("git_tag"))); + item = Rf_mkNamed(VECSXP, git2r_S3_items__git_tag)); + Rf_setAttrib(item, R_ClassSymbol, + Rf_mkString(git2r_S3_class__git_tag)); git2r_tag_init((git_tag*)object, cb_data->repo, item); break; default: git2r_error(__func__, NULL, git2r_err_object_type, NULL); } - if (git__prefixcmp(name, "refs/tags/") == 0) + if (strncmp(name, "refs/tags/", sizeof("refs/tags/") - 1) == 0) skip = strlen("refs/tags/"); - PROTECT(tag = mkChar(name + skip)); + PROTECT(tag = Rf_mkChar(name + skip)); SET_STRING_ELT( - getAttrib(cb_data->tags, R_NamesSymbol), + Rf_getAttrib(cb_data->tags, R_NamesSymbol), cb_data->n, tag); UNPROTECT(1); @@ -259,21 +275,19 @@ cb_data->n += 1; cleanup: - if (object) - git_object_free(object); - - return err; + git_object_free(object); + return error; } /** * Get all tags that can be found in a repository. * - * @param repo S4 class git_repository - * @return VECXSP with S4 objects of class git_tag + * @param repo S3 class git_repository + * @return VECXSP with S3 objects of class git_tag */ SEXP git2r_tag_list(SEXP repo) { - int err; + int error, nprotect = 0; SEXP result = R_NilValue; git2r_tag_foreach_cb_data cb_data = {0, NULL, R_NilValue, R_NilValue}; git_repository *repository; @@ -283,35 +297,36 @@ git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); /* Count number of tags before creating the list */ - err = git_tag_foreach(repository, &git2r_tag_foreach_cb, &cb_data); - if (err) { - if (GIT_ENOTFOUND == err) { - err = 0; - PROTECT(result = allocVector(VECSXP, 0)); - setAttrib(result, R_NamesSymbol, allocVector(STRSXP, 0)); + error = git_tag_foreach(repository, &git2r_tag_foreach_cb, &cb_data); + if (error) { + if (GIT_ENOTFOUND == error) { + error = 0; + PROTECT(result = Rf_allocVector(VECSXP, 0)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, Rf_allocVector(STRSXP, 0)); } goto cleanup; } - PROTECT(result = allocVector(VECSXP, cb_data.n)); - setAttrib(result, R_NamesSymbol, allocVector(STRSXP, cb_data.n)); + PROTECT(result = Rf_allocVector(VECSXP, cb_data.n)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, Rf_allocVector(STRSXP, cb_data.n)); cb_data.n = 0; cb_data.tags = result; cb_data.repo = repo; cb_data.repository = repository; - err = git_tag_foreach(repository, &git2r_tag_foreach_cb, &cb_data); + error = git_tag_foreach(repository, &git2r_tag_foreach_cb, &cb_data); cleanup: - if (repository) - git_repository_free(repository); + git_repository_free(repository); - if (!isNull(result)) - UNPROTECT(1); + if (nprotect) + UNPROTECT(nprotect); - if (err) + if (error) git2r_error(__func__, giterr_last(), NULL, NULL); return result; diff -Nru r-cran-git2r-0.21.0/src/git2r_tag.h r-cran-git2r-0.22.1/src/git2r_tag.h --- r-cran-git2r-0.21.0/src/git2r_tag.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_tag.h 2018-07-10 13:23:34.000000000 +0000 @@ -22,7 +22,7 @@ #include #include -#include "git2.h" +#include void git2r_tag_init(git_tag *source, SEXP repo, SEXP dest); SEXP git2r_tag_create(SEXP repo, SEXP name, SEXP message, SEXP tagger); diff -Nru r-cran-git2r-0.21.0/src/git2r_transfer.c r-cran-git2r-0.22.1/src/git2r_transfer.c --- r-cran-git2r-0.21.0/src/git2r_transfer.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_transfer.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,33 +16,46 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include "git2r_S3.h" #include "git2r_transfer.h" /** - * Init slots in S4 class git_transfer_progress + * Init slots in S3 class git_transfer_progress * * @param source A git_transfer_progress object - * @param dest S4 class git_transfer_progress to initialize + * @param dest S3 class git_transfer_progress to initialize * @return void */ void git2r_transfer_progress_init( const git_transfer_progress *source, SEXP dest) { - SEXP s_total_objects = Rf_install("total_objects"); - SEXP s_indexed_objects = Rf_install("indexed_objects"); - SEXP s_received_objects = Rf_install("received_objects"); - SEXP s_local_objects = Rf_install("local_objects"); - SEXP s_total_deltas = Rf_install("total_deltas"); - SEXP s_indexed_deltas = Rf_install("indexed_deltas"); - SEXP s_received_bytes = Rf_install("received_bytes"); - - SET_SLOT(dest, s_total_objects, ScalarInteger(source->total_objects)); - SET_SLOT(dest, s_indexed_objects, ScalarInteger(source->indexed_objects)); - SET_SLOT(dest, s_received_objects, ScalarInteger(source->received_objects)); - SET_SLOT(dest, s_local_objects, ScalarInteger(source->local_objects)); - SET_SLOT(dest, s_total_deltas, ScalarInteger(source->total_deltas)); - SET_SLOT(dest, s_indexed_deltas, ScalarInteger(source->indexed_deltas)); - SET_SLOT(dest, s_received_bytes, ScalarInteger(source->received_bytes)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__total_objects, + Rf_ScalarInteger(source->total_objects)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__indexed_objects, + Rf_ScalarInteger(source->indexed_objects)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__received_objects, + Rf_ScalarInteger(source->received_objects)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__local_objects, + Rf_ScalarInteger(source->local_objects)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__total_deltas, + Rf_ScalarInteger(source->total_deltas)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__indexed_deltas, + Rf_ScalarInteger(source->indexed_deltas)); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_transfer_progress__received_bytes, + Rf_ScalarInteger(source->received_bytes)); } diff -Nru r-cran-git2r-0.21.0/src/git2r_transfer.h r-cran-git2r-0.22.1/src/git2r_transfer.h --- r-cran-git2r-0.21.0/src/git2r_transfer.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_transfer.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -21,7 +21,7 @@ #include #include -#include "git2.h" +#include /** * Data structure to hold information when performing a clone, fetch @@ -31,11 +31,27 @@ int received_progress; int received_done; int verbose; - int ssh_key_agent_tried; + + /* Used in the 'git2r_cred_acquire_cb' callback to determine if to + * use the 'ssh-agent' to find the ssh key for authentication. + * Only used when credentials equals R_NilValue. */ + int use_ssh_agent; + + /* Used in the 'git2r_cred_acquire_cb' callback to determine if to + * to search for the 'id_rsa' ssh key for authentication. Only + * used when credentials equals R_NilValue. FIXME: This is + * currently always set to zero, i.e. git2r does not automatically + * search for the 'id_rsa' ssh key. */ + int use_ssh_key; + SEXP credentials; } git2r_transfer_data; -#define GIT2R_TRANSFER_DATA_INIT {0, 0, 0, 0, R_NilValue} +#ifdef WIN32 +# define GIT2R_TRANSFER_DATA_INIT {0, 0, 0, 1, 0, R_NilValue} +#else +# define GIT2R_TRANSFER_DATA_INIT {0, 0, 0, 1, 0, R_NilValue} +#endif void git2r_transfer_progress_init( const git_transfer_progress *source, diff -Nru r-cran-git2r-0.21.0/src/git2r_tree.c r-cran-git2r-0.22.1/src/git2r_tree.c --- r-cran-git2r-0.21.0/src/git2r_tree.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_tree.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2017 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -16,15 +16,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include +#include + +#include "git2r_arg.h" +#include "git2r_error.h" +#include "git2r_repository.h" +#include "git2r_S3.h" #include "git2r_tree.h" /** - * Init slots in S4 class git_tree + * Init slots in S3 class git_tree * * @param source a tree - * @param repo S4 class git_repository that contains the tree - * @param dest S4 class git_tree to initialize + * @param repo S3 class git_repository that contains the tree + * @param dest S3 class git_tree to initialize * @return void */ void git2r_tree_init(const git_tree *source, SEXP repo, SEXP dest) @@ -35,37 +40,193 @@ const git_oid *oid; char sha[GIT_OID_HEXSZ + 1]; const git_tree_entry *entry; - SEXP s_sha = Rf_install("sha"); - SEXP s_filemode = Rf_install("filemode"); - SEXP s_id = Rf_install("id"); - SEXP s_type = Rf_install("type"); - SEXP s_name = Rf_install("name"); - SEXP s_repo = Rf_install("repo"); oid = git_tree_id(source); git_oid_tostr(sha, sizeof(sha), oid); - SET_SLOT(dest, s_sha, mkString(sha)); + SET_VECTOR_ELT(dest, git2r_S3_item__git_tree__sha, Rf_mkString(sha)); n = git_tree_entrycount(source); - PROTECT(filemode = allocVector(INTSXP, n)); - SET_SLOT(dest, s_filemode, filemode); - PROTECT(id = allocVector(STRSXP, n)); - SET_SLOT(dest, s_id, id); - PROTECT(type = allocVector(STRSXP, n)); - SET_SLOT(dest, s_type, type); - PROTECT(name = allocVector(STRSXP, n)); - SET_SLOT(dest, s_name, name); + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tree__filemode, + filemode = Rf_allocVector(INTSXP, n)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tree__id, + id = Rf_allocVector(STRSXP, n)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tree__type, + type = Rf_allocVector(STRSXP, n)); + + SET_VECTOR_ELT( + dest, + git2r_S3_item__git_tree__name, + name = Rf_allocVector(STRSXP, n)); filemode_ptr = INTEGER(filemode); for (i = 0; i < n; ++i) { entry = git_tree_entry_byindex(source, i); git_oid_tostr(sha, sizeof(sha), git_tree_entry_id(entry)); filemode_ptr[i] = git_tree_entry_filemode(entry); - SET_STRING_ELT(id, i, mkChar(sha)); - SET_STRING_ELT(type, i, mkChar(git_object_type2string(git_tree_entry_type(entry)))); - SET_STRING_ELT(name, i, mkChar(git_tree_entry_name(entry))); + SET_STRING_ELT(id, i, Rf_mkChar(sha)); + SET_STRING_ELT(type, i, Rf_mkChar(git_object_type2string(git_tree_entry_type(entry)))); + SET_STRING_ELT(name, i, Rf_mkChar(git_tree_entry_name(entry))); + } + + SET_VECTOR_ELT(dest, git2r_S3_item__git_tree__repo, Rf_duplicate(repo)); +} + +/** + * Data structure to hold information for the tree traversal. + */ +typedef struct { + size_t n; + SEXP list; + int recursive; + git_repository *repository; +} git2r_tree_walk_cb_data; + +/** + * Callback for the tree traversal method. + * + */ +static int git2r_tree_walk_cb( + const char *root, + const git_tree_entry *entry, + void *payload) +{ + int error = 0; + git2r_tree_walk_cb_data *p = (git2r_tree_walk_cb_data*)payload; + + if (!p->recursive && *root) + return 1; + + if (!Rf_isNull(p->list)) { + char mode[23]; /* enums are int/32-bit, but this is enough for even a 64-bit int */ + git_object *blob = NULL, *obj = NULL; + char sha[GIT_OID_HEXSZ + 1]; + + /* mode */ + error = snprintf(mode, sizeof(mode), "%06o", git_tree_entry_filemode(entry)); + if (error < 0 || error >= sizeof(mode)) { + error = -1; + goto cleanup; + } + SET_STRING_ELT(VECTOR_ELT(p->list, 0), p->n, + Rf_mkChar(mode)); + + /* type */ + SET_STRING_ELT(VECTOR_ELT(p->list, 1), p->n, + Rf_mkChar(git_object_type2string(git_tree_entry_type(entry)))); + + /* sha */ + git_oid_tostr(sha, sizeof(sha), git_tree_entry_id(entry)); + SET_STRING_ELT(VECTOR_ELT(p->list, 2), p->n, Rf_mkChar(sha)); + + /* path */ + SET_STRING_ELT(VECTOR_ELT(p->list, 3), p->n, Rf_mkChar(root)); + + /* name */ + SET_STRING_ELT(VECTOR_ELT(p->list, 4), p->n, + Rf_mkChar(git_tree_entry_name(entry))); + + /* length */ + if (git_tree_entry_type(entry) == GIT_OBJ_BLOB) { + error = git_tree_entry_to_object(&obj, p->repository, entry); + if (error) + goto cleanup; + error = git_object_peel(&blob, obj, GIT_OBJ_BLOB); + if (error) + goto cleanup; + INTEGER(VECTOR_ELT(p->list, 5))[p->n] = git_blob_rawsize((git_blob *)blob); + } else { + INTEGER(VECTOR_ELT(p->list, 5))[p->n] = NA_INTEGER; + } + + cleanup: + git_object_free(obj); + git_object_free(blob); } - SET_SLOT(dest, s_repo, repo); - UNPROTECT(4); + p->n += 1; + + return error; +} + +/** + * Traverse the entries in a tree and its subtrees. + * + * @param tree S3 class git_tree + * @param recursive recurse into sub-trees. + * @return A list with entries + */ +SEXP git2r_tree_walk(SEXP tree, SEXP recursive) +{ + int error, nprotect = 0; + git_oid oid; + git_tree *tree_obj = NULL; + git_repository *repository = NULL; + git2r_tree_walk_cb_data cb_data = {0, R_NilValue}; + SEXP repo = R_NilValue, sha = R_NilValue; + SEXP result = R_NilValue, names = R_NilValue; + + if (git2r_arg_check_tree(tree)) + git2r_error(__func__, NULL, "'tree'", git2r_err_tree_arg); + if (git2r_arg_check_logical(recursive)) + git2r_error(__func__, NULL, "'recursive'", git2r_err_logical_arg); + + repo = git2r_get_list_element(tree, "repo"); + repository = git2r_repository_open(repo); + if (!repository) + git2r_error(__func__, NULL, git2r_err_invalid_repository, NULL); + + sha = git2r_get_list_element(tree, "sha"); + git_oid_fromstr(&oid, CHAR(STRING_ELT(sha, 0))); + error = git_tree_lookup(&tree_obj, repository, &oid); + if (error) + goto cleanup; + + /* Count number of entries before creating the list */ + cb_data.repository = repository; + if (LOGICAL(recursive)[0]) + cb_data.recursive = 1; + error = git_tree_walk(tree_obj, 0, &git2r_tree_walk_cb, &cb_data); + if (error) + goto cleanup; + + PROTECT(result = Rf_allocVector(VECSXP, 6)); + nprotect++; + Rf_setAttrib(result, R_NamesSymbol, names = Rf_allocVector(STRSXP, 6)); + + SET_VECTOR_ELT(result, 0, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, 0, Rf_mkChar("mode")); + SET_VECTOR_ELT(result, 1, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, 1, Rf_mkChar("type")); + SET_VECTOR_ELT(result, 2, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, 2, Rf_mkChar("sha")); + SET_VECTOR_ELT(result, 3, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, 3, Rf_mkChar("path")); + SET_VECTOR_ELT(result, 4, Rf_allocVector(STRSXP, cb_data.n)); + SET_STRING_ELT(names, 4, Rf_mkChar("name")); + SET_VECTOR_ELT(result, 5, Rf_allocVector(INTSXP, cb_data.n)); + SET_STRING_ELT(names, 5, Rf_mkChar("len")); + + cb_data.list = result; + cb_data.n = 0; + error = git_tree_walk(tree_obj, 0, &git2r_tree_walk_cb, &cb_data); + +cleanup: + git_repository_free(repository); + git_tree_free(tree_obj); + + if (nprotect) + UNPROTECT(nprotect); + + if (error) + git2r_error(__func__, giterr_last(), NULL, NULL); + + return result; } diff -Nru r-cran-git2r-0.21.0/src/git2r_tree.h r-cran-git2r-0.22.1/src/git2r_tree.h --- r-cran-git2r-0.21.0/src/git2r_tree.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/git2r_tree.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * git2r, R bindings to the libgit2 library. - * Copyright (C) 2013-2015 The git2r contributors + * Copyright (C) 2013-2018 The git2r contributors * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, @@ -22,8 +22,9 @@ #include #include -#include "git2.h" +#include void git2r_tree_init(const git_tree *source, SEXP repo, SEXP dest); +SEXP git2r_tree_walk(SEXP tree, SEXP recursive); #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/deps/winhttp/winhttp32.def.in r-cran-git2r-0.22.1/src/libgit2/deps/winhttp/winhttp32.def.in --- r-cran-git2r-0.21.0/src/libgit2/deps/winhttp/winhttp32.def.in 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/deps/winhttp/winhttp32.def.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -; -; Definition file of WINHTTP.dll -; Automatic generated by gendef -; written by Kai Tietz 2008 -; -LIBRARY "WINHTTP.dll" -EXPORTS -Private1@20 -SvchostPushServiceGlobals@4 -WinHttpAddRequestHeaders@16 -WinHttpAutoProxySvcMain@8 -WinHttpCheckPlatform@0 -WinHttpCloseHandle@4 -WinHttpConnect@16 -WinHttpCrackUrl@16 -WinHttpCreateUrl@16 -WinHttpDetectAutoProxyConfigUrl@8 -WinHttpGetDefaultProxyConfiguration@4 -WinHttpGetIEProxyConfigForCurrentUser@4 -WinHttpGetProxyForUrl@16 -WinHttpOpen@20 -WinHttpOpenRequest@28 -WinHttpQueryAuthSchemes@16 -WinHttpQueryDataAvailable@8 -WinHttpQueryHeaders@24 -WinHttpQueryOption@16 -WinHttpReadData@16 -WinHttpReceiveResponse@8 -WinHttpSendRequest@28 -WinHttpSetCredentials@24 -WinHttpSetDefaultProxyConfiguration@4 -WinHttpSetOption@16 -WinHttpSetStatusCallback@16 -WinHttpSetTimeouts@20 -WinHttpTimeFromSystemTime@8 -WinHttpTimeToSystemTime@8 -WinHttpWriteData@16 diff -Nru r-cran-git2r-0.21.0/src/libgit2/deps/winhttp/winhttp64.def.in r-cran-git2r-0.22.1/src/libgit2/deps/winhttp/winhttp64.def.in --- r-cran-git2r-0.21.0/src/libgit2/deps/winhttp/winhttp64.def.in 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/deps/winhttp/winhttp64.def.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -; -; Definition file of WINHTTP.dll -; Automatic generated by gendef -; written by Kai Tietz 2008 -; -LIBRARY "WINHTTP.dll" -EXPORTS -Private1 -SvchostPushServiceGlobals -WinHttpAddRequestHeaders -WinHttpAutoProxySvcMain -WinHttpCheckPlatform -WinHttpCloseHandle -WinHttpConnect -WinHttpCrackUrl -WinHttpCreateUrl -WinHttpDetectAutoProxyConfigUrl -WinHttpGetDefaultProxyConfiguration -WinHttpGetIEProxyConfigForCurrentUser -WinHttpGetProxyForUrl -WinHttpOpen -WinHttpOpenRequest -WinHttpQueryAuthSchemes -WinHttpQueryDataAvailable -WinHttpQueryHeaders -WinHttpQueryOption -WinHttpReadData -WinHttpReceiveResponse -WinHttpSendRequest -WinHttpSetCredentials -WinHttpSetDefaultProxyConfiguration -WinHttpSetOption -WinHttpSetStatusCallback -WinHttpSetTimeouts -WinHttpTimeFromSystemTime -WinHttpTimeToSystemTime -WinHttpWriteData diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/common.h r-cran-git2r-0.22.1/src/libgit2/include/git2/common.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/common.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/common.h 2018-07-10 13:23:34.000000000 +0000 @@ -49,9 +49,7 @@ #endif /** Declare a function's takes printf style arguments. */ -#if defined(__MINGW32__) -# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (__MINGW_PRINTF_FORMAT, a, b))) -#elif defined(__GNUC__) +#ifdef __GNUC__ # define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b))) #else # define GIT_FORMAT_PRINTF(a,b) /* empty */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/config.h r-cran-git2r-0.22.1/src/libgit2/include/git2/config.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/config.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/config.h 2018-07-10 13:23:34.000000000 +0000 @@ -199,6 +199,8 @@ * @param path path to the configuration file to add * @param level the priority level of the backend * @param force replace config file at the given priority level + * @param repo optional repository to allow parsing of + * conditional includes * @return 0 on success, GIT_EEXISTS when adding more than one file * for a given priority level (and force_replace set to 0), * GIT_ENOTFOUND when the file doesn't exist or error code @@ -207,6 +209,7 @@ git_config *cfg, const char *path, git_config_level_t level, + const git_repository *repo, int force); /** @@ -398,6 +401,10 @@ * * The callback will be called on each variable found * + * The regular expression is applied case-sensitively on the normalized form of + * the variable name: the section and variable parts are lower-cased. The + * subsection is left unchanged. + * * @param cfg where to look for the variable * @param name the variable's name * @param regexp regular expression to filter which variables we're @@ -410,6 +417,10 @@ /** * Get each value of a multivar * + * The regular expression is applied case-sensitively on the normalized form of + * the variable name: the section and variable parts are lower-cased. The + * subsection is left unchanged. + * * @param out pointer to store the iterator * @param cfg where to look for the variable * @param name the variable's name @@ -487,6 +498,8 @@ /** * Set a multivar in the local config file. * + * The regular expression is applied case-sensitively on the value. + * * @param cfg where to look for the variable * @param name the variable's name * @param regexp a regular expression to indicate which values to replace @@ -506,6 +519,8 @@ /** * Deletes one or several entries from a multivar in the local config file. * + * The regular expression is applied case-sensitively on the value. + * * @param cfg where to look for the variables * @param name the variable's name * @param regexp a regular expression to indicate which values to delete @@ -552,6 +567,10 @@ * Use `git_config_next` to advance the iteration and * `git_config_iterator_free` when done. * + * The regular expression is applied case-sensitively on the normalized form of + * the variable name: the section and variable parts are lower-cased. The + * subsection is left unchanged. + * * @param out pointer to store the iterator * @param cfg where to ge the variables from * @param regexp regular expression to match the names @@ -565,8 +584,12 @@ * regular expression that filters which config keys are passed to the * callback. * - * The pointers passed to the callback are only valid as long as the - * iteration is ongoing. + * The regular expression is applied case-sensitively on the normalized form of + * the variable name: the section and variable parts are lower-cased. The + * subsection is left unchanged. + * + * The regular expression is applied case-sensitively on the normalized form of + * the variable name: the case-insensitive parts are lower-case. * * @param cfg where to get the variables from * @param regexp regular expression to match against config names @@ -693,6 +716,10 @@ * This behaviors like `git_config_foreach_match` except instead of all config * entries it just enumerates through the given backend entry. * + * The regular expression is applied case-sensitively on the normalized form of + * the variable name: the section and variable parts are lower-cased. The + * subsection is left unchanged. + * * @param backend where to get the variables from * @param regexp regular expression to match against config names (can be NULL) * @param callback the function to call on each variable diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/describe.h r-cran-git2r-0.22.1/src/libgit2/include/git2/describe.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/describe.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/describe.h 2018-07-10 13:23:34.000000000 +0000 @@ -23,7 +23,7 @@ /** * Reference lookup strategy * - * These behave like the --tags and --all optios to git-describe, + * These behave like the --tags and --all options to git-describe, * namely they say to look for any reference in either refs/tags/ or * refs/ respectively. */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/diff.h r-cran-git2r-0.22.1/src/libgit2/include/git2/diff.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/diff.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/diff.h 2018-07-10 13:23:34.000000000 +0000 @@ -171,6 +171,12 @@ * Options controlling how output will be generated */ + /** Use a heuristic that takes indentation and whitespace into account + * which generally can produce better diffs when dealing with ambiguous + * diff hunks. + */ + GIT_DIFF_INDENT_HEURISTIC = (1u << 18), + /** Treat all files as text, disabling binary attributes & detection */ GIT_DIFF_FORCE_TEXT = (1u << 20), /** Treat all files as binary, disabling text diffs */ @@ -200,12 +206,12 @@ /** Use the "patience diff" algorithm */ GIT_DIFF_PATIENCE = (1u << 28), /** Take extra time to find minimal diff */ - GIT_DIFF_MINIMAL = (1 << 29), + GIT_DIFF_MINIMAL = (1u << 29), /** Include the necessary deflate / delta information so that `git-apply` * can apply given diff information to binary files. */ - GIT_DIFF_SHOW_BINARY = (1 << 30), + GIT_DIFF_SHOW_BINARY = (1u << 30), } git_diff_option_t; /** @@ -431,11 +437,13 @@ {GIT_DIFF_OPTIONS_VERSION, 0, GIT_SUBMODULE_IGNORE_UNSPECIFIED, {NULL,0}, NULL, NULL, NULL, 3} /** - * Initializes a `git_diff_options` with default values. Equivalent to - * creating an instance with GIT_DIFF_OPTIONS_INIT. + * Initialize git_diff_options structure + * + * Initializes a `git_diff_options` with default values. Equivalent to creating + * an instance with GIT_DIFF_OPTIONS_INIT. * - * @param opts The `git_diff_options` struct to initialize - * @param version Version of struct; pass `GIT_DIFF_OPTIONS_VERSION` + * @param opts The `git_diff_options` struct to initialize. + * @param version The struct version; pass `GIT_DIFF_OPTIONS_VERSION`. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_diff_init_options( @@ -515,12 +523,12 @@ * Structure describing a hunk of a diff. */ typedef struct { - int old_start; /** Starting line number in old_file */ - int old_lines; /** Number of lines in old_file */ - int new_start; /** Starting line number in new_file */ - int new_lines; /** Number of lines in new_file */ - size_t header_len; /** Number of bytes in header text */ - char header[GIT_DIFF_HUNK_HEADER_SIZE]; /** Header text, NUL-byte terminated */ + int old_start; /**< Starting line number in old_file */ + int old_lines; /**< Number of lines in old_file */ + int new_start; /**< Starting line number in new_file */ + int new_lines; /**< Number of lines in new_file */ + size_t header_len; /**< Number of bytes in header text */ + char header[GIT_DIFF_HUNK_HEADER_SIZE]; /**< Header text, NUL-byte terminated */ } git_diff_hunk; /** @@ -726,11 +734,13 @@ #define GIT_DIFF_FIND_OPTIONS_INIT {GIT_DIFF_FIND_OPTIONS_VERSION} /** - * Initializes a `git_diff_find_options` with default values. Equivalent to - * creating an instance with GIT_DIFF_FIND_OPTIONS_INIT. + * Initialize git_diff_find_options structure * - * @param opts The `git_diff_find_options` struct to initialize - * @param version Version of struct; pass `GIT_DIFF_FIND_OPTIONS_VERSION` + * Initializes a `git_diff_find_options` with default values. Equivalent to creating + * an instance with GIT_DIFF_FIND_OPTIONS_INIT. + * + * @param opts The `git_diff_find_options` struct to initialize. + * @param version The struct version; pass `GIT_DIFF_FIND_OPTIONS_VERSION`. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_diff_find_init_options( @@ -1388,18 +1398,69 @@ const git_diff_options *diff_opts); /** - * Initializes a `git_diff_format_email_options` with default values. + * Initialize git_diff_format_email_options structure * - * Equivalent to creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT. + * Initializes a `git_diff_format_email_options` with default values. Equivalent + * to creating an instance with GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT. * - * @param opts The `git_diff_format_email_options` struct to initialize - * @param version Version of struct; pass `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION` + * @param opts The `git_blame_options` struct to initialize. + * @param version The struct version; pass `GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION`. * @return Zero on success; -1 on failure. */ GIT_EXTERN(int) git_diff_format_email_init_options( git_diff_format_email_options *opts, unsigned int version); +/** + * Patch ID options structure + * + * Initialize with `GIT_PATCHID_OPTIONS_INIT`. Alternatively, you can + * use `git_patchid_init_options`. + * + */ +typedef struct git_diff_patchid_options { + unsigned int version; +} git_diff_patchid_options; + +#define GIT_DIFF_PATCHID_OPTIONS_VERSION 1 +#define GIT_DIFF_PATCHID_OPTIONS_INIT { GIT_DIFF_PATCHID_OPTIONS_VERSION } + +/** + * Initialize git_diff_patchid_options structure + * + * Initializes a `git_diff_patchid_options` with default values. Equivalent to + * creating an instance with `GIT_DIFF_PATCHID_OPTIONS_INIT`. + * + * @param opts The `git_diff_patchid_options` struct to initialize. + * @param version The struct version; pass `GIT_DIFF_PATCHID_OPTIONS_VERSION`. + * @return Zero on success; -1 on failure. + */ +GIT_EXTERN(int) git_diff_patchid_init_options( + git_diff_patchid_options *opts, + unsigned int version); + +/** + * Calculate the patch ID for the given patch. + * + * Calculate a stable patch ID for the given patch by summing the + * hash of the file diffs, ignoring whitespace and line numbers. + * This can be used to derive whether two diffs are the same with + * a high probability. + * + * Currently, this function only calculates stable patch IDs, as + * defined in git-patch-id(1), and should in fact generate the + * same IDs as the upstream git project does. + * + * @param out Pointer where the calculated patch ID shoul be + * stored + * @param diff The diff to calculate the ID for + * @param opts Options for how to calculate the patch ID. This is + * intended for future changes, as currently no options are + * available. + * @return 0 on success, an error code otherwise. + */ +GIT_EXTERN(int) git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opts); + GIT_END_DECL /** @} */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/graph.h r-cran-git2r-0.22.1/src/libgit2/include/git2/graph.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/graph.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/graph.h 2018-07-10 13:23:34.000000000 +0000 @@ -40,6 +40,9 @@ /** * Determine if a commit is the descendant of another commit. * + * Note that a commit is not considered a descendant of itself, in contrast + * to `git merge-base --is-ancestor`. + * * @param commit a previously loaded commit. * @param ancestor a potential ancestor commit. * @return 1 if the given commit is a descendant of the potential ancestor, diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/merge.h r-cran-git2r-0.22.1/src/libgit2/include/git2/merge.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/merge.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/merge.h 2018-07-10 13:23:34.000000000 +0000 @@ -162,6 +162,8 @@ GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7), } git_merge_file_flag_t; +#define GIT_MERGE_CONFLICT_MARKER_SIZE 7 + /** * Options for merging a file */ @@ -191,6 +193,10 @@ /** see `git_merge_file_flag_t` above */ git_merge_file_flag_t flags; + + /** The size of conflict markers (eg, "<<<<<<<"). Default is + * GIT_MERGE_CONFLICT_MARKER_SIZE. */ + unsigned short marker_size; } git_merge_file_options; #define GIT_MERGE_FILE_OPTIONS_VERSION 1 diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/message.h r-cran-git2r-0.22.1/src/libgit2/include/git2/message.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/message.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/message.h 2018-07-10 13:23:34.000000000 +0000 @@ -19,10 +19,9 @@ GIT_BEGIN_DECL /** - * Clean up message from excess whitespace and make sure that the last line - * ends with a '\n'. + * Clean up excess whitespace and make sure there is a trailing newline in the message. * - * Optionally, can remove lines starting with a "#". + * Optionally, it can remove lines which start with the comment character. * * @param out The user-allocated git_buf which will be filled with the * cleaned up message. @@ -38,6 +37,47 @@ */ GIT_EXTERN(int) git_message_prettify(git_buf *out, const char *message, int strip_comments, char comment_char); +/** + * Represents a single git message trailer. + */ +typedef struct { + const char *key; + const char *value; +} git_message_trailer; + +/** + * Represents an array of git message trailers. + * + * Struct members under the private comment are private, subject to change + * and should not be used by callers. + */ +typedef struct { + git_message_trailer *trailers; + size_t count; + + /* private */ + char *_trailer_block; +} git_message_trailer_array; + +/** + * Parse trailers out of a message, filling the array pointed to by +arr+. + * + * Trailers are key/value pairs in the last paragraph of a message, not + * including any patches or conflicts that may be present. + * + * @param arr A pre-allocated git_message_trailer_array struct to be filled in + * with any trailers found during parsing. + * @param message The message to be parsed + * @return 0 on success, or non-zero on error. + */ +GIT_EXTERN(int) git_message_trailers(git_message_trailer_array *arr, const char *message); + +/** + * Clean's up any allocated memory in the git_message_trailer_array filled by + * a call to git_message_trailers. + */ +GIT_EXTERN(void) git_message_trailer_array_free(git_message_trailer_array *arr); + /** @} */ GIT_END_DECL diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/notes.h r-cran-git2r-0.22.1/src/libgit2/include/git2/notes.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/notes.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/notes.h 2018-07-10 13:23:34.000000000 +0000 @@ -52,6 +52,20 @@ const char *notes_ref); /** + * Creates a new iterator for notes from a commit + * + * The iterator must be freed manually by the user. + * + * @param out pointer to the iterator + * @param notes_commit a pointer to the notes commit object + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_commit_iterator_new( + git_note_iterator **out, + git_commit *notes_commit); + +/** * Frees an git_note_iterator * * @param it pointer to the iterator @@ -94,6 +108,25 @@ const char *notes_ref, const git_oid *oid); + +/** + * Read the note for an object from a note commit + * + * The note must be freed manually by the user. + * + * @param out pointer to the read note; NULL in case of error + * @param repo repository where to look up the note + * @param notes_commit a pointer to the notes commit object + * @param oid OID of the git object to read the note from + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_commit_read( + git_note **out, + git_repository *repo, + git_commit *notes_commit, + const git_oid *oid); + /** * Get the note author * @@ -153,6 +186,36 @@ const char *note, int force); +/** + * Add a note for an object from a commit + * + * This function will create a notes commit for a given object, + * the commit is a dangling commit, no reference is created. + * + * @param notes_commit_out pointer to store the commit (optional); + * NULL in case of error + * @param notes_blob_out a point to the id of a note blob (optional) + * @param repo repository where the note will live + * @param parent Pointer to parent note + * or NULL if this shall start a new notes tree + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer + * @param oid OID of the git object to decorate + * @param note Content of the note to add for object oid + * @param allow_note_overwrite Overwrite existing note + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_commit_create( + git_oid *notes_commit_out, + git_oid *notes_blob_out, + git_repository *repo, + git_commit *parent, + const git_signature *author, + const git_signature *committer, + const git_oid *oid, + const char *note, + int allow_note_overwrite); /** * Remove the note for an object @@ -174,6 +237,32 @@ const git_oid *oid); /** + * Remove the note for an object + * + * @param notes_commit_out pointer to store the new notes commit (optional); + * NULL in case of error. + * When removing a note a new tree containing all notes + * sans the note to be removed is created and a new commit + * pointing to that tree is also created. + * In the case where the resulting tree is an empty tree + * a new commit pointing to this empty tree will be returned. + * @param repo repository where the note lives + * @param notes_commit a pointer to the notes commit object + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer + * @param oid OID of the git object to remove the note from + * + * @return 0 or an error code + */ +GIT_EXTERN(int) git_note_commit_remove( + git_oid *notes_commit_out, + git_repository *repo, + git_commit *notes_commit, + const git_signature *author, + const git_signature *committer, + const git_oid *oid); + +/** * Free a git_note object * * @param note git_note object diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/odb.h r-cran-git2r-0.22.1/src/libgit2/include/git2/odb.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/odb.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/odb.h 2018-07-10 13:23:34.000000000 +0000 @@ -357,11 +357,18 @@ * @see git_odb_stream * * @param out pointer where to store the stream + * @param len pointer where to store the length of the object + * @param type pointer where to store the type of the object * @param db object database where the stream will read from * @param oid oid of the object the stream will read from * @return 0 if the stream was created; error code otherwise */ -GIT_EXTERN(int) git_odb_open_rstream(git_odb_stream **out, git_odb *db, const git_oid *oid); +GIT_EXTERN(int) git_odb_open_rstream( + git_odb_stream **out, + size_t *len, + git_otype *type, + git_odb *db, + const git_oid *oid); /** * Open a stream for writing a pack file to the ODB. diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/patch.h r-cran-git2r-0.22.1/src/libgit2/include/git2/patch.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/patch.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/patch.h 2018-07-10 13:23:34.000000000 +0000 @@ -96,7 +96,7 @@ git_patch **out, const git_blob *old_blob, const char *old_as_path, - const char *buffer, + const void *buffer, size_t buffer_len, const char *buffer_as_path, const git_diff_options *opts); @@ -124,7 +124,7 @@ const void *old_buffer, size_t old_len, const char *old_as_path, - const char *new_buffer, + const void *new_buffer, size_t new_len, const char *new_as_path, const git_diff_options *opts); diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/pathspec.h r-cran-git2r-0.22.1/src/libgit2/include/git2/pathspec.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/pathspec.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/pathspec.h 2018-07-10 13:23:34.000000000 +0000 @@ -26,32 +26,49 @@ /** * Options controlling how pathspec match should be executed - * - * - GIT_PATHSPEC_IGNORE_CASE forces match to ignore case; otherwise - * match will use native case sensitivity of platform filesystem - * - GIT_PATHSPEC_USE_CASE forces case sensitive match; otherwise - * match will use native case sensitivity of platform filesystem - * - GIT_PATHSPEC_NO_GLOB disables glob patterns and just uses simple - * string comparison for matching - * - GIT_PATHSPEC_NO_MATCH_ERROR means the match functions return error - * code GIT_ENOTFOUND if no matches are found; otherwise no matches is - * still success (return 0) but `git_pathspec_match_list_entrycount` - * will indicate 0 matches. - * - GIT_PATHSPEC_FIND_FAILURES means that the `git_pathspec_match_list` - * should track which patterns matched which files so that at the end of - * the match we can identify patterns that did not match any files. - * - GIT_PATHSPEC_FAILURES_ONLY means that the `git_pathspec_match_list` - * does not need to keep the actual matching filenames. Use this to - * just test if there were any matches at all or in combination with - * GIT_PATHSPEC_FIND_FAILURES to validate a pathspec. */ typedef enum { GIT_PATHSPEC_DEFAULT = 0, + + /** + * GIT_PATHSPEC_IGNORE_CASE forces match to ignore case; otherwise + * match will use native case sensitivity of platform filesystem + */ GIT_PATHSPEC_IGNORE_CASE = (1u << 0), + + /** + * GIT_PATHSPEC_USE_CASE forces case sensitive match; otherwise + * match will use native case sensitivity of platform filesystem + */ GIT_PATHSPEC_USE_CASE = (1u << 1), + + /** + * GIT_PATHSPEC_NO_GLOB disables glob patterns and just uses simple + * string comparison for matching + */ GIT_PATHSPEC_NO_GLOB = (1u << 2), + + /** + * GIT_PATHSPEC_NO_MATCH_ERROR means the match functions return error + * code GIT_ENOTFOUND if no matches are found; otherwise no matches is + * still success (return 0) but `git_pathspec_match_list_entrycount` + * will indicate 0 matches. + */ GIT_PATHSPEC_NO_MATCH_ERROR = (1u << 3), + + /** + * GIT_PATHSPEC_FIND_FAILURES means that the `git_pathspec_match_list` + * should track which patterns matched which files so that at the end of + * the match we can identify patterns that did not match any files. + */ GIT_PATHSPEC_FIND_FAILURES = (1u << 4), + + /** + * GIT_PATHSPEC_FAILURES_ONLY means that the `git_pathspec_match_list` + * does not need to keep the actual matching filenames. Use this to + * just test if there were any matches at all or in combination with + * GIT_PATHSPEC_FIND_FAILURES to validate a pathspec. + */ GIT_PATHSPEC_FAILURES_ONLY = (1u << 5), } git_pathspec_flag_t; diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/refs.h r-cran-git2r-0.22.1/src/libgit2/include/git2/refs.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/refs.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/refs.h 2018-07-10 13:23:34.000000000 +0000 @@ -433,6 +433,9 @@ * passed to this method. Returning a non-zero value from the callback * will terminate the iteration. * + * Note that the callback function is responsible to call `git_reference_free` + * on each reference passed to it. + * * @param repo Repository where to find the refs * @param callback Function which will be called for every listed ref * @param payload Additional data to pass to the callback diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/remote.h r-cran-git2r-0.22.1/src/libgit2/include/git2/remote.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/remote.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/remote.h 2018-07-10 13:23:34.000000000 +0000 @@ -76,6 +76,24 @@ const char *url); /** + * Create a remote without a connected local repo + * + * Create a remote with the given url in-memory. You can use this when + * you have a URL instead of a remote's name. + * + * Contrasted with git_remote_create_anonymous, a detached remote + * will not consider any repo configuration values (such as insteadof url + * substitutions). + * + * @param out pointer to the new remote objects + * @param url the remote repository's URL + * @return 0 or an error code + */ +GIT_EXTERN(int) git_remote_create_detached( + git_remote **out, + const char *url); + +/** * Get the information for a particular remote * * The name will be checked for validity. @@ -368,6 +386,20 @@ typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload); /** + * Callback used to inform of the update status from the remote. + * + * Called for each updated reference on push. If `status` is + * not `NULL`, the update was rejected by the remote server + * and `status` contains the reason given. + * + * @param refname refname specifying to the remote ref + * @param status status message sent from the remote + * @param data data provided by the caller + * @return 0 on success, otherwise an error + */ +typedef int (*git_push_update_reference_cb)(const char *refname, const char *status, void *data); + +/** * The callback settings structure * * Set the callbacks to be called by the remote when informing the user @@ -434,11 +466,9 @@ git_push_transfer_progress push_transfer_progress; /** - * Called for each updated reference on push. If `status` is - * not `NULL`, the update was rejected by the remote server - * and `status` contains the reason given. + * See documentation of git_push_update_reference_cb */ - int (*push_update_reference)(const char *refname, const char *status, void *data); + git_push_update_reference_cb push_update_reference; /** * Called once between the negotiation step and the upload. It diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/repository.h r-cran-git2r-0.22.1/src/libgit2/include/git2/repository.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/repository.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/repository.h 2018-07-10 13:23:34.000000000 +0000 @@ -440,7 +440,7 @@ * @param item The repository item for which to retrieve the path * @return 0, GIT_ENOTFOUND if the path cannot exist or an error code */ -GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item); +GIT_EXTERN(int) git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item); /** * Get the path of this repository @@ -451,7 +451,7 @@ * @param repo A repository object * @return the path to the repository */ -GIT_EXTERN(const char *) git_repository_path(git_repository *repo); +GIT_EXTERN(const char *) git_repository_path(const git_repository *repo); /** * Get the path of the working directory for this repository @@ -462,7 +462,7 @@ * @param repo A repository object * @return the path to the working dir, if it exists */ -GIT_EXTERN(const char *) git_repository_workdir(git_repository *repo); +GIT_EXTERN(const char *) git_repository_workdir(const git_repository *repo); /** * Get the path of the shared common directory for this repository @@ -473,7 +473,7 @@ * @param repo A repository object * @return the path to the common dir */ -GIT_EXTERN(const char *) git_repository_commondir(git_repository *repo); +GIT_EXTERN(const char *) git_repository_commondir(const git_repository *repo); /** * Set the path to the working directory for this repository @@ -501,7 +501,7 @@ * @param repo Repo to test * @return 1 if the repository is bare, 0 otherwise. */ -GIT_EXTERN(int) git_repository_is_bare(git_repository *repo); +GIT_EXTERN(int) git_repository_is_bare(const git_repository *repo); /** * Check if a repository is a linked work tree @@ -509,7 +509,7 @@ * @param repo Repo to test * @return 1 if the repository is a linked work tree, 0 otherwise. */ -GIT_EXTERN(int) git_repository_is_worktree(git_repository *repo); +GIT_EXTERN(int) git_repository_is_worktree(const git_repository *repo); /** * Get the configuration file for this repository. diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/reset.h r-cran-git2r-0.22.1/src/libgit2/include/git2/reset.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/reset.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/reset.h 2018-07-10 13:23:34.000000000 +0000 @@ -61,7 +61,7 @@ */ GIT_EXTERN(int) git_reset( git_repository *repo, - git_object *target, + const git_object *target, git_reset_t reset_type, const git_checkout_options *checkout_opts); @@ -79,7 +79,7 @@ */ GIT_EXTERN(int) git_reset_from_annotated( git_repository *repo, - git_annotated_commit *commit, + const git_annotated_commit *commit, git_reset_t reset_type, const git_checkout_options *checkout_opts); @@ -103,8 +103,8 @@ */ GIT_EXTERN(int) git_reset_default( git_repository *repo, - git_object *target, - git_strarray* pathspecs); + const git_object *target, + const git_strarray* pathspecs); /** @} */ GIT_END_DECL diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/status.h r-cran-git2r-0.22.1/src/libgit2/include/git2/status.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/status.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/status.h 2018-07-10 13:23:34.000000000 +0000 @@ -173,12 +173,16 @@ * The `pathspec` is an array of path patterns to match (using * fnmatch-style matching), or just an array of paths to match exactly if * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags. + * + * The `baseline` is the tree to be used for comparison to the working directory + * and index; defaults to HEAD. */ typedef struct { unsigned int version; git_status_show_t show; unsigned int flags; git_strarray pathspec; + git_tree *baseline; } git_status_options; #define GIT_STATUS_OPTIONS_VERSION 1 diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/config.h r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/config.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/config.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/config.h 2018-07-10 13:23:34.000000000 +0000 @@ -58,7 +58,7 @@ struct git_config *cfg; /* Open means open the file/database and parse if necessary */ - int (*open)(struct git_config_backend *, git_config_level_t level); + int (*open)(struct git_config_backend *, git_config_level_t level, const git_repository *repo); int (*get)(struct git_config_backend *, const char *key, git_config_entry **entry); int (*set)(struct git_config_backend *, const char *key, const char *value); int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value); @@ -111,6 +111,8 @@ * @param cfg the configuration to add the file to * @param file the configuration file (backend) to add * @param level the priority level of the backend + * @param repo optional repository to allow parsing of + * conditional includes * @param force if a config file already exists for the given * priority level, replace it * @return 0 on success, GIT_EEXISTS when adding more than one file @@ -120,6 +122,7 @@ git_config *cfg, git_config_backend *file, git_config_level_t level, + const git_repository *repo, int force); /** @} */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/mempack.h r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/mempack.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/mempack.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/mempack.h 2018-07-10 13:23:34.000000000 +0000 @@ -11,6 +11,7 @@ #include "git2/types.h" #include "git2/oid.h" #include "git2/odb.h" +#include "git2/buffer.h" /** * @file git2/sys/mempack.h @@ -38,10 +39,10 @@ * Subsequent reads will also be served from the in-memory store * to ensure consistency, until the memory store is dumped. * - * @param out Poiter where to store the ODB backend + * @param out Pointer where to store the ODB backend * @return 0 on success; error code otherwise */ -int git_mempack_new(git_odb_backend **out); +GIT_EXTERN(int) git_mempack_new(git_odb_backend **out); /** * Dump all the queued in-memory writes to a packfile. @@ -64,7 +65,7 @@ * @param backend The mempack backend * @return 0 on success; error code otherwise */ -int git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *backend); +GIT_EXTERN(int) git_mempack_dump(git_buf *pack, git_repository *repo, git_odb_backend *backend); /** * Reset the memory packer by clearing all the queued objects. @@ -78,7 +79,7 @@ * * @param backend The mempack backend */ -void git_mempack_reset(git_odb_backend *backend); +GIT_EXTERN(void) git_mempack_reset(git_odb_backend *backend); GIT_END_DECL diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/odb_backend.h r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/odb_backend.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/odb_backend.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/odb_backend.h 2018-07-10 13:23:34.000000000 +0000 @@ -56,7 +56,8 @@ git_odb_stream **, git_odb_backend *, git_off_t, git_otype); int (* readstream)( - git_odb_stream **, git_odb_backend *, const git_oid *); + git_odb_stream **, size_t *, git_otype *, + git_odb_backend *, const git_oid *); int (* exists)( git_odb_backend *, const git_oid *); diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/remote.h r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/remote.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/sys/remote.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/sys/remote.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* - * 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_sys_git_transport_h -#define INCLUDE_sys_git_transport_h - -#include "git2/net.h" -#include "git2/types.h" - -GIT_BEGIN_DECL - -GIT_END_DECL diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/tree.h r-cran-git2r-0.22.1/src/libgit2/include/git2/tree.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/tree.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/tree.h 2018-07-10 13:23:34.000000000 +0000 @@ -307,9 +307,10 @@ * pointer may not be valid past the next operation in this * builder. Duplicate the entry if you want to keep it. * - * No attempt is being made to ensure that the provided oid points - * to an existing git object in the object database, nor that the - * attributes make sense regarding the type of the pointed at object. + * By default the entry that you are inserting will be checked for + * validity; that it exists in the object database and is of the + * correct type. If you do not want this behavior, set the + * `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` library option to false. * * @param out Pointer to store the entry (optional) * @param bld Tree builder diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/types.h r-cran-git2r-0.22.1/src/libgit2/include/git2/types.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/types.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/types.h 2018-07-10 13:23:34.000000000 +0000 @@ -159,6 +159,7 @@ typedef struct git_time { git_time_t time; /**< time in seconds from epoch */ int offset; /**< timezone offset, in minutes */ + char sign; /**< indicator for questionable '-0000' offsets in signature */ } git_time; /** An action signature (e.g. for committers, taggers, etc) */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/version.h r-cran-git2r-0.22.1/src/libgit2/include/git2/version.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/version.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/version.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,12 +7,12 @@ #ifndef INCLUDE_git_version_h__ #define INCLUDE_git_version_h__ -#define LIBGIT2_VERSION "0.26.0" +#define LIBGIT2_VERSION "0.27.2" #define LIBGIT2_VER_MAJOR 0 -#define LIBGIT2_VER_MINOR 26 -#define LIBGIT2_VER_REVISION 0 +#define LIBGIT2_VER_MINOR 27 +#define LIBGIT2_VER_REVISION 2 #define LIBGIT2_VER_PATCH 0 -#define LIBGIT2_SOVERSION 26 +#define LIBGIT2_SOVERSION 27 #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2/worktree.h r-cran-git2r-0.22.1/src/libgit2/include/git2/worktree.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2/worktree.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2/worktree.h 2018-07-10 13:23:34.000000000 +0000 @@ -123,7 +123,7 @@ * @param reason Reason why the working tree is being locked * @return 0 on success, non-zero otherwise */ -GIT_EXTERN(int) git_worktree_lock(git_worktree *wt, char *reason); +GIT_EXTERN(int) git_worktree_lock(git_worktree *wt, const char *reason); /** * Unlock a locked worktree diff -Nru r-cran-git2r-0.21.0/src/libgit2/include/git2.h r-cran-git2r-0.22.1/src/libgit2/include/git2.h --- r-cran-git2r-0.21.0/src/libgit2/include/git2.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/include/git2.h 2018-07-10 13:23:34.000000000 +0000 @@ -62,5 +62,6 @@ #include "git2/tree.h" #include "git2/types.h" #include "git2/version.h" +#include "git2/worktree.h" #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/annotated_commit.c r-cran-git2r-0.22.1/src/libgit2/src/annotated_commit.c --- r-cran-git2r-0.21.0/src/libgit2/src/annotated_commit.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/annotated_commit.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "annotated_commit.h" + #include "refs.h" #include "cache.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/annotated_commit.h r-cran-git2r-0.22.1/src/libgit2/src/annotated_commit.h --- r-cran-git2r-0.21.0/src/libgit2/src/annotated_commit.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/annotated_commit.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_annotated_commit_h__ #define INCLUDE_annotated_commit_h__ +#include "common.h" + #include "oidarray.h" #include "git2/oid.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/apply.c r-cran-git2r-0.22.1/src/libgit2/src/apply.c --- r-cran-git2r-0.21.0/src/libgit2/src/apply.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/apply.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "apply.h" + #include #include "git2/patch.h" @@ -12,7 +14,6 @@ #include "array.h" #include "patch.h" #include "fileops.h" -#include "apply.h" #include "delta.h" #include "zstream.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/apply.h r-cran-git2r-0.22.1/src/libgit2/src/apply.h --- r-cran-git2r-0.21.0/src/libgit2/src/apply.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/apply.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_apply_h__ #define INCLUDE_apply_h__ +#include "common.h" + #include "git2/patch.h" #include "buffer.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/attr.c r-cran-git2r-0.22.1/src/libgit2/src/attr.c --- r-cran-git2r-0.21.0/src/libgit2/src/attr.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/attr.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,4 +1,12 @@ -#include "common.h" +/* + * 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. + */ + +#include "attr.h" + #include "repository.h" #include "sysdir.h" #include "config.h" @@ -48,12 +56,16 @@ git_attr_file *file; git_attr_name attr; git_attr_rule *rule; + git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN; assert(value && repo && name); *value = NULL; - if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0) + if (git_repository_is_bare(repo)) + dir_flag = GIT_DIR_FLAG_FALSE; + + if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0) return -1; if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0) @@ -106,13 +118,17 @@ git_attr_rule *rule; attr_get_many_info *info = NULL; size_t num_found = 0; + git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN; if (!num_attr) return 0; assert(values && repo && names); - if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0) + if (git_repository_is_bare(repo)) + dir_flag = GIT_DIR_FLAG_FALSE; + + if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0) return -1; if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0) @@ -188,10 +204,14 @@ git_attr_rule *rule; git_attr_assignment *assign; git_strmap *seen = NULL; + git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN; assert(repo && callback); - if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0) + if (git_repository_is_bare(repo)) + dir_flag = GIT_DIR_FLAG_FALSE; + + if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0) return -1; if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 || diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/attrcache.c r-cran-git2r-0.22.1/src/libgit2/src/attrcache.c --- r-cran-git2r-0.21.0/src/libgit2/src/attrcache.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/attrcache.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,4 +1,12 @@ -#include "common.h" +/* + * 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. + */ + +#include "attrcache.h" + #include "repository.h" #include "attr_file.h" #include "config.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/attrcache.h r-cran-git2r-0.22.1/src/libgit2/src/attrcache.h --- r-cran-git2r-0.21.0/src/libgit2/src/attrcache.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/attrcache.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_attrcache_h__ #define INCLUDE_attrcache_h__ +#include "common.h" + #include "attr_file.h" #include "strmap.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/attr_file.c r-cran-git2r-0.22.1/src/libgit2/src/attr_file.c --- r-cran-git2r-0.21.0/src/libgit2/src/attr_file.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/attr_file.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,7 +1,14 @@ -#include "common.h" +/* + * 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. + */ + +#include "attr_file.h" + #include "repository.h" #include "filebuf.h" -#include "attr_file.h" #include "attrcache.h" #include "git2/blob.h" #include "git2/tree.h" @@ -626,6 +633,11 @@ if (--spec->length == 0) return GIT_ENOTFOUND; + /* Remove trailing spaces. */ + while (pattern[spec->length - 1] == ' ' || pattern[spec->length - 1] == '\t') + if (--spec->length == 0) + return GIT_ENOTFOUND; + if (pattern[spec->length - 1] == '/') { spec->length--; spec->flags = spec->flags | GIT_ATTR_FNMATCH_DIRECTORY; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/attr_file.h r-cran-git2r-0.22.1/src/libgit2/src/attr_file.h --- r-cran-git2r-0.21.0/src/libgit2/src/attr_file.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/attr_file.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_attr_file_h__ #define INCLUDE_attr_file_h__ +#include "common.h" + #include "git2/oid.h" #include "git2/attr.h" #include "vector.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/attr.h r-cran-git2r-0.22.1/src/libgit2/src/attr.h --- r-cran-git2r-0.21.0/src/libgit2/src/attr.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/attr.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_attr_h__ #define INCLUDE_attr_h__ +#include "common.h" + #include "attr_file.h" #include "attrcache.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/blame.c r-cran-git2r-0.22.1/src/libgit2/src/blame.c --- r-cran-git2r-0.21.0/src/libgit2/src/blame.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/blame.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "blame.h" + #include "git2/commit.h" #include "git2/revparse.h" #include "git2/revwalk.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/blame_git.c r-cran-git2r-0.22.1/src/libgit2/src/blame_git.c --- r-cran-git2r-0.21.0/src/libgit2/src/blame_git.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/blame_git.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "blame_git.h" + #include "commit.h" #include "blob.h" #include "xdiff/xinclude.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/blame_git.h r-cran-git2r-0.22.1/src/libgit2/src/blame_git.h --- r-cran-git2r-0.21.0/src/libgit2/src/blame_git.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/blame_git.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_blame_git__ #define INCLUDE_blame_git__ +#include "common.h" + #include "blame.h" int git_blame__get_origin( diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/blame.h r-cran-git2r-0.22.1/src/libgit2/src/blame.h --- r-cran-git2r-0.21.0/src/libgit2/src/blame.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/blame.h 2018-07-10 13:23:34.000000000 +0000 @@ -1,8 +1,9 @@ #ifndef INCLUDE_blame_h__ #define INCLUDE_blame_h__ -#include "git2/blame.h" #include "common.h" + +#include "git2/blame.h" #include "vector.h" #include "diff.h" #include "array.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/blob.c r-cran-git2r-0.22.1/src/libgit2/src/blob.c --- r-cran-git2r-0.21.0/src/libgit2/src/blob.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/blob.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,14 +5,14 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "blob.h" + #include "git2/common.h" #include "git2/object.h" #include "git2/repository.h" #include "git2/odb_backend.h" -#include "common.h" #include "filebuf.h" -#include "blob.h" #include "filter.h" #include "buf_text.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/blob.h r-cran-git2r-0.22.1/src/libgit2/src/blob.h --- r-cran-git2r-0.21.0/src/libgit2/src/blob.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/blob.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_blob_h__ #define INCLUDE_blob_h__ +#include "common.h" + #include "git2/blob.h" #include "repository.h" #include "odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/branch.c r-cran-git2r-0.22.1/src/libgit2/src/branch.c --- r-cran-git2r-0.21.0/src/libgit2/src/branch.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/branch.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "branch.h" + #include "commit.h" #include "tag.h" #include "config.h" @@ -69,6 +70,12 @@ assert(branch_name && commit && ref_out); assert(git_object_owner((const git_object *)commit) == repository); + if (!git__strcmp(branch_name, "HEAD")) { + giterr_set(GITERR_REFERENCE, "'HEAD' is not a valid branch name"); + error = -1; + goto cleanup; + } + if (force && !bare && git_branch_lookup(&branch, repository, branch_name, GIT_BRANCH_LOCAL) == 0) { error = git_branch_is_head(branch); git_reference_free(branch); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/branch.h r-cran-git2r-0.22.1/src/libgit2/src/branch.h --- r-cran-git2r-0.21.0/src/libgit2/src/branch.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/branch.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_branch_h__ #define INCLUDE_branch_h__ +#include "common.h" + #include "buffer.h" int git_branch_upstream__name( diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/buffer.c r-cran-git2r-0.22.1/src/libgit2/src/buffer.c --- r-cran-git2r-0.21.0/src/libgit2/src/buffer.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/buffer.c 2018-07-10 13:23:34.000000000 +0000 @@ -212,7 +212,7 @@ size_t new_size; assert(data); - + GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, len); GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); ENSURE_SIZE(buf, new_size); @@ -455,6 +455,36 @@ return -1; } +#define HEX_DECODE(c) ((c | 32) % 39 - 9) + +int git_buf_decode_percent( + git_buf *buf, + const char *str, + size_t str_len) +{ + size_t str_pos, new_size; + + GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, str_len); + GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); + ENSURE_SIZE(buf, new_size); + + for (str_pos = 0; str_pos < str_len; buf->size++, str_pos++) { + if (str[str_pos] == '%' && + str_len > str_pos + 2 && + isxdigit(str[str_pos + 1]) && + isxdigit(str[str_pos + 2])) { + buf->ptr[buf->size] = (HEX_DECODE(str[str_pos + 1]) << 4) + + HEX_DECODE(str[str_pos + 2]); + str_pos += 2; + } else { + buf->ptr[buf->size] = str[str_pos]; + } + } + + buf->ptr[buf->size] = '\0'; + return 0; +} + int git_buf_vprintf(git_buf *buf, const char *format, va_list ap) { size_t expected_size, new_size; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/buffer.h r-cran-git2r-0.22.1/src/libgit2/src/buffer.h --- r-cran-git2r-0.21.0/src/libgit2/src/buffer.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/buffer.h 2018-07-10 13:23:34.000000000 +0000 @@ -190,6 +190,9 @@ /* Decode the given "base85" and write the result to the buffer */ int git_buf_decode_base85(git_buf *buf, const char *base64, size_t len, size_t output_len); +/* Decode the given percent-encoded string and write the result to the buffer */ +int git_buf_decode_percent(git_buf *buf, const char *str, size_t len); + /* * Insert, remove or replace a portion of the buffer. * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/buf_text.c r-cran-git2r-0.22.1/src/libgit2/src/buf_text.c --- r-cran-git2r-0.21.0/src/libgit2/src/buf_text.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/buf_text.c 2018-07-10 13:23:34.000000000 +0000 @@ -188,7 +188,7 @@ git_bom_t bom; int printable = 0, nonprintable = 0; - scan += git_buf_text_detect_bom(&bom, buf, 0); + scan += git_buf_text_detect_bom(&bom, buf); if (bom > GIT_BOM_UTF8) return 1; @@ -215,18 +215,18 @@ return (memchr(buf->ptr, '\0', buf->size) != NULL); } -int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf, size_t offset) +int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf) { const char *ptr; size_t len; *bom = GIT_BOM_NONE; - /* need at least 2 bytes after offset to look for any BOM */ - if (buf->size < offset + 2) + /* need at least 2 bytes to look for any BOM */ + if (buf->size < 2) return 0; - ptr = buf->ptr + offset; - len = buf->size - offset; + ptr = buf->ptr; + len = buf->size; switch (*ptr++) { case 0: @@ -274,7 +274,7 @@ memset(stats, 0, sizeof(*stats)); /* BOM detection */ - skip = git_buf_text_detect_bom(&stats->bom, buf, 0); + skip = git_buf_text_detect_bom(&stats->bom, buf); if (skip_bom) scan += skip; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/buf_text.h r-cran-git2r-0.22.1/src/libgit2/src/buf_text.h --- r-cran-git2r-0.21.0/src/libgit2/src/buf_text.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/buf_text.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_buf_text_h__ #define INCLUDE_buf_text_h__ +#include "common.h" + #include "buffer.h" typedef enum { @@ -97,11 +99,9 @@ * * @param bom Set to the type of BOM detected or GIT_BOM_NONE * @param buf Buffer in which to check the first bytes for a BOM - * @param offset Offset into buffer to look for BOM * @return Number of bytes of BOM data (or 0 if no BOM found) */ -extern int git_buf_text_detect_bom( - git_bom_t *bom, const git_buf *buf, size_t offset); +extern int git_buf_text_detect_bom(git_bom_t *bom, const git_buf *buf); /** * Gather stats for a piece of text diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/cache.c r-cran-git2r-0.22.1/src/libgit2/src/cache.c --- r-cran-git2r-0.21.0/src/libgit2/src/cache.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/cache.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,12 +5,12 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "cache.h" + #include "repository.h" #include "commit.h" #include "thread-utils.h" #include "util.h" -#include "cache.h" #include "odb.h" #include "object.h" #include "git2/oid.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/cache.h r-cran-git2r-0.22.1/src/libgit2/src/cache.h --- r-cran-git2r-0.21.0/src/libgit2/src/cache.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/cache.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_cache_h__ #define INCLUDE_cache_h__ +#include "common.h" + #include "git2/common.h" #include "git2/oid.h" #include "git2/odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/cc-compat.h r-cran-git2r-0.22.1/src/libgit2/src/cc-compat.h --- r-cran-git2r-0.21.0/src/libgit2/src/cc-compat.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/cc-compat.h 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,8 @@ * 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_compat_h__ -#define INCLUDE_compat_h__ +#ifndef INCLUDE_cc_compat_h__ +#define INCLUDE_cc_compat_h__ #include @@ -46,7 +46,7 @@ #define GIT_UNUSED(x) ((void)(x)) /* Define the printf format specifer to use for size_t output */ -#if defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) # define PRIuZ "Iu" # define PRIxZ "Ix" # define PRIdZ "Id" @@ -84,4 +84,4 @@ # endif #endif -#endif /* INCLUDE_compat_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/checkout.c r-cran-git2r-0.22.1/src/libgit2/src/checkout.c --- r-cran-git2r-0.21.0/src/libgit2/src/checkout.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/checkout.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,10 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include - #include "checkout.h" +#include + #include "git2/repository.h" #include "git2/refs.h" #include "git2/tree.h" @@ -70,6 +70,7 @@ git_buf tmp; unsigned int strategy; int can_symlink; + int respect_filemode; bool reload_submodules; size_t total_steps; size_t completed_steps; @@ -159,6 +160,22 @@ git_oid__cmp(&newitem->id, workdir_id) == 0); } +GIT_INLINE(bool) is_filemode_changed(git_filemode_t a, git_filemode_t b, int respect_filemode) +{ + /* If core.filemode = false, ignore links in the repository and executable bit changes */ + if (!respect_filemode) { + if (a == S_IFLNK) + a = GIT_FILEMODE_BLOB; + if (b == S_IFLNK) + b = GIT_FILEMODE_BLOB; + + a &= ~0111; + b &= ~0111; + } + + return (a != b); +} + static bool checkout_is_workdir_modified( checkout_data *data, const git_diff_file *baseitem, @@ -192,16 +209,23 @@ return rval; } - /* Look at the cache to decide if the workdir is modified. If not, - * we can simply compare the oid in the cache to the baseitem instead - * of hashing the file. If so, we allow the checkout to proceed if the - * oid is identical (ie, the staged item is what we're trying to check - * out.) + /* + * Look at the cache to decide if the workdir is modified: if the + * cache contents match the workdir contents, then we do not need + * to examine the working directory directly, instead we can + * examine the cache to see if _it_ has been modified. This allows + * us to avoid touching the disk. */ - if ((ie = git_index_get_bypath(data->index, wditem->path, 0)) != NULL) { - if (git_index_time_eq(&wditem->mtime, &ie->mtime) && - wditem->file_size == ie->file_size) - return !is_workdir_base_or_new(&ie->id, baseitem, newitem); + ie = git_index_get_bypath(data->index, wditem->path, 0); + + if (ie != NULL && + git_index_time_eq(&wditem->mtime, &ie->mtime) && + wditem->file_size == ie->file_size && + !is_filemode_changed(wditem->mode, ie->mode, data->respect_filemode)) { + + /* The workdir is modified iff the index entry is modified */ + return !is_workdir_base_or_new(&ie->id, baseitem, newitem) || + is_filemode_changed(baseitem->mode, ie->mode, data->respect_filemode); } /* depending on where base is coming from, we may or may not know @@ -214,6 +238,9 @@ if (S_ISDIR(wditem->mode)) return false; + if (is_filemode_changed(baseitem->mode, wditem->mode, data->respect_filemode)) + return true; + if (git_diff__oid_for_entry(&oid, data->diff, wditem, wditem->mode, NULL) < 0) return false; @@ -1249,14 +1276,14 @@ unsigned int flags = GIT_PATH_REJECT_WORKDIR_DEFAULTS; if (action & CHECKOUT_ACTION__REMOVE) { - if (!git_path_isvalid(repo, delta->old_file.path, flags)) { + if (!git_path_isvalid(repo, delta->old_file.path, delta->old_file.mode, flags)) { giterr_set(GITERR_CHECKOUT, "cannot remove invalid path '%s'", delta->old_file.path); return -1; } } if (action & ~CHECKOUT_ACTION__REMOVE) { - if (!git_path_isvalid(repo, delta->new_file.path, flags)) { + if (!git_path_isvalid(repo, delta->new_file.path, delta->new_file.mode, flags)) { giterr_set(GITERR_CHECKOUT, "cannot checkout to invalid path '%s'", delta->new_file.path); return -1; } @@ -2005,8 +2032,11 @@ (error = checkout_safe_for_update_only(data, fullpath->ptr, side->mode)) <= 0) return error; - return checkout_write_content(data, - &side->id, fullpath->ptr, hint_path, side->mode, &st); + if (!S_ISGITLINK(side->mode)) + return checkout_write_content(data, + &side->id, fullpath->ptr, hint_path, side->mode, &st); + + return 0; } static int checkout_write_entries( @@ -2428,6 +2458,10 @@ &data->can_symlink, repo, GIT_CVAR_SYMLINKS)) < 0) goto cleanup; + if ((error = git_repository__cvar( + &data->respect_filemode, repo, GIT_CVAR_FILEMODE)) < 0) + goto cleanup; + if (!data->opts.baseline && !data->opts.baseline_index) { data->opts_free_baseline = true; error = 0; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/checkout.h r-cran-git2r-0.22.1/src/libgit2/src/checkout.h --- r-cran-git2r-0.21.0/src/libgit2/src/checkout.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/checkout.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_checkout_h__ #define INCLUDE_checkout_h__ +#include "common.h" + #include "git2/checkout.h" #include "iterator.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/cherrypick.c r-cran-git2r-0.22.1/src/libgit2/src/cherrypick.c --- r-cran-git2r-0.21.0/src/libgit2/src/cherrypick.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/cherrypick.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "repository.h" #include "filebuf.h" #include "merge.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/clone.c r-cran-git2r-0.22.1/src/libgit2/src/clone.c --- r-cran-git2r-0.21.0/src/libgit2/src/clone.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/clone.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "clone.h" + #include #include "git2/clone.h" @@ -16,7 +18,6 @@ #include "git2/commit.h" #include "git2/tree.h" -#include "common.h" #include "remote.h" #include "fileops.h" #include "refs.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/clone.h r-cran-git2r-0.22.1/src/libgit2/src/clone.h --- r-cran-git2r-0.21.0/src/libgit2/src/clone.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/clone.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,10 @@ #ifndef INCLUDE_clone_h__ #define INCLUDE_clone_h__ +#include "common.h" + +#include "git2/clone.h" + extern int git_clone__should_clone_local(const char *url, git_clone_local_t local); #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/commit.c r-cran-git2r-0.22.1/src/libgit2/src/commit.c --- r-cran-git2r-0.21.0/src/libgit2/src/commit.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/commit.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,13 +5,14 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "commit.h" + #include "git2/common.h" #include "git2/object.h" #include "git2/repository.h" #include "git2/signature.h" #include "git2/sys/commit.h" -#include "common.h" #include "odb.h" #include "commit.h" #include "signature.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/commit.h r-cran-git2r-0.22.1/src/libgit2/src/commit.h --- r-cran-git2r-0.21.0/src/libgit2/src/commit.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/commit.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_commit_h__ #define INCLUDE_commit_h__ +#include "common.h" + #include "git2/commit.h" #include "tree.h" #include "repository.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/commit_list.c r-cran-git2r-0.22.1/src/libgit2/src/commit_list.c --- r-cran-git2r-0.21.0/src/libgit2/src/commit_list.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/commit_list.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,7 +6,7 @@ */ #include "commit_list.h" -#include "common.h" + #include "revwalk.h" #include "pool.h" #include "odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/commit_list.h r-cran-git2r-0.22.1/src/libgit2/src/commit_list.h --- r-cran-git2r-0.21.0/src/libgit2/src/commit_list.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/commit_list.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_commit_list_h__ #define INCLUDE_commit_list_h__ +#include "common.h" + #include "git2/oid.h" #define PARENT1 (1 << 0) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/common.h r-cran-git2r-0.22.1/src/libgit2/src/common.h --- r-cran-git2r-0.21.0/src/libgit2/src/common.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/common.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,10 @@ #ifndef INCLUDE_common_h__ #define INCLUDE_common_h__ +#ifndef LIBGIT2_NO_FEATURES_H +# include "git2/sys/features.h" +#endif + #include "git2/common.h" #include "cc-compat.h" @@ -47,10 +51,6 @@ # ifdef GIT_THREADS # include "win32/thread.h" # endif -# if defined(GIT_MSVC_CRTDBG) -# include "win32/w32_stack.h" -# include "win32/w32_crtdbg_stacktrace.h" -# endif #else @@ -230,6 +230,12 @@ GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { return -1; } +#define GITERR_CHECK_ALLOC_ADD5(out, one, two, three, four, five) \ + if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), four) || \ + GIT_ADD_SIZET_OVERFLOW(out, *(out), five)) { return -1; } + /** Check for multiplicative overflow, failing if it would occur. */ #define GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \ if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { return -1; } @@ -238,4 +244,4 @@ #include "util.h" -#endif /* INCLUDE_common_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config.c r-cran-git2r-0.22.1/src/libgit2/src/config.c --- r-cran-git2r-0.21.0/src/libgit2/src/config.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "sysdir.h" #include "config.h" + +#include "sysdir.h" #include "git2/config.h" #include "git2/sys/config.h" #include "vector.h" @@ -99,6 +99,7 @@ git_config *cfg, const char *path, git_config_level_t level, + const git_repository *repo, int force) { git_config_backend *file = NULL; @@ -116,7 +117,7 @@ if (git_config_file__ondisk(&file, path) < 0) return -1; - if ((res = git_config_add_backend(cfg, file, level, force)) < 0) { + if ((res = git_config_add_backend(cfg, file, level, repo, force)) < 0) { /* * free manually; the file is not owned by the config * instance yet and will not be freed on cleanup @@ -138,7 +139,7 @@ if (git_config_new(&config) < 0) return -1; - if ((error = git_config_add_file_ondisk(config, path, GIT_CONFIG_LEVEL_LOCAL, 0)) < 0) + if ((error = git_config_add_file_ondisk(config, path, GIT_CONFIG_LEVEL_LOCAL, NULL, 0)) < 0) git_config_free(config); else *out = config; @@ -164,7 +165,7 @@ if ((error = internal->file->snapshot(&b, internal->file)) < 0) break; - if ((error = git_config_add_backend(config, b, internal->level, 0)) < 0) { + if ((error = git_config_add_backend(config, b, internal->level, NULL, 0)) < 0) { b->free(b); break; } @@ -307,6 +308,7 @@ git_config *cfg, git_config_backend *file, git_config_level_t level, + const git_repository *repo, int force) { file_internal *internal; @@ -316,7 +318,7 @@ GITERR_CHECK_VERSION(file, GIT_CONFIG_BACKEND_VERSION, "git_config_backend"); - if ((result = file->open(file, level)) < 0) + if ((result = file->open(file, level, repo)) < 0) return result; internal = git__malloc(sizeof(file_internal)); @@ -1147,20 +1149,20 @@ if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) { error = git_config_add_file_ondisk(cfg, buf.ptr, - GIT_CONFIG_LEVEL_GLOBAL, 0); + GIT_CONFIG_LEVEL_GLOBAL, NULL, 0); } if (!error && !git_config_find_xdg(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, - GIT_CONFIG_LEVEL_XDG, 0); + GIT_CONFIG_LEVEL_XDG, NULL, 0); if (!error && !git_config_find_system(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, - GIT_CONFIG_LEVEL_SYSTEM, 0); + GIT_CONFIG_LEVEL_SYSTEM, NULL, 0); if (!error && !git_config_find_programdata(&buf)) error = git_config_add_file_ondisk(cfg, buf.ptr, - GIT_CONFIG_LEVEL_PROGRAMDATA, 0); + GIT_CONFIG_LEVEL_PROGRAMDATA, NULL, 0); git_buf_free(&buf); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config_cache.c r-cran-git2r-0.22.1/src/libgit2/src/config_cache.c --- r-cran-git2r-0.21.0/src/libgit2/src/config_cache.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config_cache.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "fileops.h" #include "repository.h" #include "config.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config_file.c r-cran-git2r-0.22.1/src/libgit2/src/config_file.c --- r-cran-git2r-0.21.0/src/libgit2/src/config_file.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config_file.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "config_file.h" + #include "config.h" #include "filebuf.h" #include "sysdir.h" @@ -16,6 +17,7 @@ #include "git2/types.h" #include "strmap.h" #include "array.h" +#include "config_parse.h" #include #include @@ -74,15 +76,6 @@ (iter) && (((tmp) = CVAR_LIST_NEXT(iter) || 1));\ (iter) = (tmp)) -struct reader { - git_oid checksum; - char *file_path; - git_buf buffer; - char *read_ptr; - int line_number; - int eof; -}; - typedef struct { git_atomic refcount; git_strmap *values; @@ -93,20 +86,20 @@ /* mutex to coordinate accessing the values */ git_mutex values_mutex; refcounted_strmap *values; + const git_repository *repo; + git_config_level_t level; } diskfile_header; typedef struct { diskfile_header header; - git_config_level_t level; - - git_array_t(struct reader) readers; + git_array_t(git_config_parser) readers; bool locked; git_filebuf locked_buf; git_buf locked_content; - char *file_path; + struct config_file file; } diskfile_backend; typedef struct { @@ -115,19 +108,13 @@ diskfile_backend *snapshot_from; } diskfile_readonly_backend; -static int config_read(git_strmap *values, diskfile_backend *cfg_file, struct reader *reader, git_config_level_t level, int depth); -static int config_write(diskfile_backend *cfg, const char *key, const regex_t *preg, const char *value); +static int config_read(git_strmap *values, const git_repository *repo, git_config_file *file, git_config_level_t level, int depth); +static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const regex_t *preg, const char *value); static char *escape_value(const char *ptr); int git_config_file__snapshot(git_config_backend **out, diskfile_backend *in); static int config_snapshot(git_config_backend **out, git_config_backend *in); -static void set_parse_error(struct reader *reader, int col, const char *error_str) -{ - giterr_set(GITERR_CONFIG, "failed to parse config file: %s (in %s:%d, column %d)", - error_str, reader->file_path, reader->line_number, col); -} - static int config_error_readonly(void) { giterr_set(GITERR_CONFIG, "this backend is read-only"); @@ -261,123 +248,131 @@ return error; } -static int config_open(git_config_backend *cfg, git_config_level_t level) +static void config_file_clear(struct config_file *file) +{ + struct config_file *include; + uint32_t i; + + if (file == NULL) + return; + + git_array_foreach(file->includes, i, include) { + config_file_clear(include); + } + git_array_clear(file->includes); + + git__free(file->path); +} + +static int config_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo) { int res; - struct reader *reader; diskfile_backend *b = (diskfile_backend *)cfg; - b->level = level; + b->header.level = level; + b->header.repo = repo; if ((res = refcounted_strmap_alloc(&b->header.values)) < 0) return res; - git_array_init(b->readers); - reader = git_array_alloc(b->readers); - if (!reader) { - refcounted_strmap_free(b->header.values); - return -1; - } - memset(reader, 0, sizeof(struct reader)); - - reader->file_path = git__strdup(b->file_path); - GITERR_CHECK_ALLOC(reader->file_path); - - git_buf_init(&reader->buffer, 0); - res = git_futils_readbuffer_updated( - &reader->buffer, b->file_path, &reader->checksum, NULL); - - /* It's fine if the file doesn't exist */ - if (res == GIT_ENOTFOUND) + if (!git_path_exists(b->file.path)) return 0; - if (res < 0 || (res = config_read(b->header.values->values, b, reader, level, 0)) < 0) { + if (res < 0 || (res = config_read(b->header.values->values, repo, &b->file, level, 0)) < 0) { refcounted_strmap_free(b->header.values); b->header.values = NULL; } - reader = git_array_get(b->readers, 0); - git_buf_free(&reader->buffer); - return res; } -/* The meat of the refresh, as we want to use it in different places */ -static int config__refresh(git_config_backend *cfg) +static int config_is_modified(int *modified, struct config_file *file) { - refcounted_strmap *values = NULL, *tmp; - diskfile_backend *b = (diskfile_backend *)cfg; - struct reader *reader = NULL; + git_config_file *include; + git_buf buf = GIT_BUF_INIT; + git_oid hash; + uint32_t i; int error = 0; - if ((error = refcounted_strmap_alloc(&values)) < 0) - goto out; + *modified = 0; - reader = git_array_get(b->readers, git_array_size(b->readers) - 1); - GITERR_CHECK_ALLOC(reader); + if ((error = git_futils_readbuffer(&buf, file->path)) < 0) + goto out; - if ((error = config_read(values->values, b, reader, b->level, 0)) < 0) + if ((error = git_hash_buf(&hash, buf.ptr, buf.size)) < 0) goto out; - if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) { - giterr_set(GITERR_OS, "failed to lock config backend"); + if (!git_oid_equal(&hash, &file->checksum)) { + *modified = 1; goto out; } - tmp = b->header.values; - b->header.values = values; - values = tmp; - - git_mutex_unlock(&b->header.values_mutex); + git_array_foreach(file->includes, i, include) { + if ((error = config_is_modified(modified, include)) < 0 || *modified) + goto out; + } out: - refcounted_strmap_free(values); - if (reader) - git_buf_free(&reader->buffer); + git_buf_free(&buf); + return error; } static int config_refresh(git_config_backend *cfg) { - int error = 0, updated = 0, any_updated = 0; diskfile_backend *b = (diskfile_backend *)cfg; - struct reader *reader = NULL; + refcounted_strmap *values = NULL, *tmp; + git_config_file *include; + int error, modified; uint32_t i; - for (i = 0; i < git_array_size(b->readers); i++) { - reader = git_array_get(b->readers, i); - error = git_futils_readbuffer_updated( - &reader->buffer, reader->file_path, - &reader->checksum, &updated); + if (b->header.parent.readonly) + return config_error_readonly(); + + error = config_is_modified(&modified, &b->file); + if (error < 0 && error != GIT_ENOTFOUND) + goto out; + + if (!modified) + return 0; - if (error < 0 && error != GIT_ENOTFOUND) - return error; + if ((error = refcounted_strmap_alloc(&values)) < 0) + goto out; + + /* Reparse the current configuration */ + git_array_foreach(b->file.includes, i, include) { + config_file_clear(include); + } + git_array_clear(b->file.includes); + + if ((error = config_read(values->values, b->header.repo, &b->file, b->header.level, 0)) < 0) + goto out; - if (updated) - any_updated = 1; + if ((error = git_mutex_lock(&b->header.values_mutex)) < 0) { + giterr_set(GITERR_OS, "failed to lock config backend"); + goto out; } - if (!any_updated) - return (error == GIT_ENOTFOUND) ? 0 : error; + tmp = b->header.values; + b->header.values = values; + values = tmp; + + git_mutex_unlock(&b->header.values_mutex); + +out: + refcounted_strmap_free(values); - return config__refresh(cfg); + return (error == GIT_ENOTFOUND) ? 0 : error; } static void backend_free(git_config_backend *_backend) { diskfile_backend *backend = (diskfile_backend *)_backend; - uint32_t i; if (backend == NULL) return; - for (i = 0; i < git_array_size(backend->readers); i++) { - struct reader *r = git_array_get(backend->readers, i); - git__free(r->file_path); - } - git_array_clear(backend->readers); - - git__free(backend->file_path); + config_file_clear(&backend->file); refcounted_strmap_free(backend->header.values); git_mutex_free(&backend->header.values_mutex); git__free(backend); @@ -424,13 +419,13 @@ diskfile_header *h; git_config_file_iter *it; git_config_backend *snapshot; - diskfile_backend *b = (diskfile_backend *) backend; + diskfile_header *bh = (diskfile_header *) backend; int error; if ((error = config_snapshot(&snapshot, backend)) < 0) return error; - if ((error = snapshot->open(snapshot, b->level)) < 0) + if ((error = snapshot->open(snapshot, bh->level, bh->repo)) < 0) return error; it = git__calloc(1, sizeof(git_config_file_iter)); @@ -482,6 +477,12 @@ goto out; } + if (existing->included) { + giterr_set(GITERR_CONFIG, "modifying included variable is not supported"); + ret = -1; + goto out; + } + /* don't update if old and new values already match */ if ((!existing->entry->value && !value) || (existing->entry->value && value && @@ -498,7 +499,7 @@ GITERR_CHECK_ALLOC(esc_value); } - if ((ret = config_write(b, key, NULL, esc_value)) < 0) + if ((ret = config_write(b, name, key, NULL, esc_value)) < 0) goto out; ret = config_refresh(cfg); @@ -576,7 +577,7 @@ } /* If we do have it, set call config_write() and reload */ - if ((result = config_write(b, key, &preg, value)) < 0) + if ((result = config_write(b, name, key, &preg, value)) < 0) goto out; result = config_refresh(cfg); @@ -616,12 +617,17 @@ var = git_strmap_value_at(values, pos); refcounted_strmap_free(map); + if (var->included) { + giterr_set(GITERR_CONFIG, "cannot delete included variable"); + return -1; + } + if (var->next != NULL) { giterr_set(GITERR_CONFIG, "cannot delete multivar with a single delete"); return -1; } - if ((result = config_write(b, var->entry->name, NULL, NULL)) < 0) + if ((result = config_write(b, name, var->entry->name, NULL, NULL)) < 0) return result; return config_refresh(cfg); @@ -662,7 +668,7 @@ goto out; } - if ((result = config_write(b, key, &preg, NULL)) < 0) + if ((result = config_write(b, name, key, &preg, NULL)) < 0) goto out; result = config_refresh(cfg); @@ -685,10 +691,10 @@ diskfile_backend *cfg = (diskfile_backend *) _cfg; int error; - if ((error = git_filebuf_open(&cfg->locked_buf, cfg->file_path, 0, GIT_CONFIG_FILE_MODE)) < 0) + if ((error = git_filebuf_open(&cfg->locked_buf, cfg->file.path, 0, GIT_CONFIG_FILE_MODE)) < 0) return error; - error = git_futils_readbuffer(&cfg->locked_content, cfg->file_path); + error = git_futils_readbuffer(&cfg->locked_content, cfg->file.path); if (error < 0 && error != GIT_ENOTFOUND) { git_filebuf_cleanup(&cfg->locked_buf); return error; @@ -726,8 +732,9 @@ backend->header.parent.version = GIT_CONFIG_BACKEND_VERSION; git_mutex_init(&backend->header.values_mutex); - backend->file_path = git__strdup(path); - GITERR_CHECK_ALLOC(backend->file_path); + backend->file.path = git__strdup(path); + GITERR_CHECK_ALLOC(backend->file.path); + git_array_init(backend->file.includes); backend->header.parent.open = config_open; backend->header.parent.get = config_get; @@ -810,7 +817,7 @@ git__free(backend); } -static int config_readonly_open(git_config_backend *cfg, git_config_level_t level) +static int config_readonly_open(git_config_backend *cfg, git_config_level_t level, const git_repository *repo) { diskfile_readonly_backend *b = (diskfile_readonly_backend *) cfg; diskfile_backend *src = b->snapshot_from; @@ -821,8 +828,9 @@ if (!src_header->parent.readonly && (error = config_refresh(&src_header->parent)) < 0) return error; - /* We're just copying data, don't care about the level */ + /* We're just copying data, don't care about the level or repo*/ GIT_UNUSED(level); + GIT_UNUSED(repo); if ((src_map = refcounted_strmap_take(src_header)) == NULL) return -1; @@ -861,397 +869,6 @@ return 0; } -static int reader_getchar_raw(struct reader *reader) -{ - int c; - - c = *reader->read_ptr++; - - /* - Win 32 line breaks: if we find a \r\n sequence, - return only the \n as a newline - */ - if (c == '\r' && *reader->read_ptr == '\n') { - reader->read_ptr++; - c = '\n'; - } - - if (c == '\n') - reader->line_number++; - - if (c == 0) { - reader->eof = 1; - c = '\0'; - } - - return c; -} - -#define SKIP_WHITESPACE (1 << 1) -#define SKIP_COMMENTS (1 << 2) - -static int reader_getchar(struct reader *reader, int flags) -{ - const int skip_whitespace = (flags & SKIP_WHITESPACE); - const int skip_comments = (flags & SKIP_COMMENTS); - int c; - - assert(reader->read_ptr); - - do { - c = reader_getchar_raw(reader); - } while (c != '\n' && c != '\0' && skip_whitespace && git__isspace(c)); - - if (skip_comments && (c == '#' || c == ';')) { - do { - c = reader_getchar_raw(reader); - } while (c != '\n' && c != '\0'); - } - - return c; -} - -/* - * Read the next char, but don't move the reading pointer. - */ -static int reader_peek(struct reader *reader, int flags) -{ - void *old_read_ptr; - int old_lineno, old_eof; - int ret; - - assert(reader->read_ptr); - - old_read_ptr = reader->read_ptr; - old_lineno = reader->line_number; - old_eof = reader->eof; - - ret = reader_getchar(reader, flags); - - reader->read_ptr = old_read_ptr; - reader->line_number = old_lineno; - reader->eof = old_eof; - - return ret; -} - -/* - * Read and consume a line, returning it in newly-allocated memory. - */ -static char *reader_readline(struct reader *reader, bool skip_whitespace) -{ - char *line = NULL; - char *line_src, *line_end; - size_t line_len, alloc_len; - - line_src = reader->read_ptr; - - if (skip_whitespace) { - /* Skip empty empty lines */ - while (git__isspace(*line_src)) - ++line_src; - } - - line_end = strchr(line_src, '\n'); - - /* no newline at EOF */ - if (line_end == NULL) - line_end = strchr(line_src, 0); - - line_len = line_end - line_src; - - if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, line_len, 1) || - (line = git__malloc(alloc_len)) == NULL) { - return NULL; - } - - memcpy(line, line_src, line_len); - - do line[line_len] = '\0'; - while (line_len-- > 0 && git__isspace(line[line_len])); - - if (*line_end == '\n') - line_end++; - - if (*line_end == '\0') - reader->eof = 1; - - reader->line_number++; - reader->read_ptr = line_end; - - return line; -} - -/* - * Consume a line, without storing it anywhere - */ -static void reader_consume_line(struct reader *reader) -{ - char *line_start, *line_end; - - line_start = reader->read_ptr; - line_end = strchr(line_start, '\n'); - /* No newline at EOF */ - if(line_end == NULL){ - line_end = strchr(line_start, '\0'); - } - - if (*line_end == '\n') - line_end++; - - if (*line_end == '\0') - reader->eof = 1; - - reader->line_number++; - reader->read_ptr = line_end; -} - -GIT_INLINE(int) config_keychar(int c) -{ - return isalnum(c) || c == '-'; -} - -static int parse_section_header_ext(struct reader *reader, const char *line, const char *base_name, char **section_name) -{ - int c, rpos; - char *first_quote, *last_quote; - git_buf buf = GIT_BUF_INIT; - size_t quoted_len, alloc_len, base_name_len = strlen(base_name); - - /* - * base_name is what came before the space. We should be at the - * first quotation mark, except for now, line isn't being kept in - * sync so we only really use it to calculate the length. - */ - - first_quote = strchr(line, '"'); - if (first_quote == NULL) { - set_parse_error(reader, 0, "Missing quotation marks in section header"); - goto end_error; - } - - last_quote = strrchr(line, '"'); - quoted_len = last_quote - first_quote; - - if (quoted_len == 0) { - set_parse_error(reader, 0, "Missing closing quotation mark in section header"); - goto end_error; - } - - GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len); - GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); - - if (git_buf_grow(&buf, alloc_len) < 0 || - git_buf_printf(&buf, "%s.", base_name) < 0) - goto end_error; - - rpos = 0; - - line = first_quote; - c = line[++rpos]; - - /* - * At the end of each iteration, whatever is stored in c will be - * added to the string. In case of error, jump to out - */ - do { - - switch (c) { - case 0: - set_parse_error(reader, 0, "Unexpected end-of-line in section header"); - goto end_error; - - case '"': - goto end_parse; - - case '\\': - c = line[++rpos]; - - if (c == 0) { - set_parse_error(reader, rpos, "Unexpected end-of-line in section header"); - goto end_error; - } - - default: - break; - } - - git_buf_putc(&buf, (char)c); - c = line[++rpos]; - } while (line + rpos < last_quote); - -end_parse: - if (git_buf_oom(&buf)) - goto end_error; - - if (line[rpos] != '"' || line[rpos + 1] != ']') { - set_parse_error(reader, rpos, "Unexpected text after closing quotes"); - git_buf_free(&buf); - return -1; - } - - *section_name = git_buf_detach(&buf); - return 0; - -end_error: - git_buf_free(&buf); - - return -1; -} - -static int parse_section_header(struct reader *reader, char **section_out) -{ - char *name, *name_end; - int name_length, c, pos; - int result; - char *line; - size_t line_len; - - line = reader_readline(reader, true); - if (line == NULL) - return -1; - - /* find the end of the variable's name */ - name_end = strrchr(line, ']'); - if (name_end == NULL) { - git__free(line); - set_parse_error(reader, 0, "Missing ']' in section header"); - return -1; - } - - GITERR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1); - name = git__malloc(line_len); - GITERR_CHECK_ALLOC(name); - - name_length = 0; - pos = 0; - - /* Make sure we were given a section header */ - c = line[pos++]; - assert(c == '['); - - c = line[pos++]; - - do { - if (git__isspace(c)){ - name[name_length] = '\0'; - result = parse_section_header_ext(reader, line, name, section_out); - git__free(line); - git__free(name); - return result; - } - - if (!config_keychar(c) && c != '.') { - set_parse_error(reader, pos, "Unexpected character in header"); - goto fail_parse; - } - - name[name_length++] = (char)git__tolower(c); - - } while ((c = line[pos++]) != ']'); - - if (line[pos - 1] != ']') { - set_parse_error(reader, pos, "Unexpected end of file"); - goto fail_parse; - } - - git__free(line); - - name[name_length] = 0; - *section_out = name; - - return 0; - -fail_parse: - git__free(line); - git__free(name); - return -1; -} - -static int skip_bom(struct reader *reader) -{ - git_bom_t bom; - int bom_offset = git_buf_text_detect_bom(&bom, - &reader->buffer, reader->read_ptr - reader->buffer.ptr); - - if (bom == GIT_BOM_UTF8) - reader->read_ptr += bom_offset; - - /* TODO: reference implementation is pretty stupid with BoM */ - - return 0; -} - -/* - (* basic types *) - digit = "0".."9" - integer = digit { digit } - alphabet = "a".."z" + "A" .. "Z" - - section_char = alphabet | "." | "-" - extension_char = (* any character except newline *) - any_char = (* any character *) - variable_char = "alphabet" | "-" - - - (* actual grammar *) - config = { section } - - section = header { definition } - - header = "[" section [subsection | subsection_ext] "]" - - subsection = "." section - subsection_ext = "\"" extension "\"" - - section = section_char { section_char } - extension = extension_char { extension_char } - - definition = variable_name ["=" variable_value] "\n" - - variable_name = variable_char { variable_char } - variable_value = string | boolean | integer - - string = quoted_string | plain_string - quoted_string = "\"" plain_string "\"" - plain_string = { any_char } - - boolean = boolean_true | boolean_false - boolean_true = "yes" | "1" | "true" | "on" - boolean_false = "no" | "0" | "false" | "off" -*/ - -static int strip_comments(char *line, int in_quotes) -{ - int quote_count = in_quotes, backslash_count = 0; - char *ptr; - - for (ptr = line; *ptr; ++ptr) { - if (ptr[0] == '"' && ptr > line && ptr[-1] != '\\') - quote_count++; - - if ((ptr[0] == ';' || ptr[0] == '#') && - (quote_count % 2) == 0 && - (backslash_count % 2) == 0) { - ptr[0] = '\0'; - break; - } - - if (ptr[0] == '\\') - backslash_count++; - else - backslash_count = 0; - } - - /* skip any space at the end */ - while (ptr > line && git__isspace(ptr[-1])) { - ptr--; - } - ptr[0] = '\0'; - - return quote_count; -} - static int included_path(git_buf *out, const char *dir, const char *path) { /* From the user's home */ @@ -1261,9 +878,6 @@ return git_path_join_unrooted(out, path, dir, NULL); } -static const char *escapes = "ntb\"\\"; -static const char *escaped = "\n\t\b\"\\"; - /* Escape the values to write them to the file */ static char *escape_value(const char *ptr) { @@ -1281,9 +895,9 @@ return NULL; while (*ptr != '\0') { - if ((esc = strchr(escaped, *ptr)) != NULL) { + if ((esc = strchr(git_config_escaped, *ptr)) != NULL) { git_buf_putc(&buf, '\\'); - git_buf_putc(&buf, escapes[esc - escaped]); + git_buf_putc(&buf, git_config_escapes[esc - git_config_escaped]); } else { git_buf_putc(&buf, *ptr); } @@ -1298,264 +912,151 @@ return git_buf_detach(&buf); } -/* '\"' -> '"' etc */ -static int unescape_line( - char **out, bool *is_multi, const char *ptr, int quote_count) -{ - char *str, *fixed, *esc; - size_t ptr_len = strlen(ptr), alloc_len; - - *is_multi = false; - - if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, ptr_len, 1) || - (str = git__malloc(alloc_len)) == NULL) { - return -1; - } - - fixed = str; - - while (*ptr != '\0') { - if (*ptr == '"') { - quote_count++; - } else if (*ptr != '\\') { - *fixed++ = *ptr; - } else { - /* backslash, check the next char */ - ptr++; - /* if we're at the end, it's a multiline, so keep the backslash */ - if (*ptr == '\0') { - *is_multi = true; - goto done; - } - if ((esc = strchr(escapes, *ptr)) != NULL) { - *fixed++ = escaped[esc - escapes]; - } else { - git__free(str); - giterr_set(GITERR_CONFIG, "invalid escape at %s", ptr); - return -1; - } - } - ptr++; - } - -done: - *fixed = '\0'; - *out = str; - - return 0; -} +struct parse_data { + const git_repository *repo; + const char *file_path; + git_strmap *values; + git_config_level_t level; + int depth; +}; -static int parse_multiline_variable(struct reader *reader, git_buf *value, int in_quotes) +static int parse_include(git_config_parser *reader, + struct parse_data *parse_data, const char *file) { - char *line = NULL, *proc_line = NULL; - int quote_count; - bool multiline; - - /* Check that the next line exists */ - line = reader_readline(reader, false); - if (line == NULL) - return -1; - - /* We've reached the end of the file, there is no continuation. - * (this is not an error). - */ - if (line[0] == '\0') { - git__free(line); - return 0; - } + struct config_file *include; + git_buf path = GIT_BUF_INIT; + char *dir; + int result; - quote_count = strip_comments(line, !!in_quotes); + if ((result = git_path_dirname_r(&path, reader->file->path)) < 0) + return result; - /* If it was just a comment, pretend it didn't exist */ - if (line[0] == '\0') { - git__free(line); - return parse_multiline_variable(reader, value, quote_count); - /* TODO: unbounded recursion. This **could** be exploitable */ - } + dir = git_buf_detach(&path); + result = included_path(&path, dir, file); + git__free(dir); - if (unescape_line(&proc_line, &multiline, line, in_quotes) < 0) { - git__free(line); - return -1; - } - /* add this line to the multiline var */ + if (result < 0) + return result; - git_buf_puts(value, proc_line); - git__free(line); - git__free(proc_line); + include = git_array_alloc(reader->file->includes); + memset(include, 0, sizeof(*include)); + git_array_init(include->includes); + include->path = git_buf_detach(&path); - /* - * If we need to continue reading the next line, let's just - * keep putting stuff in the buffer - */ - if (multiline) - return parse_multiline_variable(reader, value, quote_count); + result = config_read(parse_data->values, parse_data->repo, + include, parse_data->level, parse_data->depth+1); - return 0; -} + if (result == GIT_ENOTFOUND) { + giterr_clear(); + result = 0; + } -GIT_INLINE(bool) is_namechar(char c) -{ - return isalnum(c) || c == '-'; + return result; } -static int parse_name( - char **name, const char **value, struct reader *reader, const char *line) -{ - const char *name_end = line, *value_start; - - *name = NULL; - *value = NULL; - - while (*name_end && is_namechar(*name_end)) - name_end++; +static int do_match_gitdir( + int *matches, + const git_repository *repo, + const char *cfg_file, + const char *value, + bool case_insensitive) +{ + git_buf path = GIT_BUF_INIT; + int error, fnmatch_flags; + + if (value[0] == '.' && git_path_is_dirsep(value[1])) { + git_path_dirname_r(&path, cfg_file); + git_buf_joinpath(&path, path.ptr, value + 2); + } else if (value[0] == '~' && git_path_is_dirsep(value[1])) + git_sysdir_expand_global_file(&path, value + 1); + else if (!git_path_is_absolute(value)) + git_buf_joinpath(&path, "**", value); + else + git_buf_sets(&path, value); - if (line == name_end) { - set_parse_error(reader, 0, "Invalid configuration key"); - return -1; + if (git_buf_oom(&path)) { + error = -1; + goto out; } - value_start = name_end; + if (git_path_is_dirsep(value[strlen(value) - 1])) + git_buf_puts(&path, "**"); - while (*value_start && git__isspace(*value_start)) - value_start++; + fnmatch_flags = FNM_PATHNAME|FNM_LEADING_DIR; + if (case_insensitive) + fnmatch_flags |= FNM_IGNORECASE; - if (*value_start == '=') { - *value = value_start + 1; - } else if (*value_start) { - set_parse_error(reader, 0, "Invalid configuration key"); - return -1; - } + if ((error = p_fnmatch(path.ptr, git_repository_path(repo), fnmatch_flags)) < 0) + goto out; - if ((*name = git__strndup(line, name_end - line)) == NULL) - return -1; + *matches = (error == 0); - return 0; +out: + git_buf_free(&path); + return error; } -static int parse_variable(struct reader *reader, char **var_name, char **var_value) -{ - const char *value_start = NULL; - char *line; - int quote_count; - bool multiline; - - line = reader_readline(reader, true); - if (line == NULL) - return -1; - - quote_count = strip_comments(line, 0); - - /* If there is no value, boolean true is assumed */ - *var_value = NULL; - - if (parse_name(var_name, &value_start, reader, line) < 0) - goto on_error; - - /* - * Now, let's try to parse the value - */ - if (value_start != NULL) { - while (git__isspace(value_start[0])) - value_start++; - - if (unescape_line(var_value, &multiline, value_start, 0) < 0) - goto on_error; - - if (multiline) { - git_buf multi_value = GIT_BUF_INIT; - git_buf_attach(&multi_value, *var_value, 0); - - if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 || - git_buf_oom(&multi_value)) { - git_buf_free(&multi_value); - goto on_error; - } - - *var_value = git_buf_detach(&multi_value); - } - } - - git__free(line); - return 0; - -on_error: - git__free(*var_name); - git__free(line); - return -1; -} +static int conditional_match_gitdir( + int *matches, + const git_repository *repo, + const char *cfg_file, + const char *value) +{ + return do_match_gitdir(matches, repo, cfg_file, value, false); +} + +static int conditional_match_gitdir_i( + int *matches, + const git_repository *repo, + const char *cfg_file, + const char *value) +{ + return do_match_gitdir(matches, repo, cfg_file, value, true); +} + +static const struct { + const char *prefix; + int (*matches)(int *matches, const git_repository *repo, const char *cfg, const char *value); +} conditions[] = { + { "gitdir:", conditional_match_gitdir }, + { "gitdir/i:", conditional_match_gitdir_i } +}; -static int config_parse( - struct reader *reader, - int (*on_section)(struct reader **reader, const char *current_section, const char *line, size_t line_len, void *data), - int (*on_variable)(struct reader **reader, const char *current_section, char *var_name, char *var_value, const char *line, size_t line_len, void *data), - int (*on_comment)(struct reader **reader, const char *line, size_t line_len, void *data), - int (*on_eof)(struct reader **reader, const char *current_section, void *data), - void *data) +static int parse_conditional_include(git_config_parser *reader, + struct parse_data *parse_data, const char *section, const char *file) { - char *current_section = NULL, *var_name, *var_value, *line_start; - char c; - size_t line_len; - int result = 0; - - skip_bom(reader); + char *condition; + size_t i; + int error = 0, matches; - while (result == 0 && !reader->eof) { - line_start = reader->read_ptr; + if (!parse_data->repo) + return 0; - c = reader_peek(reader, SKIP_WHITESPACE); + condition = git__substrdup(section + strlen("includeIf."), + strlen(section) - strlen("includeIf.") - strlen(".path")); - switch (c) { - case '\0': /* EOF when peeking, set EOF in the reader to exit the loop */ - reader->eof = 1; + for (i = 0; i < ARRAY_SIZE(conditions); i++) { + if (git__prefixcmp(condition, conditions[i].prefix)) + continue; + + if ((error = conditions[i].matches(&matches, + parse_data->repo, + parse_data->file_path, + condition + strlen(conditions[i].prefix))) < 0) break; - case '[': /* section header, new section begins */ - git__free(current_section); - current_section = NULL; - - if ((result = parse_section_header(reader, ¤t_section)) == 0 && on_section) { - line_len = reader->read_ptr - line_start; - result = on_section(&reader, current_section, line_start, line_len, data); - } - break; + if (matches) + error = parse_include(reader, parse_data, file); - case '\n': /* comment or whitespace-only */ - case ';': - case '#': - reader_consume_line(reader); - - if (on_comment) { - line_len = reader->read_ptr - line_start; - result = on_comment(&reader, line_start, line_len, data); - } - break; - - default: /* assume variable declaration */ - if ((result = parse_variable(reader, &var_name, &var_value)) == 0 && on_variable) { - line_len = reader->read_ptr - line_start; - result = on_variable(&reader, current_section, var_name, var_value, line_start, line_len, data); - } - break; - } + break; } - if (on_eof) - result = on_eof(&reader, current_section, data); - - git__free(current_section); - return result; + git__free(condition); + return error; } -struct parse_data { - git_strmap *values; - diskfile_backend *cfg_file; - uint32_t reader_idx; - git_config_level_t level; - int depth; -}; - static int read_on_variable( - struct reader **reader, + git_config_parser *reader, const char *current_section, char *var_name, char *var_value, @@ -1596,74 +1097,61 @@ result = 0; /* Add or append the new config option */ - if (!git__strcmp(var->entry->name, "include.path")) { - struct reader *r; - git_buf path = GIT_BUF_INIT; - char *dir; - uint32_t index; - - r = git_array_alloc(parse_data->cfg_file->readers); - /* The reader may have been reallocated */ - *reader = git_array_get(parse_data->cfg_file->readers, parse_data->reader_idx); - memset(r, 0, sizeof(struct reader)); - - if ((result = git_path_dirname_r(&path, (*reader)->file_path)) < 0) - return result; + if (!git__strcmp(var->entry->name, "include.path")) + result = parse_include(reader, parse_data, var->entry->value); + else if (!git__prefixcmp(var->entry->name, "includeif.") && + !git__suffixcmp(var->entry->name, ".path")) + result = parse_conditional_include(reader, parse_data, + var->entry->name, var->entry->value); - /* We need to know our index in the array, as the next config_parse call may realloc */ - index = git_array_size(parse_data->cfg_file->readers) - 1; - dir = git_buf_detach(&path); - result = included_path(&path, dir, var->entry->value); - git__free(dir); - - if (result < 0) - return result; - - r->file_path = git_buf_detach(&path); - git_buf_init(&r->buffer, 0); - - result = git_futils_readbuffer_updated( - &r->buffer, r->file_path, &r->checksum, NULL); - - if (result == 0) { - result = config_read(parse_data->values, parse_data->cfg_file, r, parse_data->level, parse_data->depth+1); - r = git_array_get(parse_data->cfg_file->readers, index); - *reader = git_array_get(parse_data->cfg_file->readers, parse_data->reader_idx); - } else if (result == GIT_ENOTFOUND) { - giterr_clear(); - result = 0; - } - - git_buf_free(&r->buffer); - } return result; } -static int config_read(git_strmap *values, diskfile_backend *cfg_file, struct reader *reader, git_config_level_t level, int depth) +static int config_read( + git_strmap *values, + const git_repository *repo, + git_config_file *file, + git_config_level_t level, + int depth) { struct parse_data parse_data; + git_config_parser reader; + git_buf contents = GIT_BUF_INIT; + int error; if (depth >= MAX_INCLUDE_DEPTH) { giterr_set(GITERR_CONFIG, "maximum config include depth reached"); return -1; } + if ((error = git_futils_readbuffer(&contents, file->path)) < 0) + goto out; + + git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size); + + if ((error = git_hash_buf(&file->checksum, contents.ptr, contents.size)) < 0) + goto out; + /* Initialize the reading position */ - reader->read_ptr = reader->buffer.ptr; - reader->eof = 0; + reader.file = file; + git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size); /* If the file is empty, there's nothing for us to do */ - if (*reader->read_ptr == '\0') - return 0; + if (!reader.ctx.content || *reader.ctx.content == '\0') + goto out; + parse_data.repo = repo; + parse_data.file_path = file->path; parse_data.values = values; - parse_data.cfg_file = cfg_file; - parse_data.reader_idx = git_array_size(cfg_file->readers) - 1; parse_data.level = level; parse_data.depth = depth; - return config_parse(reader, NULL, read_on_variable, NULL, NULL, &parse_data); + error = git_config_parse(&reader, NULL, read_on_variable, NULL, NULL, &parse_data); + +out: + git_buf_free(&contents); + return error; } static int write_section(git_buf *fbuf, const char *key) @@ -1719,7 +1207,9 @@ git_buf buffered_comment; unsigned int in_section : 1, preg_replaced : 1; + const char *orig_section; const char *section; + const char *orig_name; const char *name; const regex_t *preg; const char *value; @@ -1747,7 +1237,7 @@ q = quotes_for_value(write_data->value); result = git_buf_printf(write_data->buf, - "\t%s = %s%s%s\n", write_data->name, q, write_data->value, q); + "\t%s = %s%s%s\n", write_data->orig_name, q, write_data->value, q); /* If we are updating a single name/value, we're done. Setting `value` * to `NULL` will prevent us from trying to write it again later (in @@ -1760,7 +1250,7 @@ } static int write_on_section( - struct reader **reader, + git_config_parser *reader, const char *current_section, const char *line, size_t line_len, @@ -1796,7 +1286,7 @@ } static int write_on_variable( - struct reader **reader, + git_config_parser *reader, const char *current_section, char *var_name, char *var_value, @@ -1846,7 +1336,7 @@ return write_value(write_data); } -static int write_on_comment(struct reader **reader, const char *line, size_t line_len, void *data) +static int write_on_comment(git_config_parser *reader, const char *line, size_t line_len, void *data) { struct write_data *write_data; @@ -1857,7 +1347,7 @@ } static int write_on_eof( - struct reader **reader, const char *current_section, void *data) + git_config_parser *reader, const char *current_section, void *data) { struct write_data *write_data = (struct write_data *)data; int result = 0; @@ -1878,7 +1368,7 @@ if ((!write_data->preg || !write_data->preg_replaced) && write_data->value) { /* write the section header unless we're already in it */ if (!current_section || strcmp(current_section, write_data->section)) - result = write_section(write_data->buf, write_data->section); + result = write_section(write_data->buf, write_data->orig_section); if (!result) result = write_value(write_data); @@ -1890,37 +1380,35 @@ /* * This is pretty much the parsing, except we write out anything we don't have */ -static int config_write(diskfile_backend *cfg, const char *key, const regex_t *preg, const char* value) +static int config_write(diskfile_backend *cfg, const char *orig_key, const char *key, const regex_t *preg, const char* value) { int result; - char *section, *name, *ldot; + char *orig_section, *section, *orig_name, *name, *ldot; git_filebuf file = GIT_FILEBUF_INIT; - git_buf buf = GIT_BUF_INIT; - struct reader *reader = git_array_get(cfg->readers, 0); + git_buf buf = GIT_BUF_INIT, contents = GIT_BUF_INIT; + git_config_parser reader; struct write_data write_data; + memset(&reader, 0, sizeof(reader)); + reader.file = &cfg->file; + if (cfg->locked) { - result = git_buf_puts(&reader->buffer, git_buf_cstr(&cfg->locked_content)); + result = git_buf_puts(&contents, git_buf_cstr(&cfg->locked_content)); } else { /* Lock the file */ if ((result = git_filebuf_open( - &file, cfg->file_path, GIT_FILEBUF_HASH_CONTENTS, GIT_CONFIG_FILE_MODE)) < 0) { - git_buf_free(&reader->buffer); + &file, cfg->file.path, GIT_FILEBUF_HASH_CONTENTS, GIT_CONFIG_FILE_MODE)) < 0) { + git_buf_free(&contents); return result; } /* We need to read in our own config file */ - result = git_futils_readbuffer(&reader->buffer, cfg->file_path); + result = git_futils_readbuffer(&contents, cfg->file.path); } /* Initialise the reading position */ - if (result == GIT_ENOTFOUND) { - reader->read_ptr = NULL; - reader->eof = 1; - git_buf_clear(&reader->buffer); - } else if (result == 0) { - reader->read_ptr = reader->buffer.ptr; - reader->eof = 0; + if (result == 0 || result == GIT_ENOTFOUND) { + git_parse_ctx_init(&reader.ctx, contents.ptr, contents.size); } else { git_filebuf_cleanup(&file); return -1; /* OS error when reading the file */ @@ -1929,18 +1417,32 @@ ldot = strrchr(key, '.'); name = ldot + 1; section = git__strndup(key, ldot - key); + GITERR_CHECK_ALLOC(section); + + ldot = strrchr(orig_key, '.'); + orig_name = ldot + 1; + orig_section = git__strndup(orig_key, ldot - orig_key); + GITERR_CHECK_ALLOC(orig_section); write_data.buf = &buf; git_buf_init(&write_data.buffered_comment, 0); + write_data.orig_section = orig_section; write_data.section = section; write_data.in_section = 0; write_data.preg_replaced = 0; + write_data.orig_name = orig_name; write_data.name = name; write_data.preg = preg; write_data.value = value; - result = config_parse(reader, write_on_section, write_on_variable, write_on_comment, write_on_eof, &write_data); + result = git_config_parse(&reader, + write_on_section, + write_on_variable, + write_on_comment, + write_on_eof, + &write_data); git__free(section); + git__free(orig_section); git_buf_free(&write_data.buffered_comment); if (result < 0) { @@ -1960,6 +1462,7 @@ done: git_buf_free(&buf); - git_buf_free(&reader->buffer); + git_buf_free(&contents); + git_parse_ctx_clear(&reader.ctx); return result; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config_file.h r-cran-git2r-0.22.1/src/libgit2/src/config_file.h --- r-cran-git2r-0.21.0/src/libgit2/src/config_file.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config_file.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,12 +7,14 @@ #ifndef INCLUDE_config_file_h__ #define INCLUDE_config_file_h__ +#include "common.h" + #include "git2/sys/config.h" #include "git2/config.h" -GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level) +GIT_INLINE(int) git_config_file_open(git_config_backend *cfg, unsigned int level, const git_repository *repo) { - return cfg->open(cfg, level); + return cfg->open(cfg, level, repo); } GIT_INLINE(void) git_config_file_free(git_config_backend *cfg) @@ -69,4 +71,3 @@ extern int git_config_file_normalize_section(char *start, char *end); #endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config.h r-cran-git2r-0.22.1/src/libgit2/src/config.h --- r-cran-git2r-0.21.0/src/libgit2/src/config.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_config_h__ #define INCLUDE_config_h__ +#include "common.h" + #include "git2.h" #include "git2/config.h" #include "vector.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config_parse.c r-cran-git2r-0.22.1/src/libgit2/src/config_parse.c --- r-cran-git2r-0.21.0/src/libgit2/src/config_parse.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config_parse.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,525 @@ +/* + * 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. + */ + +#include "config_parse.h" + +#include "buf_text.h" + +#include + +static void set_parse_error(git_config_parser *reader, int col, const char *error_str) +{ + giterr_set(GITERR_CONFIG, "failed to parse config file: %s (in %s:%"PRIuZ", column %d)", + error_str, reader->file->path, reader->ctx.line_num, col); +} + + +GIT_INLINE(int) config_keychar(int c) +{ + return isalnum(c) || c == '-'; +} + +static int strip_comments(char *line, int in_quotes) +{ + int quote_count = in_quotes, backslash_count = 0; + char *ptr; + + for (ptr = line; *ptr; ++ptr) { + if (ptr[0] == '"' && ptr > line && ptr[-1] != '\\') + quote_count++; + + if ((ptr[0] == ';' || ptr[0] == '#') && + (quote_count % 2) == 0 && + (backslash_count % 2) == 0) { + ptr[0] = '\0'; + break; + } + + if (ptr[0] == '\\') + backslash_count++; + else + backslash_count = 0; + } + + /* skip any space at the end */ + while (ptr > line && git__isspace(ptr[-1])) { + ptr--; + } + ptr[0] = '\0'; + + return quote_count; +} + + +static int parse_section_header_ext(git_config_parser *reader, const char *line, const char *base_name, char **section_name) +{ + int c, rpos; + char *first_quote, *last_quote; + git_buf buf = GIT_BUF_INIT; + size_t quoted_len, alloc_len, base_name_len = strlen(base_name); + + /* + * base_name is what came before the space. We should be at the + * first quotation mark, except for now, line isn't being kept in + * sync so we only really use it to calculate the length. + */ + + first_quote = strchr(line, '"'); + if (first_quote == NULL) { + set_parse_error(reader, 0, "Missing quotation marks in section header"); + goto end_error; + } + + last_quote = strrchr(line, '"'); + quoted_len = last_quote - first_quote; + + if (quoted_len == 0) { + set_parse_error(reader, 0, "Missing closing quotation mark in section header"); + goto end_error; + } + + GITERR_CHECK_ALLOC_ADD(&alloc_len, base_name_len, quoted_len); + GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 2); + + if (git_buf_grow(&buf, alloc_len) < 0 || + git_buf_printf(&buf, "%s.", base_name) < 0) + goto end_error; + + rpos = 0; + + line = first_quote; + c = line[++rpos]; + + /* + * At the end of each iteration, whatever is stored in c will be + * added to the string. In case of error, jump to out + */ + do { + + switch (c) { + case 0: + set_parse_error(reader, 0, "Unexpected end-of-line in section header"); + goto end_error; + + case '"': + goto end_parse; + + case '\\': + c = line[++rpos]; + + if (c == 0) { + set_parse_error(reader, rpos, "Unexpected end-of-line in section header"); + goto end_error; + } + + default: + break; + } + + git_buf_putc(&buf, (char)c); + c = line[++rpos]; + } while (line + rpos < last_quote); + +end_parse: + if (git_buf_oom(&buf)) + goto end_error; + + if (line[rpos] != '"' || line[rpos + 1] != ']') { + set_parse_error(reader, rpos, "Unexpected text after closing quotes"); + git_buf_free(&buf); + return -1; + } + + *section_name = git_buf_detach(&buf); + return 0; + +end_error: + git_buf_free(&buf); + + return -1; +} + +static int parse_section_header(git_config_parser *reader, char **section_out) +{ + char *name, *name_end; + int name_length, c, pos; + int result; + char *line; + size_t line_len; + + git_parse_advance_ws(&reader->ctx); + line = git__strndup(reader->ctx.line, reader->ctx.line_len); + if (line == NULL) + return -1; + + /* find the end of the variable's name */ + name_end = strrchr(line, ']'); + if (name_end == NULL) { + git__free(line); + set_parse_error(reader, 0, "Missing ']' in section header"); + return -1; + } + + GITERR_CHECK_ALLOC_ADD(&line_len, (size_t)(name_end - line), 1); + name = git__malloc(line_len); + GITERR_CHECK_ALLOC(name); + + name_length = 0; + pos = 0; + + /* Make sure we were given a section header */ + c = line[pos++]; + assert(c == '['); + + c = line[pos++]; + + do { + if (git__isspace(c)){ + name[name_length] = '\0'; + result = parse_section_header_ext(reader, line, name, section_out); + git__free(line); + git__free(name); + return result; + } + + if (!config_keychar(c) && c != '.') { + set_parse_error(reader, pos, "Unexpected character in header"); + goto fail_parse; + } + + name[name_length++] = (char)git__tolower(c); + + } while ((c = line[pos++]) != ']'); + + if (line[pos - 1] != ']') { + set_parse_error(reader, pos, "Unexpected end of file"); + goto fail_parse; + } + + git__free(line); + + name[name_length] = 0; + *section_out = name; + + return 0; + +fail_parse: + git__free(line); + git__free(name); + return -1; +} + +static int skip_bom(git_parse_ctx *parser) +{ + git_buf buf = GIT_BUF_INIT_CONST(parser->content, parser->content_len); + git_bom_t bom; + int bom_offset = git_buf_text_detect_bom(&bom, &buf); + + if (bom == GIT_BOM_UTF8) + git_parse_advance_chars(parser, bom_offset); + + /* TODO: reference implementation is pretty stupid with BoM */ + + return 0; +} + +/* + (* basic types *) + digit = "0".."9" + integer = digit { digit } + alphabet = "a".."z" + "A" .. "Z" + + section_char = alphabet | "." | "-" + extension_char = (* any character except newline *) + any_char = (* any character *) + variable_char = "alphabet" | "-" + + + (* actual grammar *) + config = { section } + + section = header { definition } + + header = "[" section [subsection | subsection_ext] "]" + + subsection = "." section + subsection_ext = "\"" extension "\"" + + section = section_char { section_char } + extension = extension_char { extension_char } + + definition = variable_name ["=" variable_value] "\n" + + variable_name = variable_char { variable_char } + variable_value = string | boolean | integer + + string = quoted_string | plain_string + quoted_string = "\"" plain_string "\"" + plain_string = { any_char } + + boolean = boolean_true | boolean_false + boolean_true = "yes" | "1" | "true" | "on" + boolean_false = "no" | "0" | "false" | "off" +*/ + +/* '\"' -> '"' etc */ +static int unescape_line( + char **out, bool *is_multi, const char *ptr, int quote_count) +{ + char *str, *fixed, *esc; + size_t ptr_len = strlen(ptr), alloc_len; + + *is_multi = false; + + if (GIT_ADD_SIZET_OVERFLOW(&alloc_len, ptr_len, 1) || + (str = git__malloc(alloc_len)) == NULL) { + return -1; + } + + fixed = str; + + while (*ptr != '\0') { + if (*ptr == '"') { + quote_count++; + } else if (*ptr != '\\') { + *fixed++ = *ptr; + } else { + /* backslash, check the next char */ + ptr++; + /* if we're at the end, it's a multiline, so keep the backslash */ + if (*ptr == '\0') { + *is_multi = true; + goto done; + } + if ((esc = strchr(git_config_escapes, *ptr)) != NULL) { + *fixed++ = git_config_escaped[esc - git_config_escapes]; + } else { + git__free(str); + giterr_set(GITERR_CONFIG, "invalid escape at %s", ptr); + return -1; + } + } + ptr++; + } + +done: + *fixed = '\0'; + *out = str; + + return 0; +} + +static int parse_multiline_variable(git_config_parser *reader, git_buf *value, int in_quotes) +{ + char *line = NULL, *proc_line = NULL; + int quote_count; + bool multiline; + + /* Check that the next line exists */ + git_parse_advance_line(&reader->ctx); + line = git__strndup(reader->ctx.line, reader->ctx.line_len); + if (line == NULL) + return -1; + + /* We've reached the end of the file, there is no continuation. + * (this is not an error). + */ + if (line[0] == '\0') { + git__free(line); + return 0; + } + + quote_count = strip_comments(line, !!in_quotes); + + /* If it was just a comment, pretend it didn't exist */ + if (line[0] == '\0') { + git__free(line); + return parse_multiline_variable(reader, value, quote_count); + /* TODO: unbounded recursion. This **could** be exploitable */ + } + + if (unescape_line(&proc_line, &multiline, line, in_quotes) < 0) { + git__free(line); + return -1; + } + /* add this line to the multiline var */ + + git_buf_puts(value, proc_line); + git__free(line); + git__free(proc_line); + + /* + * If we need to continue reading the next line, let's just + * keep putting stuff in the buffer + */ + if (multiline) + return parse_multiline_variable(reader, value, quote_count); + + return 0; +} + +GIT_INLINE(bool) is_namechar(char c) +{ + return isalnum(c) || c == '-'; +} + +static int parse_name( + char **name, const char **value, git_config_parser *reader, const char *line) +{ + const char *name_end = line, *value_start; + + *name = NULL; + *value = NULL; + + while (*name_end && is_namechar(*name_end)) + name_end++; + + if (line == name_end) { + set_parse_error(reader, 0, "Invalid configuration key"); + return -1; + } + + value_start = name_end; + + while (*value_start && git__isspace(*value_start)) + value_start++; + + if (*value_start == '=') { + *value = value_start + 1; + } else if (*value_start) { + set_parse_error(reader, 0, "Invalid configuration key"); + return -1; + } + + if ((*name = git__strndup(line, name_end - line)) == NULL) + return -1; + + return 0; +} + +static int parse_variable(git_config_parser *reader, char **var_name, char **var_value) +{ + const char *value_start = NULL; + char *line; + int quote_count; + bool multiline; + + git_parse_advance_ws(&reader->ctx); + line = git__strndup(reader->ctx.line, reader->ctx.line_len); + if (line == NULL) + return -1; + + quote_count = strip_comments(line, 0); + + /* If there is no value, boolean true is assumed */ + *var_value = NULL; + + if (parse_name(var_name, &value_start, reader, line) < 0) + goto on_error; + + /* + * Now, let's try to parse the value + */ + if (value_start != NULL) { + while (git__isspace(value_start[0])) + value_start++; + + if (unescape_line(var_value, &multiline, value_start, 0) < 0) + goto on_error; + + if (multiline) { + git_buf multi_value = GIT_BUF_INIT; + git_buf_attach(&multi_value, *var_value, 0); + + if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 || + git_buf_oom(&multi_value)) { + git_buf_free(&multi_value); + goto on_error; + } + + *var_value = git_buf_detach(&multi_value); + } + } + + git__free(line); + return 0; + +on_error: + git__free(*var_name); + git__free(line); + return -1; +} + +int git_config_parse( + git_config_parser *parser, + git_config_parser_section_cb on_section, + git_config_parser_variable_cb on_variable, + git_config_parser_comment_cb on_comment, + git_config_parser_eof_cb on_eof, + void *data) +{ + git_parse_ctx *ctx; + char *current_section = NULL, *var_name, *var_value; + int result = 0; + + ctx = &parser->ctx; + + skip_bom(ctx); + + for (; ctx->remain_len > 0; git_parse_advance_line(ctx)) { + const char *line_start = parser->ctx.line; + size_t line_len = parser->ctx.line_len; + char c; + + /* + * Get either first non-whitespace character or, if that does + * not exist, the first whitespace character. This is required + * to preserve whitespaces when writing back the file. + */ + if (git_parse_peek(&c, ctx, GIT_PARSE_PEEK_SKIP_WHITESPACE) < 0 && + git_parse_peek(&c, ctx, 0) < 0) + continue; + + switch (c) { + case '[': /* section header, new section begins */ + git__free(current_section); + current_section = NULL; + + if ((result = parse_section_header(parser, ¤t_section)) == 0 && on_section) { + result = on_section(parser, current_section, line_start, line_len, data); + } + break; + + case '\n': /* comment or whitespace-only */ + case '\r': + case ' ': + case '\t': + case ';': + case '#': + if (on_comment) { + result = on_comment(parser, line_start, line_len, data); + } + break; + + default: /* assume variable declaration */ + if ((result = parse_variable(parser, &var_name, &var_value)) == 0 && on_variable) { + result = on_variable(parser, current_section, var_name, var_value, line_start, line_len, data); + } + break; + } + + if (result < 0) + goto out; + } + + if (on_eof) + result = on_eof(parser, current_section, data); + +out: + git__free(current_section); + return result; +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/config_parse.h r-cran-git2r-0.22.1/src/libgit2/src/config_parse.h --- r-cran-git2r-0.21.0/src/libgit2/src/config_parse.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/config_parse.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,64 @@ +/* + * 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_config_parse_h__ +#define INCLUDE_config_parse_h__ + +#include "common.h" +#include "array.h" +#include "oid.h" +#include "parse.h" + +static const char *git_config_escapes = "ntb\"\\"; +static const char *git_config_escaped = "\n\t\b\"\\"; + +typedef struct config_file { + git_oid checksum; + char *path; + git_array_t(struct config_file) includes; +} git_config_file; + +typedef struct { + struct config_file *file; + git_parse_ctx ctx; +} git_config_parser; + +typedef int (*git_config_parser_section_cb)( + git_config_parser *parser, + const char *current_section, + const char *line, + size_t line_len, + void *data); + +typedef int (*git_config_parser_variable_cb)( + git_config_parser *parser, + const char *current_section, + char *var_name, + char *var_value, + const char *line, + size_t line_len, + void *data); + +typedef int (*git_config_parser_comment_cb)( + git_config_parser *parser, + const char *line, + size_t line_len, + void *data); + +typedef int (*git_config_parser_eof_cb)( + git_config_parser *parser, + const char *current_section, + void *data); + +int git_config_parse( + git_config_parser *parser, + git_config_parser_section_cb on_section, + git_config_parser_variable_cb on_variable, + git_config_parser_comment_cb on_comment, + git_config_parser_eof_cb on_eof, + void *data); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/crlf.c r-cran-git2r-0.22.1/src/libgit2/src/crlf.c --- r-cran-git2r-0.21.0/src/libgit2/src/crlf.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/crlf.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,12 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #include "git2/attr.h" #include "git2/blob.h" #include "git2/index.h" #include "git2/sys/filter.h" -#include "common.h" #include "fileops.h" #include "hash.h" #include "filter.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/curl_stream.c r-cran-git2r-0.22.1/src/libgit2/src/curl_stream.c --- r-cran-git2r-0.21.0/src/libgit2/src/curl_stream.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/curl_stream.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,362 +0,0 @@ -/* - * 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. - */ - -#ifdef GIT_CURL - -#include - -#include "stream.h" -#include "git2/transport.h" -#include "buffer.h" -#include "vector.h" -#include "proxy.h" - -/* This is for backwards compatibility with curl<7.45.0. */ -#ifndef CURLINFO_ACTIVESOCKET -# define CURLINFO_ACTIVESOCKET CURLINFO_LASTSOCKET -# define GIT_CURL_BADSOCKET -1 -# define git_activesocket_t long -#else -# define GIT_CURL_BADSOCKET CURL_SOCKET_BAD -# define git_activesocket_t curl_socket_t -#endif - -typedef struct { - git_stream parent; - CURL *handle; - curl_socket_t socket; - char curl_error[CURL_ERROR_SIZE + 1]; - git_cert_x509 cert_info; - git_strarray cert_info_strings; - git_proxy_options proxy; - git_cred *proxy_cred; -} curl_stream; - -static int seterr_curl(curl_stream *s) -{ - giterr_set(GITERR_NET, "curl error: %s\n", s->curl_error); - return -1; -} - -GIT_INLINE(int) error_no_credentials(void) -{ - giterr_set(GITERR_NET, "proxy authentication required, but no callback provided"); - return GIT_EAUTH; -} - -static int apply_proxy_creds(curl_stream *s) -{ - CURLcode res; - git_cred_userpass_plaintext *userpass; - - if (!s->proxy_cred) - return GIT_ENOTFOUND; - - userpass = (git_cred_userpass_plaintext *) s->proxy_cred; - if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXYUSERNAME, userpass->username)) != CURLE_OK) - return seterr_curl(s); - if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXYPASSWORD, userpass->password)) != CURLE_OK) - return seterr_curl(s); - - return 0; -} - -static int ask_and_apply_proxy_creds(curl_stream *s) -{ - int error; - git_proxy_options *opts = &s->proxy; - - if (!opts->credentials) - return error_no_credentials(); - - /* TODO: see if PROXYAUTH_AVAIL helps us here */ - git_cred_free(s->proxy_cred); - s->proxy_cred = NULL; - giterr_clear(); - error = opts->credentials(&s->proxy_cred, opts->url, NULL, GIT_CREDTYPE_USERPASS_PLAINTEXT, opts->payload); - if (error == GIT_PASSTHROUGH) - return error_no_credentials(); - if (error < 0) { - if (!giterr_last()) - giterr_set(GITERR_NET, "proxy authentication was aborted by the user"); - return error; - } - - if (s->proxy_cred->credtype != GIT_CREDTYPE_USERPASS_PLAINTEXT) { - giterr_set(GITERR_NET, "credentials callback returned invalid credential type"); - return -1; - } - - return apply_proxy_creds(s); -} - -static int curls_connect(git_stream *stream) -{ - curl_stream *s = (curl_stream *) stream; - git_activesocket_t sockextr; - long connect_last = 0; - int failed_cert = 0, error; - bool retry_connect; - CURLcode res; - - /* Apply any credentials we've already established */ - error = apply_proxy_creds(s); - if (error < 0 && error != GIT_ENOTFOUND) - return seterr_curl(s); - - do { - retry_connect = 0; - res = curl_easy_perform(s->handle); - - curl_easy_getinfo(s->handle, CURLINFO_HTTP_CONNECTCODE, &connect_last); - - /* HTTP 407 Proxy Authentication Required */ - if (connect_last == 407) { - if ((error = ask_and_apply_proxy_creds(s)) < 0) - return error; - - retry_connect = true; - } - } while (retry_connect); - - if (res != CURLE_OK && res != CURLE_PEER_FAILED_VERIFICATION) - return seterr_curl(s); - if (res == CURLE_PEER_FAILED_VERIFICATION) - failed_cert = 1; - - if ((res = curl_easy_getinfo(s->handle, CURLINFO_ACTIVESOCKET, &sockextr)) != CURLE_OK) { - return seterr_curl(s); - } - - if (sockextr == GIT_CURL_BADSOCKET) { - giterr_set(GITERR_NET, "curl socket is no longer valid"); - return -1; - } - - s->socket = sockextr; - - if (s->parent.encrypted && failed_cert) - return GIT_ECERTIFICATE; - - return 0; -} - -static int curls_certificate(git_cert **out, git_stream *stream) -{ - int error; - CURLcode res; - struct curl_slist *slist; - struct curl_certinfo *certinfo; - git_vector strings = GIT_VECTOR_INIT; - curl_stream *s = (curl_stream *) stream; - - if ((res = curl_easy_getinfo(s->handle, CURLINFO_CERTINFO, &certinfo)) != CURLE_OK) - return seterr_curl(s); - - /* No information is available, can happen with SecureTransport */ - if (certinfo->num_of_certs == 0) { - s->cert_info.parent.cert_type = GIT_CERT_NONE; - s->cert_info.data = NULL; - s->cert_info.len = 0; - return 0; - } - - if ((error = git_vector_init(&strings, 8, NULL)) < 0) - return error; - - for (slist = certinfo->certinfo[0]; slist; slist = slist->next) { - char *str = git__strdup(slist->data); - GITERR_CHECK_ALLOC(str); - git_vector_insert(&strings, str); - } - - /* Copy the contents of the vector into a strarray so we can expose them */ - s->cert_info_strings.strings = (char **) strings.contents; - s->cert_info_strings.count = strings.length; - - s->cert_info.parent.cert_type = GIT_CERT_STRARRAY; - s->cert_info.data = &s->cert_info_strings; - s->cert_info.len = strings.length; - - *out = &s->cert_info.parent; - - return 0; -} - -static int curls_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts) -{ - int error; - CURLcode res; - curl_stream *s = (curl_stream *) stream; - - if ((error = git_proxy_options_dup(&s->proxy, proxy_opts)) < 0) - return error; - - if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXY, s->proxy.url)) != CURLE_OK) - return seterr_curl(s); - - if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY)) != CURLE_OK) - return seterr_curl(s); - - return 0; -} - -static int wait_for(curl_socket_t fd, bool reading) -{ - int ret; - fd_set infd, outfd, errfd; - - FD_ZERO(&infd); - FD_ZERO(&outfd); - FD_ZERO(&errfd); - - assert(fd >= 0); - FD_SET(fd, &errfd); - if (reading) - FD_SET(fd, &infd); - else - FD_SET(fd, &outfd); - - if ((ret = select(fd + 1, &infd, &outfd, &errfd, NULL)) < 0) { - giterr_set(GITERR_OS, "error in select"); - return -1; - } - - return 0; -} - -static ssize_t curls_write(git_stream *stream, const char *data, size_t len, int flags) -{ - int error; - size_t off = 0, sent; - CURLcode res; - curl_stream *s = (curl_stream *) stream; - - GIT_UNUSED(flags); - - do { - if ((error = wait_for(s->socket, false)) < 0) - return error; - - res = curl_easy_send(s->handle, data + off, len - off, &sent); - if (res == CURLE_OK) - off += sent; - } while ((res == CURLE_OK || res == CURLE_AGAIN) && off < len); - - if (res != CURLE_OK) - return seterr_curl(s); - - return len; -} - -static ssize_t curls_read(git_stream *stream, void *data, size_t len) -{ - int error; - size_t read; - CURLcode res; - curl_stream *s = (curl_stream *) stream; - - do { - if ((error = wait_for(s->socket, true)) < 0) - return error; - - res = curl_easy_recv(s->handle, data, len, &read); - } while (res == CURLE_AGAIN); - - if (res != CURLE_OK) - return seterr_curl(s); - - return read; -} - -static int curls_close(git_stream *stream) -{ - curl_stream *s = (curl_stream *) stream; - - if (!s->handle) - return 0; - - curl_easy_cleanup(s->handle); - s->handle = NULL; - s->socket = 0; - - return 0; -} - -static void curls_free(git_stream *stream) -{ - curl_stream *s = (curl_stream *) stream; - - curls_close(stream); - git_strarray_free(&s->cert_info_strings); - git__free(s); -} - -int git_curl_stream_new(git_stream **out, const char *host, const char *port) -{ - curl_stream *st; - CURL *handle; - int iport = 0, error; - - st = git__calloc(1, sizeof(curl_stream)); - GITERR_CHECK_ALLOC(st); - - handle = curl_easy_init(); - if (handle == NULL) { - giterr_set(GITERR_NET, "failed to create curl handle"); - git__free(st); - return -1; - } - - if ((error = git__strtol32(&iport, port, NULL, 10)) < 0) { - git__free(st); - return error; - } - - curl_easy_setopt(handle, CURLOPT_URL, host); - curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, st->curl_error); - curl_easy_setopt(handle, CURLOPT_PORT, iport); - curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 1); - curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1); - curl_easy_setopt(handle, CURLOPT_CERTINFO, 1); - curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1); - curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); - - /* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */ - - st->parent.version = GIT_STREAM_VERSION; - st->parent.encrypted = 0; /* we don't encrypt ourselves */ - st->parent.proxy_support = 1; - st->parent.connect = curls_connect; - st->parent.certificate = curls_certificate; - st->parent.set_proxy = curls_set_proxy; - st->parent.read = curls_read; - st->parent.write = curls_write; - st->parent.close = curls_close; - st->parent.free = curls_free; - st->handle = handle; - - *out = (git_stream *) st; - return 0; -} - -#else - -#include "stream.h" - -int git_curl_stream_new(git_stream **out, const char *host, const char *port) -{ - GIT_UNUSED(out); - GIT_UNUSED(host); - GIT_UNUSED(port); - - giterr_set(GITERR_NET, "curl is not supported in this version"); - return -1; -} - - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/curl_stream.h r-cran-git2r-0.22.1/src/libgit2/src/curl_stream.h --- r-cran-git2r-0.21.0/src/libgit2/src/curl_stream.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/curl_stream.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* - * 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_curl_stream_h__ -#define INCLUDE_curl_stream_h__ - -#include "git2/sys/stream.h" - -extern int git_curl_stream_new(git_stream **out, const char *host, const char *port); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/delta.h r-cran-git2r-0.22.1/src/libgit2/src/delta.h --- r-cran-git2r-0.21.0/src/libgit2/src/delta.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/delta.h 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ #define INCLUDE_git_delta_h__ #include "common.h" + #include "pack.h" typedef struct git_delta_index git_delta_index; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/describe.c r-cran-git2r-0.22.1/src/libgit2/src/describe.c --- r-cran-git2r-0.21.0/src/libgit2/src/describe.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/describe.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,12 +4,14 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "common.h" + #include "git2/describe.h" #include "git2/strarray.h" #include "git2/diff.h" #include "git2/status.h" -#include "common.h" #include "commit.h" #include "commit_list.h" #include "oidmap.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff.c r-cran-git2r-0.22.1/src/libgit2/src/diff.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,20 +4,20 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "git2/version.h" -#include "common.h" + #include "diff.h" + +#include "git2/version.h" #include "diff_generate.h" #include "patch.h" #include "commit.h" #include "index.h" -#define DIFF_FLAG_IS_SET(DIFF,FLAG) \ - (((DIFF)->opts.flags & (FLAG)) != 0) -#define DIFF_FLAG_ISNT_SET(DIFF,FLAG) \ - (((DIFF)->opts.flags & (FLAG)) == 0) -#define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->opts.flags = \ - (VAL) ? ((DIFF)->opts.flags | (FLAG)) : ((DIFF)->opts.flags & ~(VAL)) +struct patch_id_args { + git_hash_ctx ctx; + git_oid result; + int first_file; +}; GIT_INLINE(const char *) diff_delta__path(const git_diff_delta *delta) { @@ -374,3 +374,142 @@ return 0; } +static int flush_hunk(git_oid *result, git_hash_ctx *ctx) +{ + git_oid hash; + unsigned short carry = 0; + int error, i; + + if ((error = git_hash_final(&hash, ctx)) < 0 || + (error = git_hash_init(ctx)) < 0) + return error; + + for (i = 0; i < GIT_OID_RAWSZ; i++) { + carry += result->id[i] + hash.id[i]; + result->id[i] = carry; + carry >>= 8; + } + + return 0; +} + +static void strip_spaces(git_buf *buf) +{ + char *src = buf->ptr, *dst = buf->ptr; + char c; + size_t len = 0; + + while ((c = *src++) != '\0') { + if (!git__isspace(c)) { + *dst++ = c; + len++; + } + } + + git_buf_truncate(buf, len); +} + +static int file_cb( + const git_diff_delta *delta, + float progress, + void *payload) +{ + struct patch_id_args *args = (struct patch_id_args *) payload; + git_buf buf = GIT_BUF_INIT; + int error; + + GIT_UNUSED(progress); + + if (!args->first_file && + (error = flush_hunk(&args->result, &args->ctx)) < 0) + goto out; + args->first_file = 0; + + if ((error = git_buf_printf(&buf, + "diff--gita/%sb/%s---a/%s+++b/%s", + delta->old_file.path, + delta->new_file.path, + delta->old_file.path, + delta->new_file.path)) < 0) + goto out; + + strip_spaces(&buf); + + if ((error = git_hash_update(&args->ctx, buf.ptr, buf.size)) < 0) + goto out; + +out: + git_buf_free(&buf); + return error; +} + +static int line_cb( + const git_diff_delta *delta, + const git_diff_hunk *hunk, + const git_diff_line *line, + void *payload) +{ + struct patch_id_args *args = (struct patch_id_args *) payload; + git_buf buf = GIT_BUF_INIT; + int error; + + GIT_UNUSED(delta); + GIT_UNUSED(hunk); + + switch (line->origin) { + case GIT_DIFF_LINE_ADDITION: + git_buf_putc(&buf, '+'); + break; + case GIT_DIFF_LINE_DELETION: + git_buf_putc(&buf, '-'); + break; + case GIT_DIFF_LINE_CONTEXT: + break; + default: + giterr_set(GITERR_PATCH, "invalid line origin for patch"); + return -1; + } + + git_buf_put(&buf, line->content, line->content_len); + strip_spaces(&buf); + + if ((error = git_hash_update(&args->ctx, buf.ptr, buf.size)) < 0) + goto out; + +out: + git_buf_free(&buf); + return error; +} + +int git_diff_patchid_init_options(git_diff_patchid_options *opts, unsigned int version) +{ + GIT_INIT_STRUCTURE_FROM_TEMPLATE( + opts, version, git_diff_patchid_options, GIT_DIFF_PATCHID_OPTIONS_INIT); + return 0; +} + +int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opts) +{ + struct patch_id_args args; + int error; + + GITERR_CHECK_VERSION( + opts, GIT_DIFF_PATCHID_OPTIONS_VERSION, "git_diff_patchid_options"); + + memset(&args, 0, sizeof(args)); + args.first_file = 1; + if ((error = git_hash_ctx_init(&args.ctx)) < 0) + goto out; + + if ((error = git_diff_foreach(diff, file_cb, NULL, NULL, line_cb, &args)) < 0) + goto out; + + if ((error = (flush_hunk(&args.result, &args.ctx))) < 0) + goto out; + + git_oid_cpy(out, &args.result); + +out: + git_hash_ctx_cleanup(&args.ctx); + return error; +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_driver.c r-cran-git2r-0.22.1/src/libgit2/src/diff_driver.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_driver.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_driver.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,12 +4,12 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + +#include "diff_driver.h" #include "git2/attr.h" #include "diff.h" -#include "diff_driver.h" #include "strmap.h" #include "map.h" #include "buf_text.h" @@ -354,27 +354,30 @@ } int git_diff_driver_lookup( - git_diff_driver **out, git_repository *repo, const char *path) + git_diff_driver **out, git_repository *repo, + git_attr_session *attrsession, const char *path) { int error = 0; - const char *value; + const char *values[1], *attrs[] = { "diff" }; assert(out); *out = NULL; if (!repo || !path || !strlen(path)) /* just use the auto value */; - else if ((error = git_attr_get(&value, repo, 0, path, "diff")) < 0) + else if ((error = git_attr_get_many_with_session(values, repo, + attrsession, 0, path, 1, attrs)) < 0) /* return error below */; - else if (GIT_ATTR_UNSPECIFIED(value)) + + else if (GIT_ATTR_UNSPECIFIED(values[0])) /* just use the auto value */; - else if (GIT_ATTR_FALSE(value)) + else if (GIT_ATTR_FALSE(values[0])) *out = &global_drivers[DIFF_DRIVER_BINARY]; - else if (GIT_ATTR_TRUE(value)) + else if (GIT_ATTR_TRUE(values[0])) *out = &global_drivers[DIFF_DRIVER_TEXT]; /* otherwise look for driver information in config and build driver */ - else if ((error = git_diff_driver_load(out, repo, value)) < 0) { + else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) { if (error == GIT_ENOTFOUND) { error = 0; giterr_clear(); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_driver.h r-cran-git2r-0.22.1/src/libgit2/src/diff_driver.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff_driver.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_driver.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,8 @@ #define INCLUDE_diff_driver_h__ #include "common.h" + +#include "attr_file.h" #include "buffer.h" typedef struct git_diff_driver_registry git_diff_driver_registry; @@ -17,7 +19,8 @@ typedef struct git_diff_driver git_diff_driver; -int git_diff_driver_lookup(git_diff_driver **, git_repository *, const char *); +int git_diff_driver_lookup(git_diff_driver **, git_repository *, + git_attr_session *attrsession, const char *); void git_diff_driver_free(git_diff_driver *); /* diff option flags to force off and on for this driver */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_file.c r-cran-git2r-0.22.1/src/libgit2/src/diff_file.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_file.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_file.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,12 +4,13 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + +#include "diff_file.h" + #include "git2/blob.h" #include "git2/submodule.h" #include "diff.h" #include "diff_generate.h" -#include "diff_file.h" #include "odb.h" #include "fileops.h" #include "filter.h" @@ -53,7 +54,8 @@ fc->src = GIT_ITERATOR_TYPE_TREE; if (!fc->driver && - git_diff_driver_lookup(&fc->driver, fc->repo, fc->file->path) < 0) + git_diff_driver_lookup(&fc->driver, fc->repo, + NULL, fc->file->path) < 0) return -1; /* give driver a chance to modify options */ @@ -100,7 +102,8 @@ fc->file = use_old ? &delta->old_file : &delta->new_file; fc->src = use_old ? diff->old_src : diff->new_src; - if (git_diff_driver_lookup(&fc->driver, fc->repo, fc->file->path) < 0) + if (git_diff_driver_lookup(&fc->driver, fc->repo, + &diff->attrsession, fc->file->path) < 0) return -1; switch (delta->status) { @@ -138,7 +141,6 @@ memset(fc, 0, sizeof(*fc)); fc->repo = repo; fc->file = as_file; - fc->blob = src->blob; if (!src->blob && !src->buf) { fc->flags |= GIT_DIFF_FLAG__NO_DATA; @@ -148,12 +150,15 @@ fc->file->mode = GIT_FILEMODE_BLOB; if (src->blob) { + git_blob_dup((git_blob **)&fc->blob, (git_blob *) src->blob); fc->file->size = git_blob_rawsize(src->blob); git_oid_cpy(&fc->file->id, git_blob_id(src->blob)); fc->file->id_abbrev = GIT_OID_HEXSZ; fc->map.len = (size_t)fc->file->size; fc->map.data = (char *)git_blob_rawcontent(src->blob); + + fc->flags |= GIT_DIFF_FLAG__FREE_BLOB; } else { fc->file->size = src->buflen; git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_file.h r-cran-git2r-0.22.1/src/libgit2/src/diff_file.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff_file.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_file.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_diff_file_h__ #include "common.h" + #include "diff.h" #include "diff_driver.h" #include "map.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_generate.c r-cran-git2r-0.22.1/src/libgit2/src/diff_generate.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_generate.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_generate.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,9 +4,10 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "diff.h" + #include "diff_generate.h" + +#include "diff.h" #include "patch_generate.h" #include "fileops.h" #include "config.h" @@ -23,7 +24,7 @@ (((DIFF)->base.opts.flags & (FLAG)) == 0) #define DIFF_FLAG_SET(DIFF,FLAG,VAL) (DIFF)->base.opts.flags = \ (VAL) ? ((DIFF)->base.opts.flags | (FLAG)) : \ - ((DIFF)->base.opts.flags & ~(VAL)) + ((DIFF)->base.opts.flags & ~(FLAG)) typedef struct { struct git_diff base; @@ -388,6 +389,7 @@ { git_diff_generated *diff = (git_diff_generated *)d; + git_attr_session__free(&diff->base.attrsession); git_vector_free_deep(&diff->base.deltas); git_pathspec__vfree(&diff->pathspec); @@ -410,13 +412,14 @@ if ((diff = git__calloc(1, sizeof(git_diff_generated))) == NULL) return NULL; - GIT_REFCOUNT_INC(diff); + GIT_REFCOUNT_INC(&diff->base); diff->base.type = GIT_DIFF_TYPE_GENERATED; diff->base.repo = repo; diff->base.old_src = old_iter->type; diff->base.new_src = new_iter->type; diff->base.patch_fn = git_patch_generated_from_diff; diff->base.free_fn = diff_generated_free; + git_attr_session__init(&diff->base.attrsession, repo); memcpy(&diff->base.opts, &dflt, sizeof(git_diff_options)); git_pool_init(&diff->base.pool, 1); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_generate.h r-cran-git2r-0.22.1/src/libgit2/src/diff_generate.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff_generate.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_generate.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,12 @@ #ifndef INCLUDE_diff_generate_h__ #define INCLUDE_diff_generate_h__ +#include "common.h" + +#include "diff.h" +#include "pool.h" +#include "index.h" + enum { GIT_DIFFCAPS_HAS_SYMLINKS = (1 << 0), /* symlinks on platform? */ GIT_DIFFCAPS_IGNORE_STAT = (1 << 1), /* use stat? */ @@ -120,4 +126,3 @@ } #endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff.h r-cran-git2r-0.22.1/src/libgit2/src/diff.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_diff_h__ #define INCLUDE_diff_h__ +#include "common.h" + #include "git2/diff.h" #include "git2/patch.h" #include "git2/sys/diff.h" @@ -32,6 +34,7 @@ struct git_diff { git_refcount rc; git_repository *repo; + git_attr_session attrsession; git_diff_origin_t type; git_diff_options opts; git_vector deltas; /* vector of git_diff_delta */ @@ -63,4 +66,3 @@ extern int git_diff__entry_icmp(const void *a, const void *b); #endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_parse.c r-cran-git2r-0.22.1/src/libgit2/src/diff_parse.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_parse.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_parse.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,9 +4,10 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "diff.h" + #include "diff_parse.h" + +#include "diff.h" #include "patch.h" #include "patch_parse.h" @@ -35,7 +36,7 @@ if ((diff = git__calloc(1, sizeof(git_diff_parsed))) == NULL) return NULL; - GIT_REFCOUNT_INC(diff); + GIT_REFCOUNT_INC(&diff->base); diff->base.type = GIT_DIFF_TYPE_PARSED; diff->base.strcomp = git__strcmp; diff->base.strncomp = git__strncmp; @@ -82,7 +83,7 @@ ctx = git_patch_parse_ctx_init(content, content_len, NULL); GITERR_CHECK_ALLOC(ctx); - while (ctx->remain_len) { + while (ctx->parse_ctx.remain_len) { if ((error = git_patch_parse(&patch, ctx)) < 0) break; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_parse.h r-cran-git2r-0.22.1/src/libgit2/src/diff_parse.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff_parse.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_parse.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_diff_parse_h__ #define INCLUDE_diff_parse_h__ +#include "common.h" + #include "diff.h" typedef struct { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_print.c r-cran-git2r-0.22.1/src/libgit2/src/diff_print.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_print.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_print.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "common.h" + #include "diff.h" #include "diff_file.h" #include "patch_generate.h" @@ -128,6 +130,7 @@ case GIT_DELTA_COPIED: code = 'C'; break; case GIT_DELTA_IGNORED: code = 'I'; break; case GIT_DELTA_UNTRACKED: code = '?'; break; + case GIT_DELTA_TYPECHANGE: code = 'T'; break; case GIT_DELTA_UNREADABLE: code = 'X'; break; default: code = ' '; break; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_stats.c r-cran-git2r-0.22.1/src/libgit2/src/diff_stats.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_stats.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_stats.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "common.h" + #include "vector.h" #include "diff.h" #include "patch_generate.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_tform.c r-cran-git2r-0.22.1/src/libgit2/src/diff_tform.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_tform.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_tform.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,8 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + +#include "diff_tform.h" #include "git2/config.h" #include "git2/blob.h" @@ -685,8 +686,10 @@ break; } if (FLAG_SET(opts, GIT_DIFF_FIND_RENAMES_FROM_REWRITES) && - delta->similarity < opts->rename_from_rewrite_threshold) + delta->similarity < opts->rename_from_rewrite_threshold) { + delta->flags |= GIT_DIFF_FLAG__TO_SPLIT; break; + } return false; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_tform.h r-cran-git2r-0.22.1/src/libgit2/src/diff_tform.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff_tform.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_tform.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,10 @@ #ifndef INCLUDE_diff_tform_h__ #define INCLUDE_diff_tform_h__ +#include "common.h" + +#include "diff_file.h" + extern int git_diff_find_similar__hashsig_for_file( void **out, const git_diff_file *f, const char *path, void *p); @@ -19,4 +23,3 @@ int *score, void *siga, void *sigb, void *payload); #endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_xdiff.c r-cran-git2r-0.22.1/src/libgit2/src/diff_xdiff.c --- r-cran-git2r-0.21.0/src/libgit2/src/diff_xdiff.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_xdiff.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,11 +4,12 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "diff_xdiff.h" + #include "git2/errors.h" -#include "common.h" #include "diff.h" #include "diff_driver.h" -#include "diff_xdiff.h" #include "patch_generate.h" static int git_xdiff_scan_int(const char **str, int *value) @@ -238,6 +239,8 @@ xo->params.flags |= XDF_IGNORE_WHITESPACE_CHANGE; if (flags & GIT_DIFF_IGNORE_WHITESPACE_EOL) xo->params.flags |= XDF_IGNORE_WHITESPACE_AT_EOL; + if (flags & GIT_DIFF_INDENT_HEURISTIC) + xo->params.flags |= XDF_INDENT_HEURISTIC; if (flags & GIT_DIFF_PATIENCE) xo->params.flags |= XDF_PATIENCE_DIFF; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/diff_xdiff.h r-cran-git2r-0.22.1/src/libgit2/src/diff_xdiff.h --- r-cran-git2r-0.21.0/src/libgit2/src/diff_xdiff.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/diff_xdiff.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_diff_xdiff_h__ #define INCLUDE_diff_xdiff_h__ +#include "common.h" + #include "diff.h" #include "xdiff/xdiff.h" #include "patch_generate.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/errors.c r-cran-git2r-0.22.1/src/libgit2/src/errors.c --- r-cran-git2r-0.21.0/src/libgit2/src/errors.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/errors.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "common.h" + #include "global.h" #include "posix.h" #include "buffer.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fetch.c r-cran-git2r-0.22.1/src/libgit2/src/fetch.c --- r-cran-git2r-0.21.0/src/libgit2/src/fetch.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fetch.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,16 +5,16 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "fetch.h" + #include "git2/oid.h" #include "git2/refs.h" #include "git2/revwalk.h" #include "git2/transport.h" -#include "common.h" #include "remote.h" #include "refspec.h" #include "pack.h" -#include "fetch.h" #include "netops.h" #include "repository.h" #include "refs.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fetch.h r-cran-git2r-0.22.1/src/libgit2/src/fetch.h --- r-cran-git2r-0.21.0/src/libgit2/src/fetch.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fetch.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,10 @@ #ifndef INCLUDE_fetch_h__ #define INCLUDE_fetch_h__ +#include "common.h" + +#include "git2/remote.h" + #include "netops.h" int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fetchhead.c r-cran-git2r-0.22.1/src/libgit2/src/fetchhead.c --- r-cran-git2r-0.21.0/src/libgit2/src/fetchhead.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fetchhead.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,11 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "fetchhead.h" + #include "git2/types.h" #include "git2/oid.h" -#include "fetchhead.h" -#include "common.h" #include "buffer.h" #include "fileops.h" #include "filebuf.h" @@ -118,7 +118,7 @@ if (git_buf_joinpath(&path, repo->gitdir, GIT_FETCH_HEAD_FILE) < 0) return -1; - if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_FORCE, GIT_REFS_FILE_MODE) < 0) { + if (git_filebuf_open(&file, path.ptr, GIT_FILEBUF_APPEND, GIT_REFS_FILE_MODE) < 0) { git_buf_free(&path); return -1; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fetchhead.h r-cran-git2r-0.22.1/src/libgit2/src/fetchhead.h --- r-cran-git2r-0.21.0/src/libgit2/src/fetchhead.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fetchhead.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,9 @@ #ifndef INCLUDE_fetchhead_h__ #define INCLUDE_fetchhead_h__ +#include "common.h" + +#include "oid.h" #include "vector.h" typedef struct git_fetchhead_ref { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/filebuf.c r-cran-git2r-0.22.1/src/libgit2/src/filebuf.c --- r-cran-git2r-0.21.0/src/libgit2/src/filebuf.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/filebuf.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + #include "filebuf.h" + #include "fileops.h" static const size_t WRITE_BUFFER_SIZE = (4096 * 2); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/filebuf.h r-cran-git2r-0.22.1/src/libgit2/src/filebuf.h --- r-cran-git2r-0.21.0/src/libgit2/src/filebuf.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/filebuf.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_filebuf_h__ #define INCLUDE_filebuf_h__ +#include "common.h" + #include "fileops.h" #include "hash.h" #include diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fileops.c r-cran-git2r-0.22.1/src/libgit2/src/fileops.c --- r-cran-git2r-0.21.0/src/libgit2/src/fileops.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fileops.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + #include "fileops.h" + #include "global.h" #include "strmap.h" #include @@ -101,6 +102,16 @@ return fd; } +int git_futils_truncate(const char *path, int mode) +{ + int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode); + if (fd < 0) + return git_path_set_error(errno, path, "open"); + + close(fd); + return 0; +} + git_off_t git_futils_filesize(git_file fd) { struct stat sb; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fileops.h r-cran-git2r-0.22.1/src/libgit2/src/fileops.h --- r-cran-git2r-0.21.0/src/libgit2/src/fileops.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fileops.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_fileops_h__ #include "common.h" + #include "map.h" #include "posix.h" #include "path.h" @@ -247,6 +248,11 @@ extern int git_futils_open_ro(const char *path); /** + * Truncate a file, creating it if it doesn't exist. + */ +extern int git_futils_truncate(const char *path, int mode); + +/** * Get the filesize in bytes of a file */ extern git_off_t git_futils_filesize(git_file fd); @@ -381,4 +387,4 @@ */ extern int git_futils_fsync_parent(const char *path); -#endif /* INCLUDE_fileops_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/filter.c r-cran-git2r-0.22.1/src/libgit2/src/filter.c --- r-cran-git2r-0.21.0/src/libgit2/src/filter.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/filter.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,10 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "filter.h" + #include "common.h" #include "fileops.h" #include "hash.h" -#include "filter.h" #include "repository.h" #include "global.h" #include "git2/sys/filter.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/filter.h r-cran-git2r-0.22.1/src/libgit2/src/filter.h --- r-cran-git2r-0.21.0/src/libgit2/src/filter.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/filter.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_filter_h__ #include "common.h" + #include "attr_file.h" #include "git2/filter.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fnmatch.c r-cran-git2r-0.22.1/src/libgit2/src/fnmatch.c --- r-cran-git2r-0.21.0/src/libgit2/src/fnmatch.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fnmatch.c 2018-07-10 13:23:34.000000000 +0000 @@ -44,12 +44,12 @@ * Compares a filename or pathname to a pattern. */ +#include "fnmatch.h" + #include #include #include -#include "fnmatch.h" - #define EOS '\0' #define RANGE_MATCH 1 diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/fnmatch.h r-cran-git2r-0.22.1/src/libgit2/src/fnmatch.h --- r-cran-git2r-0.21.0/src/libgit2/src/fnmatch.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/fnmatch.h 2018-07-10 13:23:34.000000000 +0000 @@ -25,8 +25,8 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#ifndef INCLUDE_fnmatch__compat_h__ -#define INCLUDE_fnmatch__compat_h__ +#ifndef INCLUDE_fnmatch_h__ +#define INCLUDE_fnmatch_h__ #include "common.h" @@ -45,5 +45,4 @@ extern int p_fnmatch(const char *pattern, const char *string, int flags); -#endif /* _FNMATCH_H */ - +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/global.c r-cran-git2r-0.22.1/src/libgit2/src/global.c --- r-cran-git2r-0.21.0/src/libgit2/src/global.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/global.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,13 +4,15 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + #include "global.h" + #include "hash.h" #include "sysdir.h" #include "filter.h" #include "merge_driver.h" -#include "openssl_stream.h" +#include "streams/curl.h" +#include "streams/openssl.h" #include "thread-utils.h" #include "git2/global.h" #include "transports/ssh.h" @@ -22,7 +24,7 @@ git_mutex git__mwindow_mutex; -#define MAX_SHUTDOWN_CB 9 +#define MAX_SHUTDOWN_CB 10 static git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB]; static git_atomic git__n_shutdown_callbacks; @@ -62,7 +64,8 @@ (ret = git_filter_global_init()) == 0 && (ret = git_merge_driver_global_init()) == 0 && (ret = git_transport_ssh_global_init()) == 0 && - (ret = git_openssl_stream_global_init()) == 0) + (ret = git_openssl_stream_global_init()) == 0 && + (ret = git_curl_stream_global_init()) == 0) ret = git_mwindow_global_init(); GIT_MEMORY_BARRIER; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/global.h r-cran-git2r-0.22.1/src/libgit2/src/global.h --- r-cran-git2r-0.21.0/src/libgit2/src/global.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/global.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_global_h__ #include "common.h" + #include "mwindow.h" #include "hash.h" @@ -24,11 +25,6 @@ git_thread *current_thread; } git_global_st; -#ifdef GIT_OPENSSL -# include -extern SSL_CTX *git__ssl_ctx; -#endif - git_global_st *git__global_state(void); extern git_mutex git__mwindow_mutex; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/graph.c r-cran-git2r-0.22.1/src/libgit2/src/graph.c --- r-cran-git2r-0.21.0/src/libgit2/src/graph.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/graph.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #include "revwalk.h" #include "merge.h" #include "git2/graph.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_collisiondetect.h r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_collisiondetect.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_collisiondetect.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_collisiondetect.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* - * 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_hash_collisiondetect_h__ -#define INCLUDE_hash_collisiondetect_h__ - -#include "hash.h" -#include "sha1dc/sha1.h" - -struct git_hash_ctx { - SHA1_CTX c; -}; - -#define git_hash_global_init() 0 -#define git_hash_ctx_init(ctx) git_hash_init(ctx) -#define git_hash_ctx_cleanup(ctx) - -GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) -{ - assert(ctx); - SHA1DCInit(&ctx->c); - return 0; -} - -GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) -{ - assert(ctx); - SHA1DCUpdate(&ctx->c, data, len); - return 0; -} - -GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) -{ - assert(ctx); - if (SHA1DCFinal(out->id, &ctx->c)) { - giterr_set(GITERR_SHA1, "SHA1 collision attack detected"); - return -1; - } - - return 0; -} - -#endif /* INCLUDE_hash_collisiondetect_h__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_common_crypto.h r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_common_crypto.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_common_crypto.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_common_crypto.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* - * 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_hash_common_crypto_h__ -#define INCLUDE_hash_common_crypto_h__ - -#include "hash.h" - -#include - -struct git_hash_ctx { - CC_SHA1_CTX c; -}; - -#define git_hash_global_init() 0 -#define git_hash_ctx_init(ctx) git_hash_init(ctx) -#define git_hash_ctx_cleanup(ctx) - -GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) -{ - assert(ctx); - CC_SHA1_Init(&ctx->c); - return 0; -} - -GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) -{ - assert(ctx); - CC_SHA1_Update(&ctx->c, data, len); - return 0; -} - -GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) -{ - assert(ctx); - CC_SHA1_Final(out->id, &ctx->c); - return 0; -} - -#endif /* INCLUDE_hash_common_crypto_h__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_generic.c r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_generic.c --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_generic.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_generic.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,288 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "hash.h" -#include "hash/hash_generic.h" - -#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - -/* - * Force usage of rol or ror by selecting the one with the smaller constant. - * It _can_ generate slightly smaller code (a constant of 1 is special), but - * perhaps more importantly it's possibly faster on any uarch that does a - * rotate with a loop. - */ - -#define SHA_ASM(op, x, n) (__extension__ ({ unsigned int __res; __asm__(op " %1,%0":"=r" (__res):"i" (n), "0" (x)); __res; })) -#define SHA_ROL(x,n) SHA_ASM("rol", x, n) -#define SHA_ROR(x,n) SHA_ASM("ror", x, n) - -#else - -#define SHA_ROT(X,l,r) (((X) << (l)) | ((X) >> (r))) -#define SHA_ROL(X,n) SHA_ROT(X,n,32-(n)) -#define SHA_ROR(X,n) SHA_ROT(X,32-(n),n) - -#endif - -/* - * If you have 32 registers or more, the compiler can (and should) - * try to change the array[] accesses into registers. However, on - * machines with less than ~25 registers, that won't really work, - * and at least gcc will make an unholy mess of it. - * - * So to avoid that mess which just slows things down, we force - * the stores to memory to actually happen (we might be better off - * with a 'W(t)=(val);asm("":"+m" (W(t))' there instead, as - * suggested by Artur Skawina - that will also make gcc unable to - * try to do the silly "optimize away loads" part because it won't - * see what the value will be). - * - * Ben Herrenschmidt reports that on PPC, the C version comes close - * to the optimized asm with this (ie on PPC you don't want that - * 'volatile', since there are lots of registers). - * - * On ARM we get the best code generation by forcing a full memory barrier - * between each SHA_ROUND, otherwise gcc happily get wild with spilling and - * the stack frame size simply explode and performance goes down the drain. - */ - -#if defined(__i386__) || defined(__x86_64__) - #define setW(x, val) (*(volatile unsigned int *)&W(x) = (val)) -#elif defined(__GNUC__) && defined(__arm__) - #define setW(x, val) do { W(x) = (val); __asm__("":::"memory"); } while (0) -#else - #define setW(x, val) (W(x) = (val)) -#endif - -/* - * Performance might be improved if the CPU architecture is OK with - * unaligned 32-bit loads and a fast ntohl() is available. - * Otherwise fall back to byte loads and shifts which is portable, - * and is faster on architectures with memory alignment issues. - */ - -#if defined(__i386__) || defined(__x86_64__) || \ - defined(_M_IX86) || defined(_M_X64) || \ - defined(__ppc__) || defined(__ppc64__) || \ - defined(__powerpc__) || defined(__powerpc64__) || \ - defined(__s390__) || defined(__s390x__) - -#define get_be32(p) ntohl(*(const unsigned int *)(p)) -#define put_be32(p, v) do { *(unsigned int *)(p) = htonl(v); } while (0) - -#else - -#define get_be32(p) ( \ - (*((const unsigned char *)(p) + 0) << 24) | \ - (*((const unsigned char *)(p) + 1) << 16) | \ - (*((const unsigned char *)(p) + 2) << 8) | \ - (*((const unsigned char *)(p) + 3) << 0) ) -#define put_be32(p, v) do { \ - unsigned int __v = (v); \ - *((unsigned char *)(p) + 0) = __v >> 24; \ - *((unsigned char *)(p) + 1) = __v >> 16; \ - *((unsigned char *)(p) + 2) = __v >> 8; \ - *((unsigned char *)(p) + 3) = __v >> 0; } while (0) - -#endif - -/* This "rolls" over the 512-bit array */ -#define W(x) (array[(x)&15]) - -/* - * Where do we get the source from? The first 16 iterations get it from - * the input data, the next mix it from the 512-bit array. - */ -#define SHA_SRC(t) get_be32(data + t) -#define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1) - -#define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \ - unsigned int TEMP = input(t); setW(t, TEMP); \ - E += TEMP + SHA_ROL(A,5) + (fn) + (constant); \ - B = SHA_ROR(B, 2); } while (0) - -#define T_0_15(t, A, B, C, D, E) SHA_ROUND(t, SHA_SRC, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) -#define T_16_19(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (((C^D)&B)^D) , 0x5a827999, A, B, C, D, E ) -#define T_20_39(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0x6ed9eba1, A, B, C, D, E ) -#define T_40_59(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, ((B&C)+(D&(B^C))) , 0x8f1bbcdc, A, B, C, D, E ) -#define T_60_79(t, A, B, C, D, E) SHA_ROUND(t, SHA_MIX, (B^C^D) , 0xca62c1d6, A, B, C, D, E ) - -static void hash__block(git_hash_ctx *ctx, const unsigned int *data) -{ - unsigned int A,B,C,D,E; - unsigned int array[16]; - - A = ctx->H[0]; - B = ctx->H[1]; - C = ctx->H[2]; - D = ctx->H[3]; - E = ctx->H[4]; - - /* Round 1 - iterations 0-16 take their input from 'data' */ - T_0_15( 0, A, B, C, D, E); - T_0_15( 1, E, A, B, C, D); - T_0_15( 2, D, E, A, B, C); - T_0_15( 3, C, D, E, A, B); - T_0_15( 4, B, C, D, E, A); - T_0_15( 5, A, B, C, D, E); - T_0_15( 6, E, A, B, C, D); - T_0_15( 7, D, E, A, B, C); - T_0_15( 8, C, D, E, A, B); - T_0_15( 9, B, C, D, E, A); - T_0_15(10, A, B, C, D, E); - T_0_15(11, E, A, B, C, D); - T_0_15(12, D, E, A, B, C); - T_0_15(13, C, D, E, A, B); - T_0_15(14, B, C, D, E, A); - T_0_15(15, A, B, C, D, E); - - /* Round 1 - tail. Input from 512-bit mixing array */ - T_16_19(16, E, A, B, C, D); - T_16_19(17, D, E, A, B, C); - T_16_19(18, C, D, E, A, B); - T_16_19(19, B, C, D, E, A); - - /* Round 2 */ - T_20_39(20, A, B, C, D, E); - T_20_39(21, E, A, B, C, D); - T_20_39(22, D, E, A, B, C); - T_20_39(23, C, D, E, A, B); - T_20_39(24, B, C, D, E, A); - T_20_39(25, A, B, C, D, E); - T_20_39(26, E, A, B, C, D); - T_20_39(27, D, E, A, B, C); - T_20_39(28, C, D, E, A, B); - T_20_39(29, B, C, D, E, A); - T_20_39(30, A, B, C, D, E); - T_20_39(31, E, A, B, C, D); - T_20_39(32, D, E, A, B, C); - T_20_39(33, C, D, E, A, B); - T_20_39(34, B, C, D, E, A); - T_20_39(35, A, B, C, D, E); - T_20_39(36, E, A, B, C, D); - T_20_39(37, D, E, A, B, C); - T_20_39(38, C, D, E, A, B); - T_20_39(39, B, C, D, E, A); - - /* Round 3 */ - T_40_59(40, A, B, C, D, E); - T_40_59(41, E, A, B, C, D); - T_40_59(42, D, E, A, B, C); - T_40_59(43, C, D, E, A, B); - T_40_59(44, B, C, D, E, A); - T_40_59(45, A, B, C, D, E); - T_40_59(46, E, A, B, C, D); - T_40_59(47, D, E, A, B, C); - T_40_59(48, C, D, E, A, B); - T_40_59(49, B, C, D, E, A); - T_40_59(50, A, B, C, D, E); - T_40_59(51, E, A, B, C, D); - T_40_59(52, D, E, A, B, C); - T_40_59(53, C, D, E, A, B); - T_40_59(54, B, C, D, E, A); - T_40_59(55, A, B, C, D, E); - T_40_59(56, E, A, B, C, D); - T_40_59(57, D, E, A, B, C); - T_40_59(58, C, D, E, A, B); - T_40_59(59, B, C, D, E, A); - - /* Round 4 */ - T_60_79(60, A, B, C, D, E); - T_60_79(61, E, A, B, C, D); - T_60_79(62, D, E, A, B, C); - T_60_79(63, C, D, E, A, B); - T_60_79(64, B, C, D, E, A); - T_60_79(65, A, B, C, D, E); - T_60_79(66, E, A, B, C, D); - T_60_79(67, D, E, A, B, C); - T_60_79(68, C, D, E, A, B); - T_60_79(69, B, C, D, E, A); - T_60_79(70, A, B, C, D, E); - T_60_79(71, E, A, B, C, D); - T_60_79(72, D, E, A, B, C); - T_60_79(73, C, D, E, A, B); - T_60_79(74, B, C, D, E, A); - T_60_79(75, A, B, C, D, E); - T_60_79(76, E, A, B, C, D); - T_60_79(77, D, E, A, B, C); - T_60_79(78, C, D, E, A, B); - T_60_79(79, B, C, D, E, A); - - ctx->H[0] += A; - ctx->H[1] += B; - ctx->H[2] += C; - ctx->H[3] += D; - ctx->H[4] += E; -} - -int git_hash_init(git_hash_ctx *ctx) -{ - ctx->size = 0; - - /* Initialize H with the magic constants (see FIPS180 for constants) */ - ctx->H[0] = 0x67452301; - ctx->H[1] = 0xefcdab89; - ctx->H[2] = 0x98badcfe; - ctx->H[3] = 0x10325476; - ctx->H[4] = 0xc3d2e1f0; - - return 0; -} - -int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) -{ - unsigned int lenW = ctx->size & 63; - - ctx->size += len; - - /* Read the data into W and process blocks as they get full */ - if (lenW) { - unsigned int left = 64 - lenW; - if (len < left) - left = (unsigned int)len; - memcpy(lenW + (char *)ctx->W, data, left); - lenW = (lenW + left) & 63; - len -= left; - data = ((const char *)data + left); - if (lenW) - return 0; - hash__block(ctx, ctx->W); - } - while (len >= 64) { - hash__block(ctx, data); - data = ((const char *)data + 64); - len -= 64; - } - if (len) - memcpy(ctx->W, data, len); - - return 0; -} - -int git_hash_final(git_oid *out, git_hash_ctx *ctx) -{ - static const unsigned char pad[64] = { 0x80 }; - unsigned int padlen[2]; - int i; - - /* Pad with a binary 1 (ie 0x80), then zeroes, then length */ - padlen[0] = htonl((uint32_t)(ctx->size >> 29)); - padlen[1] = htonl((uint32_t)(ctx->size << 3)); - - i = ctx->size & 63; - git_hash_update(ctx, pad, 1+ (63 & (55 - i))); - git_hash_update(ctx, padlen, 8); - - /* Output hash */ - for (i = 0; i < 5; i++) - put_be32(out->id + i*4, ctx->H[i]); - - return 0; -} - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_generic.h r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_generic.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_generic.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_generic.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* - * 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_hash_generic_h__ -#define INCLUDE_hash_generic_h__ - -#include "hash.h" - -struct git_hash_ctx { - unsigned long long size; - unsigned int H[5]; - unsigned int W[16]; -}; - -#define git_hash_global_init() 0 -#define git_hash_ctx_init(ctx) git_hash_init(ctx) -#define git_hash_ctx_cleanup(ctx) - -#endif /* INCLUDE_hash_generic_h__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_openssl.h r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_openssl.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_openssl.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_openssl.h 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#ifndef INCLUDE_hash_openssl_h__ -#define INCLUDE_hash_openssl_h__ +#ifndef INCLUDE_hash_hash_openssl_h__ +#define INCLUDE_hash_hash_openssl_h__ #include "hash.h" @@ -23,22 +23,37 @@ GIT_INLINE(int) git_hash_init(git_hash_ctx *ctx) { assert(ctx); - SHA1_Init(&ctx->c); + + if (SHA1_Init(&ctx->c) != 1) { + giterr_set(GITERR_SHA1, "hash_openssl: failed to initialize hash context"); + return -1; + } + return 0; } GIT_INLINE(int) git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) { assert(ctx); - SHA1_Update(&ctx->c, data, len); + + if (SHA1_Update(&ctx->c, data, len) != 1) { + giterr_set(GITERR_SHA1, "hash_openssl: failed to update hash"); + return -1; + } + return 0; } GIT_INLINE(int) git_hash_final(git_oid *out, git_hash_ctx *ctx) { assert(ctx); - SHA1_Final(out->id, &ctx->c); + + if (SHA1_Final(out->id, &ctx->c) != 1) { + giterr_set(GITERR_SHA1, "hash_openssl: failed to finalize hash"); + return -1; + } + return 0; } -#endif /* INCLUDE_hash_openssl_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_win32.c r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_win32.c --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_win32.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_win32.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,276 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "global.h" -#include "hash.h" -#include "hash/hash_win32.h" - -#include -#include - -static struct git_hash_prov hash_prov = {0}; - -/* Hash initialization */ - -/* Initialize CNG, if available */ -GIT_INLINE(int) hash_cng_prov_init(void) -{ - char dll_path[MAX_PATH]; - DWORD dll_path_len, size_len; - - /* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */ - if (!git_has_win32_version(6, 0, 1)) - return -1; - - /* Load bcrypt.dll explicitly from the system directory */ - if ((dll_path_len = GetSystemDirectory(dll_path, MAX_PATH)) == 0 || - dll_path_len > MAX_PATH || - StringCchCat(dll_path, MAX_PATH, "\\") < 0 || - StringCchCat(dll_path, MAX_PATH, GIT_HASH_CNG_DLL_NAME) < 0 || - (hash_prov.prov.cng.dll = LoadLibrary(dll_path)) == NULL) - return -1; - - /* Load the function addresses */ - if ((hash_prov.prov.cng.open_algorithm_provider = (hash_win32_cng_open_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptOpenAlgorithmProvider")) == NULL || - (hash_prov.prov.cng.get_property = (hash_win32_cng_get_property_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptGetProperty")) == NULL || - (hash_prov.prov.cng.create_hash = (hash_win32_cng_create_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCreateHash")) == NULL || - (hash_prov.prov.cng.finish_hash = (hash_win32_cng_finish_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptFinishHash")) == NULL || - (hash_prov.prov.cng.hash_data = (hash_win32_cng_hash_data_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptHashData")) == NULL || - (hash_prov.prov.cng.destroy_hash = (hash_win32_cng_destroy_hash_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptDestroyHash")) == NULL || - (hash_prov.prov.cng.close_algorithm_provider = (hash_win32_cng_close_algorithm_provider_fn)GetProcAddress(hash_prov.prov.cng.dll, "BCryptCloseAlgorithmProvider")) == NULL) { - FreeLibrary(hash_prov.prov.cng.dll); - return -1; - } - - /* Load the SHA1 algorithm */ - if (hash_prov.prov.cng.open_algorithm_provider(&hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_TYPE, NULL, GIT_HASH_CNG_HASH_REUSABLE) < 0) { - FreeLibrary(hash_prov.prov.cng.dll); - return -1; - } - - /* Get storage space for the hash object */ - if (hash_prov.prov.cng.get_property(hash_prov.prov.cng.handle, GIT_HASH_CNG_HASH_OBJECT_LEN, (PBYTE)&hash_prov.prov.cng.hash_object_size, sizeof(DWORD), &size_len, 0) < 0) { - hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); - FreeLibrary(hash_prov.prov.cng.dll); - return -1; - } - - hash_prov.type = CNG; - return 0; -} - -GIT_INLINE(void) hash_cng_prov_shutdown(void) -{ - hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0); - FreeLibrary(hash_prov.prov.cng.dll); - - hash_prov.type = INVALID; -} - -/* Initialize CryptoAPI */ -GIT_INLINE(int) hash_cryptoapi_prov_init() -{ - if (!CryptAcquireContext(&hash_prov.prov.cryptoapi.handle, NULL, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - return -1; - - hash_prov.type = CRYPTOAPI; - return 0; -} - -GIT_INLINE(void) hash_cryptoapi_prov_shutdown(void) -{ - CryptReleaseContext(hash_prov.prov.cryptoapi.handle, 0); - - hash_prov.type = INVALID; -} - -static void git_hash_global_shutdown(void) -{ - if (hash_prov.type == CNG) - hash_cng_prov_shutdown(); - else if(hash_prov.type == CRYPTOAPI) - hash_cryptoapi_prov_shutdown(); -} - -int git_hash_global_init(void) -{ - int error = 0; - - if (hash_prov.type != INVALID) - return 0; - - if ((error = hash_cng_prov_init()) < 0) - error = hash_cryptoapi_prov_init(); - - git__on_shutdown(git_hash_global_shutdown); - - return error; -} - -/* CryptoAPI: available in Windows XP and newer */ - -GIT_INLINE(int) hash_ctx_cryptoapi_init(git_hash_ctx *ctx) -{ - ctx->type = CRYPTOAPI; - ctx->prov = &hash_prov; - - return git_hash_init(ctx); -} - -GIT_INLINE(int) hash_cryptoapi_init(git_hash_ctx *ctx) -{ - if (ctx->ctx.cryptoapi.valid) - CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); - - if (!CryptCreateHash(ctx->prov->prov.cryptoapi.handle, CALG_SHA1, 0, 0, &ctx->ctx.cryptoapi.hash_handle)) { - ctx->ctx.cryptoapi.valid = 0; - return -1; - } - - ctx->ctx.cryptoapi.valid = 1; - return 0; -} - -GIT_INLINE(int) hash_cryptoapi_update(git_hash_ctx *ctx, const void *data, size_t len) -{ - assert(ctx->ctx.cryptoapi.valid); - - if (!CryptHashData(ctx->ctx.cryptoapi.hash_handle, (const BYTE *)data, (DWORD)len, 0)) - return -1; - - return 0; -} - -GIT_INLINE(int) hash_cryptoapi_final(git_oid *out, git_hash_ctx *ctx) -{ - DWORD len = 20; - int error = 0; - - assert(ctx->ctx.cryptoapi.valid); - - if (!CryptGetHashParam(ctx->ctx.cryptoapi.hash_handle, HP_HASHVAL, out->id, &len, 0)) - error = -1; - - CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); - ctx->ctx.cryptoapi.valid = 0; - - return error; -} - -GIT_INLINE(void) hash_ctx_cryptoapi_cleanup(git_hash_ctx *ctx) -{ - if (ctx->ctx.cryptoapi.valid) - CryptDestroyHash(ctx->ctx.cryptoapi.hash_handle); -} - -/* CNG: Available in Windows Server 2008 and newer */ - -GIT_INLINE(int) hash_ctx_cng_init(git_hash_ctx *ctx) -{ - if ((ctx->ctx.cng.hash_object = git__malloc(hash_prov.prov.cng.hash_object_size)) == NULL) - return -1; - - if (hash_prov.prov.cng.create_hash(hash_prov.prov.cng.handle, &ctx->ctx.cng.hash_handle, ctx->ctx.cng.hash_object, hash_prov.prov.cng.hash_object_size, NULL, 0, 0) < 0) { - git__free(ctx->ctx.cng.hash_object); - return -1; - } - - ctx->type = CNG; - ctx->prov = &hash_prov; - - return 0; -} - -GIT_INLINE(int) hash_cng_init(git_hash_ctx *ctx) -{ - BYTE hash[GIT_OID_RAWSZ]; - - if (!ctx->ctx.cng.updated) - return 0; - - /* CNG needs to be finished to restart */ - if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, hash, GIT_OID_RAWSZ, 0) < 0) - return -1; - - ctx->ctx.cng.updated = 0; - - return 0; -} - -GIT_INLINE(int) hash_cng_update(git_hash_ctx *ctx, const void *data, size_t len) -{ - if (ctx->prov->prov.cng.hash_data(ctx->ctx.cng.hash_handle, (PBYTE)data, (ULONG)len, 0) < 0) - return -1; - - return 0; -} - -GIT_INLINE(int) hash_cng_final(git_oid *out, git_hash_ctx *ctx) -{ - if (ctx->prov->prov.cng.finish_hash(ctx->ctx.cng.hash_handle, out->id, GIT_OID_RAWSZ, 0) < 0) - return -1; - - ctx->ctx.cng.updated = 0; - - return 0; -} - -GIT_INLINE(void) hash_ctx_cng_cleanup(git_hash_ctx *ctx) -{ - ctx->prov->prov.cng.destroy_hash(ctx->ctx.cng.hash_handle); - git__free(ctx->ctx.cng.hash_object); -} - -/* Indirection between CryptoAPI and CNG */ - -int git_hash_ctx_init(git_hash_ctx *ctx) -{ - int error = 0; - - assert(ctx); - - /* - * When compiled with GIT_THREADS, the global hash_prov data is - * initialized with git_libgit2_init. Otherwise, it must be initialized - * at first use. - */ - if (hash_prov.type == INVALID && (error = git_hash_global_init()) < 0) - return error; - - memset(ctx, 0x0, sizeof(git_hash_ctx)); - - return (hash_prov.type == CNG) ? hash_ctx_cng_init(ctx) : hash_ctx_cryptoapi_init(ctx); -} - -int git_hash_init(git_hash_ctx *ctx) -{ - assert(ctx && ctx->type); - return (ctx->type == CNG) ? hash_cng_init(ctx) : hash_cryptoapi_init(ctx); -} - -int git_hash_update(git_hash_ctx *ctx, const void *data, size_t len) -{ - assert(ctx && ctx->type); - return (ctx->type == CNG) ? hash_cng_update(ctx, data, len) : hash_cryptoapi_update(ctx, data, len); -} - -int git_hash_final(git_oid *out, git_hash_ctx *ctx) -{ - assert(ctx && ctx->type); - return (ctx->type == CNG) ? hash_cng_final(out, ctx) : hash_cryptoapi_final(out, ctx); -} - -void git_hash_ctx_cleanup(git_hash_ctx *ctx) -{ - assert(ctx); - - if (ctx->type == CNG) - hash_ctx_cng_cleanup(ctx); - else if(ctx->type == CRYPTOAPI) - hash_ctx_cryptoapi_cleanup(ctx); -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_win32.h r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_win32.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/hash_win32.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/hash_win32.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* - * 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_hash_win32_h__ -#define INCLUDE_hash_win32_h__ - -#include "common.h" -#include "hash.h" - -#include -#include - -enum hash_win32_prov_type { - INVALID = 0, - CRYPTOAPI, - CNG -}; - -/* - * CryptoAPI is available for hashing on Windows XP and newer. - */ - -struct hash_cryptoapi_prov { - HCRYPTPROV handle; -}; - -/* - * CNG (bcrypt.dll) is significantly more performant than CryptoAPI and is - * preferred, however it is only available on Windows 2008 and newer and - * must therefore be dynamically loaded, and we must inline constants that - * would not exist when building in pre-Windows 2008 environments. - */ - -#define GIT_HASH_CNG_DLL_NAME "bcrypt.dll" - -/* BCRYPT_SHA1_ALGORITHM */ -#define GIT_HASH_CNG_HASH_TYPE L"SHA1" - -/* BCRYPT_OBJECT_LENGTH */ -#define GIT_HASH_CNG_HASH_OBJECT_LEN L"ObjectLength" - -/* BCRYPT_HASH_REUSEABLE_FLAGS */ -#define GIT_HASH_CNG_HASH_REUSABLE 0x00000020 - -/* Function declarations for CNG */ -typedef NTSTATUS (WINAPI *hash_win32_cng_open_algorithm_provider_fn)( - HANDLE /* BCRYPT_ALG_HANDLE */ *phAlgorithm, - LPCWSTR pszAlgId, - LPCWSTR pszImplementation, - DWORD dwFlags); - -typedef NTSTATUS (WINAPI *hash_win32_cng_get_property_fn)( - HANDLE /* BCRYPT_HANDLE */ hObject, - LPCWSTR pszProperty, - PUCHAR pbOutput, - ULONG cbOutput, - ULONG *pcbResult, - ULONG dwFlags); - -typedef NTSTATUS (WINAPI *hash_win32_cng_create_hash_fn)( - HANDLE /* BCRYPT_ALG_HANDLE */ hAlgorithm, - HANDLE /* BCRYPT_HASH_HANDLE */ *phHash, - PUCHAR pbHashObject, ULONG cbHashObject, - PUCHAR pbSecret, - ULONG cbSecret, - ULONG dwFlags); - -typedef NTSTATUS (WINAPI *hash_win32_cng_finish_hash_fn)( - HANDLE /* BCRYPT_HASH_HANDLE */ hHash, - PUCHAR pbOutput, - ULONG cbOutput, - ULONG dwFlags); - -typedef NTSTATUS (WINAPI *hash_win32_cng_hash_data_fn)( - HANDLE /* BCRYPT_HASH_HANDLE */ hHash, - PUCHAR pbInput, - ULONG cbInput, - ULONG dwFlags); - -typedef NTSTATUS (WINAPI *hash_win32_cng_destroy_hash_fn)( - HANDLE /* BCRYPT_HASH_HANDLE */ hHash); - -typedef NTSTATUS (WINAPI *hash_win32_cng_close_algorithm_provider_fn)( - HANDLE /* BCRYPT_ALG_HANDLE */ hAlgorithm, - ULONG dwFlags); - -struct hash_cng_prov { - /* DLL for CNG */ - HINSTANCE dll; - - /* Function pointers for CNG */ - hash_win32_cng_open_algorithm_provider_fn open_algorithm_provider; - hash_win32_cng_get_property_fn get_property; - hash_win32_cng_create_hash_fn create_hash; - hash_win32_cng_finish_hash_fn finish_hash; - hash_win32_cng_hash_data_fn hash_data; - hash_win32_cng_destroy_hash_fn destroy_hash; - hash_win32_cng_close_algorithm_provider_fn close_algorithm_provider; - - HANDLE /* BCRYPT_ALG_HANDLE */ handle; - DWORD hash_object_size; -}; - -struct git_hash_prov { - enum hash_win32_prov_type type; - - union { - struct hash_cryptoapi_prov cryptoapi; - struct hash_cng_prov cng; - } prov; -}; - -/* Hash contexts */ - -struct hash_cryptoapi_ctx { - bool valid; - HCRYPTHASH hash_handle; -}; - -struct hash_cng_ctx { - bool updated; - HANDLE /* BCRYPT_HASH_HANDLE */ hash_handle; - PBYTE hash_object; -}; - -struct git_hash_ctx { - enum hash_win32_prov_type type; - git_hash_prov *prov; - - union { - struct hash_cryptoapi_ctx cryptoapi; - struct hash_cng_ctx cng; - } ctx; -}; - -#endif /* INCLUDE_hash_openssl_h__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/sha1.c r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/sha1.c --- r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/sha1.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/sha1.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1856 +0,0 @@ -/*** -* Copyright 2017 Marc Stevens , Dan Shumow (danshu@microsoft.com) -* Distributed under the MIT Software License. -* See accompanying file LICENSE.txt or copy at -* https://opensource.org/licenses/MIT -***/ - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#include -#include -#include -#endif - -#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C -#include SHA1DC_CUSTOM_INCLUDE_SHA1_C -#endif - -#ifndef SHA1DC_INIT_SAFE_HASH_DEFAULT -#define SHA1DC_INIT_SAFE_HASH_DEFAULT 1 -#endif - -#include "sha1.h" -#include "ubc_check.h" - - -/* - Because Little-Endian architectures are most common, - we only set SHA1DC_BIGENDIAN if one of these conditions is met. - Note that all MSFT platforms are little endian, - so none of these will be defined under the MSC compiler. - If you are compiling on a big endian platform and your compiler does not define one of these, - you will have to add whatever macros your tool chain defines to indicate Big-Endianness. - */ -#ifdef SHA1DC_BIGENDIAN -#undef SHA1DC_BIGENDIAN -#endif - -#if (defined(_BYTE_ORDER) || defined(__BYTE_ORDER) || defined(__BYTE_ORDER__)) - -#if ((defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)) || \ - (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \ - (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) ) -#define SHA1DC_BIGENDIAN -#endif - -#else - -#if (defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) || defined(__BIG_ENDIAN__) || \ - defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \ - defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \ - defined(__sparc)) -#define SHA1DC_BIGENDIAN -#endif - -#endif - -#if (defined(SHA1DC_FORCE_LITTLEENDIAN) && defined(SHA1DC_BIGENDIAN)) -#undef SHA1DC_BIGENDIAN -#endif -#if (defined(SHA1DC_FORCE_BIGENDIAN) && !defined(SHA1DC_BIGENDIAN)) -#define SHA1DC_BIGENDIAN -#endif -/*ENDIANNESS SELECTION*/ - -#if (defined SHA1DC_FORCE_UNALIGNED_ACCESS || \ - defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \ - defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || \ - defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || \ - defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__) || \ - defined(__386) || defined(_M_X64) || defined(_M_AMD64)) - -#define SHA1DC_ALLOW_UNALIGNED_ACCESS - -#endif /*UNALIGNMENT DETECTION*/ - - -#define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n)))) -#define rotate_left(x,n) (((x)<<(n))|((x)>>(32-(n)))) - -#define sha1_bswap32(x) \ - {x = ((x << 8) & 0xFF00FF00) | ((x >> 8) & 0xFF00FF); x = (x << 16) | (x >> 16);} - -#define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1)) - -#ifdef SHA1DC_BIGENDIAN - #define sha1_load(m, t, temp) { temp = m[t]; } -#else - #define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); } -#endif - -#define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x - -#define sha1_f1(b,c,d) ((d)^((b)&((c)^(d)))) -#define sha1_f2(b,c,d) ((b)^(c)^(d)) -#define sha1_f3(b,c,d) (((b)&(c))+((d)&((b)^(c)))) -#define sha1_f4(b,c,d) ((b)^(c)^(d)) - -#define HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, m, t) \ - { e += rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; b = rotate_left(b, 30); } -#define HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, m, t) \ - { e += rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; b = rotate_left(b, 30); } -#define HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, m, t) \ - { e += rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; b = rotate_left(b, 30); } -#define HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, m, t) \ - { e += rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; b = rotate_left(b, 30); } - -#define HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, m, t) \ - { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999 + m[t]; } -#define HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, m, t) \ - { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1 + m[t]; } -#define HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, m, t) \ - { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC + m[t]; } -#define HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, m, t) \ - { b = rotate_right(b, 30); e -= rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6 + m[t]; } - -#define SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, t, temp) \ - {sha1_load(m, t, temp); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999; b = rotate_left(b, 30);} - -#define SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(a, b, c, d, e, W, t, temp) \ - {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f1(b,c,d) + 0x5A827999; b = rotate_left(b, 30); } - -#define SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, t, temp) \ - {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f2(b,c,d) + 0x6ED9EBA1; b = rotate_left(b, 30); } - -#define SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, t, temp) \ - {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f3(b,c,d) + 0x8F1BBCDC; b = rotate_left(b, 30); } - -#define SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, t, temp) \ - {temp = sha1_mix(W, t); sha1_store(W, t, temp); e += temp + rotate_left(a, 5) + sha1_f4(b,c,d) + 0xCA62C1D6; b = rotate_left(b, 30); } - - -#define SHA1_STORE_STATE(i) states[i][0] = a; states[i][1] = b; states[i][2] = c; states[i][3] = d; states[i][4] = e; - -#ifdef BUILDNOCOLLDETECTSHA1COMPRESSION -void sha1_compression(uint32_t ihv[5], const uint32_t m[16]) -{ - uint32_t W[80]; - uint32_t a,b,c,d,e; - unsigned i; - - memcpy(W, m, 16 * 4); - for (i = 16; i < 80; ++i) - W[i] = sha1_mix(W, i); - - a = ihv[0]; b = ihv[1]; c = ihv[2]; d = ihv[3]; e = ihv[4]; - - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19); - - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39); - - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59); - - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79); - - ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e; -} -#endif /*BUILDNOCOLLDETECTSHA1COMPRESSION*/ - - -static void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80]) -{ - uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4]; - - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 0); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 1); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 2); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 3); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 4); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 5); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 6); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 7); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 8); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 9); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 10); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 11); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 12); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 13); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 14); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, W, 15); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, W, 16); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, W, 17); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, W, 18); - HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, W, 19); - - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 20); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 21); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 22); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 23); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 24); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 25); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 26); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 27); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 28); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 29); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 30); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 31); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 32); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 33); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 34); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, W, 35); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, W, 36); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, W, 37); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, W, 38); - HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, W, 39); - - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 40); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 41); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 42); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 43); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 44); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 45); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 46); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 47); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 48); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 49); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 50); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 51); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 52); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 53); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 54); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, W, 55); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, W, 56); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, W, 57); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, W, 58); - HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, W, 59); - - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 60); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 61); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 62); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 63); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 64); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 65); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 66); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 67); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 68); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 69); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 70); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 71); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 72); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 73); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 74); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, W, 75); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, W, 76); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, W, 77); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, W, 78); - HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, W, 79); - - ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e; -} - - - -void sha1_compression_states(uint32_t ihv[5], const uint32_t m[16], uint32_t W[80], uint32_t states[80][5]) -{ - uint32_t a = ihv[0], b = ihv[1], c = ihv[2], d = ihv[3], e = ihv[4]; - uint32_t temp; - -#ifdef DOSTORESTATE00 - SHA1_STORE_STATE(0) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 0, temp); - -#ifdef DOSTORESTATE01 - SHA1_STORE_STATE(1) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 1, temp); - -#ifdef DOSTORESTATE02 - SHA1_STORE_STATE(2) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 2, temp); - -#ifdef DOSTORESTATE03 - SHA1_STORE_STATE(3) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 3, temp); - -#ifdef DOSTORESTATE04 - SHA1_STORE_STATE(4) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 4, temp); - -#ifdef DOSTORESTATE05 - SHA1_STORE_STATE(5) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 5, temp); - -#ifdef DOSTORESTATE06 - SHA1_STORE_STATE(6) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 6, temp); - -#ifdef DOSTORESTATE07 - SHA1_STORE_STATE(7) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 7, temp); - -#ifdef DOSTORESTATE08 - SHA1_STORE_STATE(8) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 8, temp); - -#ifdef DOSTORESTATE09 - SHA1_STORE_STATE(9) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 9, temp); - -#ifdef DOSTORESTATE10 - SHA1_STORE_STATE(10) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 10, temp); - -#ifdef DOSTORESTATE11 - SHA1_STORE_STATE(11) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(e, a, b, c, d, m, W, 11, temp); - -#ifdef DOSTORESTATE12 - SHA1_STORE_STATE(12) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(d, e, a, b, c, m, W, 12, temp); - -#ifdef DOSTORESTATE13 - SHA1_STORE_STATE(13) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(c, d, e, a, b, m, W, 13, temp); - -#ifdef DOSTORESTATE14 - SHA1_STORE_STATE(14) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(b, c, d, e, a, m, W, 14, temp); - -#ifdef DOSTORESTATE15 - SHA1_STORE_STATE(15) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_LOAD(a, b, c, d, e, m, W, 15, temp); - -#ifdef DOSTORESTATE16 - SHA1_STORE_STATE(16) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(e, a, b, c, d, W, 16, temp); - -#ifdef DOSTORESTATE17 - SHA1_STORE_STATE(17) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(d, e, a, b, c, W, 17, temp); - -#ifdef DOSTORESTATE18 - SHA1_STORE_STATE(18) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(c, d, e, a, b, W, 18, temp); - -#ifdef DOSTORESTATE19 - SHA1_STORE_STATE(19) -#endif - SHA1COMPRESS_FULL_ROUND1_STEP_EXPAND(b, c, d, e, a, W, 19, temp); - - - -#ifdef DOSTORESTATE20 - SHA1_STORE_STATE(20) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 20, temp); - -#ifdef DOSTORESTATE21 - SHA1_STORE_STATE(21) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 21, temp); - -#ifdef DOSTORESTATE22 - SHA1_STORE_STATE(22) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 22, temp); - -#ifdef DOSTORESTATE23 - SHA1_STORE_STATE(23) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 23, temp); - -#ifdef DOSTORESTATE24 - SHA1_STORE_STATE(24) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 24, temp); - -#ifdef DOSTORESTATE25 - SHA1_STORE_STATE(25) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 25, temp); - -#ifdef DOSTORESTATE26 - SHA1_STORE_STATE(26) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 26, temp); - -#ifdef DOSTORESTATE27 - SHA1_STORE_STATE(27) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 27, temp); - -#ifdef DOSTORESTATE28 - SHA1_STORE_STATE(28) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 28, temp); - -#ifdef DOSTORESTATE29 - SHA1_STORE_STATE(29) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 29, temp); - -#ifdef DOSTORESTATE30 - SHA1_STORE_STATE(30) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 30, temp); - -#ifdef DOSTORESTATE31 - SHA1_STORE_STATE(31) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 31, temp); - -#ifdef DOSTORESTATE32 - SHA1_STORE_STATE(32) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 32, temp); - -#ifdef DOSTORESTATE33 - SHA1_STORE_STATE(33) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 33, temp); - -#ifdef DOSTORESTATE34 - SHA1_STORE_STATE(34) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 34, temp); - -#ifdef DOSTORESTATE35 - SHA1_STORE_STATE(35) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(a, b, c, d, e, W, 35, temp); - -#ifdef DOSTORESTATE36 - SHA1_STORE_STATE(36) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(e, a, b, c, d, W, 36, temp); - -#ifdef DOSTORESTATE37 - SHA1_STORE_STATE(37) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(d, e, a, b, c, W, 37, temp); - -#ifdef DOSTORESTATE38 - SHA1_STORE_STATE(38) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(c, d, e, a, b, W, 38, temp); - -#ifdef DOSTORESTATE39 - SHA1_STORE_STATE(39) -#endif - SHA1COMPRESS_FULL_ROUND2_STEP(b, c, d, e, a, W, 39, temp); - - - -#ifdef DOSTORESTATE40 - SHA1_STORE_STATE(40) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 40, temp); - -#ifdef DOSTORESTATE41 - SHA1_STORE_STATE(41) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 41, temp); - -#ifdef DOSTORESTATE42 - SHA1_STORE_STATE(42) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 42, temp); - -#ifdef DOSTORESTATE43 - SHA1_STORE_STATE(43) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 43, temp); - -#ifdef DOSTORESTATE44 - SHA1_STORE_STATE(44) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 44, temp); - -#ifdef DOSTORESTATE45 - SHA1_STORE_STATE(45) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 45, temp); - -#ifdef DOSTORESTATE46 - SHA1_STORE_STATE(46) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 46, temp); - -#ifdef DOSTORESTATE47 - SHA1_STORE_STATE(47) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 47, temp); - -#ifdef DOSTORESTATE48 - SHA1_STORE_STATE(48) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 48, temp); - -#ifdef DOSTORESTATE49 - SHA1_STORE_STATE(49) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 49, temp); - -#ifdef DOSTORESTATE50 - SHA1_STORE_STATE(50) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 50, temp); - -#ifdef DOSTORESTATE51 - SHA1_STORE_STATE(51) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 51, temp); - -#ifdef DOSTORESTATE52 - SHA1_STORE_STATE(52) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 52, temp); - -#ifdef DOSTORESTATE53 - SHA1_STORE_STATE(53) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 53, temp); - -#ifdef DOSTORESTATE54 - SHA1_STORE_STATE(54) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 54, temp); - -#ifdef DOSTORESTATE55 - SHA1_STORE_STATE(55) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(a, b, c, d, e, W, 55, temp); - -#ifdef DOSTORESTATE56 - SHA1_STORE_STATE(56) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(e, a, b, c, d, W, 56, temp); - -#ifdef DOSTORESTATE57 - SHA1_STORE_STATE(57) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(d, e, a, b, c, W, 57, temp); - -#ifdef DOSTORESTATE58 - SHA1_STORE_STATE(58) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(c, d, e, a, b, W, 58, temp); - -#ifdef DOSTORESTATE59 - SHA1_STORE_STATE(59) -#endif - SHA1COMPRESS_FULL_ROUND3_STEP(b, c, d, e, a, W, 59, temp); - - - - -#ifdef DOSTORESTATE60 - SHA1_STORE_STATE(60) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 60, temp); - -#ifdef DOSTORESTATE61 - SHA1_STORE_STATE(61) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 61, temp); - -#ifdef DOSTORESTATE62 - SHA1_STORE_STATE(62) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 62, temp); - -#ifdef DOSTORESTATE63 - SHA1_STORE_STATE(63) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 63, temp); - -#ifdef DOSTORESTATE64 - SHA1_STORE_STATE(64) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 64, temp); - -#ifdef DOSTORESTATE65 - SHA1_STORE_STATE(65) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 65, temp); - -#ifdef DOSTORESTATE66 - SHA1_STORE_STATE(66) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 66, temp); - -#ifdef DOSTORESTATE67 - SHA1_STORE_STATE(67) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 67, temp); - -#ifdef DOSTORESTATE68 - SHA1_STORE_STATE(68) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 68, temp); - -#ifdef DOSTORESTATE69 - SHA1_STORE_STATE(69) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 69, temp); - -#ifdef DOSTORESTATE70 - SHA1_STORE_STATE(70) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 70, temp); - -#ifdef DOSTORESTATE71 - SHA1_STORE_STATE(71) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 71, temp); - -#ifdef DOSTORESTATE72 - SHA1_STORE_STATE(72) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 72, temp); - -#ifdef DOSTORESTATE73 - SHA1_STORE_STATE(73) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 73, temp); - -#ifdef DOSTORESTATE74 - SHA1_STORE_STATE(74) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 74, temp); - -#ifdef DOSTORESTATE75 - SHA1_STORE_STATE(75) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(a, b, c, d, e, W, 75, temp); - -#ifdef DOSTORESTATE76 - SHA1_STORE_STATE(76) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(e, a, b, c, d, W, 76, temp); - -#ifdef DOSTORESTATE77 - SHA1_STORE_STATE(77) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(d, e, a, b, c, W, 77, temp); - -#ifdef DOSTORESTATE78 - SHA1_STORE_STATE(78) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(c, d, e, a, b, W, 78, temp); - -#ifdef DOSTORESTATE79 - SHA1_STORE_STATE(79) -#endif - SHA1COMPRESS_FULL_ROUND4_STEP(b, c, d, e, a, W, 79, temp); - - - - ihv[0] += a; ihv[1] += b; ihv[2] += c; ihv[3] += d; ihv[4] += e; -} - - - - -#define SHA1_RECOMPRESS(t) \ -static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) \ -{ \ - uint32_t a = state[0], b = state[1], c = state[2], d = state[3], e = state[4]; \ - if (t > 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 79); \ - if (t > 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 78); \ - if (t > 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 77); \ - if (t > 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 76); \ - if (t > 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 75); \ - if (t > 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 74); \ - if (t > 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 73); \ - if (t > 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 72); \ - if (t > 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 71); \ - if (t > 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 70); \ - if (t > 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 69); \ - if (t > 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 68); \ - if (t > 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 67); \ - if (t > 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 66); \ - if (t > 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 65); \ - if (t > 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(b, c, d, e, a, me2, 64); \ - if (t > 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(c, d, e, a, b, me2, 63); \ - if (t > 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(d, e, a, b, c, me2, 62); \ - if (t > 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(e, a, b, c, d, me2, 61); \ - if (t > 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP_BW(a, b, c, d, e, me2, 60); \ - if (t > 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 59); \ - if (t > 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 58); \ - if (t > 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 57); \ - if (t > 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 56); \ - if (t > 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 55); \ - if (t > 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 54); \ - if (t > 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 53); \ - if (t > 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 52); \ - if (t > 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 51); \ - if (t > 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 50); \ - if (t > 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 49); \ - if (t > 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 48); \ - if (t > 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 47); \ - if (t > 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 46); \ - if (t > 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 45); \ - if (t > 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(b, c, d, e, a, me2, 44); \ - if (t > 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(c, d, e, a, b, me2, 43); \ - if (t > 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(d, e, a, b, c, me2, 42); \ - if (t > 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(e, a, b, c, d, me2, 41); \ - if (t > 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP_BW(a, b, c, d, e, me2, 40); \ - if (t > 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 39); \ - if (t > 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 38); \ - if (t > 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 37); \ - if (t > 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 36); \ - if (t > 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 35); \ - if (t > 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 34); \ - if (t > 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 33); \ - if (t > 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 32); \ - if (t > 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 31); \ - if (t > 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 30); \ - if (t > 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 29); \ - if (t > 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 28); \ - if (t > 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 27); \ - if (t > 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 26); \ - if (t > 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 25); \ - if (t > 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(b, c, d, e, a, me2, 24); \ - if (t > 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(c, d, e, a, b, me2, 23); \ - if (t > 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(d, e, a, b, c, me2, 22); \ - if (t > 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(e, a, b, c, d, me2, 21); \ - if (t > 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP_BW(a, b, c, d, e, me2, 20); \ - if (t > 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 19); \ - if (t > 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 18); \ - if (t > 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 17); \ - if (t > 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 16); \ - if (t > 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 15); \ - if (t > 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 14); \ - if (t > 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 13); \ - if (t > 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 12); \ - if (t > 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 11); \ - if (t > 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 10); \ - if (t > 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 9); \ - if (t > 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 8); \ - if (t > 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 7); \ - if (t > 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 6); \ - if (t > 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 5); \ - if (t > 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(b, c, d, e, a, me2, 4); \ - if (t > 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(c, d, e, a, b, me2, 3); \ - if (t > 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(d, e, a, b, c, me2, 2); \ - if (t > 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(e, a, b, c, d, me2, 1); \ - if (t > 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP_BW(a, b, c, d, e, me2, 0); \ - ihvin[0] = a; ihvin[1] = b; ihvin[2] = c; ihvin[3] = d; ihvin[4] = e; \ - a = state[0]; b = state[1]; c = state[2]; d = state[3]; e = state[4]; \ - if (t <= 0) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 0); \ - if (t <= 1) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 1); \ - if (t <= 2) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 2); \ - if (t <= 3) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 3); \ - if (t <= 4) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 4); \ - if (t <= 5) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 5); \ - if (t <= 6) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 6); \ - if (t <= 7) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 7); \ - if (t <= 8) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 8); \ - if (t <= 9) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 9); \ - if (t <= 10) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 10); \ - if (t <= 11) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 11); \ - if (t <= 12) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 12); \ - if (t <= 13) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 13); \ - if (t <= 14) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 14); \ - if (t <= 15) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(a, b, c, d, e, me2, 15); \ - if (t <= 16) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(e, a, b, c, d, me2, 16); \ - if (t <= 17) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(d, e, a, b, c, me2, 17); \ - if (t <= 18) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(c, d, e, a, b, me2, 18); \ - if (t <= 19) HASHCLASH_SHA1COMPRESS_ROUND1_STEP(b, c, d, e, a, me2, 19); \ - if (t <= 20) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 20); \ - if (t <= 21) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 21); \ - if (t <= 22) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 22); \ - if (t <= 23) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 23); \ - if (t <= 24) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 24); \ - if (t <= 25) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 25); \ - if (t <= 26) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 26); \ - if (t <= 27) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 27); \ - if (t <= 28) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 28); \ - if (t <= 29) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 29); \ - if (t <= 30) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 30); \ - if (t <= 31) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 31); \ - if (t <= 32) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 32); \ - if (t <= 33) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 33); \ - if (t <= 34) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 34); \ - if (t <= 35) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(a, b, c, d, e, me2, 35); \ - if (t <= 36) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(e, a, b, c, d, me2, 36); \ - if (t <= 37) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(d, e, a, b, c, me2, 37); \ - if (t <= 38) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(c, d, e, a, b, me2, 38); \ - if (t <= 39) HASHCLASH_SHA1COMPRESS_ROUND2_STEP(b, c, d, e, a, me2, 39); \ - if (t <= 40) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 40); \ - if (t <= 41) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 41); \ - if (t <= 42) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 42); \ - if (t <= 43) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 43); \ - if (t <= 44) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 44); \ - if (t <= 45) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 45); \ - if (t <= 46) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 46); \ - if (t <= 47) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 47); \ - if (t <= 48) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 48); \ - if (t <= 49) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 49); \ - if (t <= 50) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 50); \ - if (t <= 51) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 51); \ - if (t <= 52) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 52); \ - if (t <= 53) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 53); \ - if (t <= 54) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 54); \ - if (t <= 55) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(a, b, c, d, e, me2, 55); \ - if (t <= 56) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(e, a, b, c, d, me2, 56); \ - if (t <= 57) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(d, e, a, b, c, me2, 57); \ - if (t <= 58) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(c, d, e, a, b, me2, 58); \ - if (t <= 59) HASHCLASH_SHA1COMPRESS_ROUND3_STEP(b, c, d, e, a, me2, 59); \ - if (t <= 60) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 60); \ - if (t <= 61) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 61); \ - if (t <= 62) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 62); \ - if (t <= 63) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 63); \ - if (t <= 64) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 64); \ - if (t <= 65) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 65); \ - if (t <= 66) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 66); \ - if (t <= 67) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 67); \ - if (t <= 68) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 68); \ - if (t <= 69) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 69); \ - if (t <= 70) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 70); \ - if (t <= 71) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 71); \ - if (t <= 72) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 72); \ - if (t <= 73) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 73); \ - if (t <= 74) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 74); \ - if (t <= 75) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(a, b, c, d, e, me2, 75); \ - if (t <= 76) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(e, a, b, c, d, me2, 76); \ - if (t <= 77) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(d, e, a, b, c, me2, 77); \ - if (t <= 78) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(c, d, e, a, b, me2, 78); \ - if (t <= 79) HASHCLASH_SHA1COMPRESS_ROUND4_STEP(b, c, d, e, a, me2, 79); \ - ihvout[0] = ihvin[0] + a; ihvout[1] = ihvin[1] + b; ihvout[2] = ihvin[2] + c; ihvout[3] = ihvin[3] + d; ihvout[4] = ihvin[4] + e; \ -} - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4127) /* Complier complains about the checks in the above macro being constant. */ -#endif - -#ifdef DOSTORESTATE0 -SHA1_RECOMPRESS(0) -#endif - -#ifdef DOSTORESTATE1 -SHA1_RECOMPRESS(1) -#endif - -#ifdef DOSTORESTATE2 -SHA1_RECOMPRESS(2) -#endif - -#ifdef DOSTORESTATE3 -SHA1_RECOMPRESS(3) -#endif - -#ifdef DOSTORESTATE4 -SHA1_RECOMPRESS(4) -#endif - -#ifdef DOSTORESTATE5 -SHA1_RECOMPRESS(5) -#endif - -#ifdef DOSTORESTATE6 -SHA1_RECOMPRESS(6) -#endif - -#ifdef DOSTORESTATE7 -SHA1_RECOMPRESS(7) -#endif - -#ifdef DOSTORESTATE8 -SHA1_RECOMPRESS(8) -#endif - -#ifdef DOSTORESTATE9 -SHA1_RECOMPRESS(9) -#endif - -#ifdef DOSTORESTATE10 -SHA1_RECOMPRESS(10) -#endif - -#ifdef DOSTORESTATE11 -SHA1_RECOMPRESS(11) -#endif - -#ifdef DOSTORESTATE12 -SHA1_RECOMPRESS(12) -#endif - -#ifdef DOSTORESTATE13 -SHA1_RECOMPRESS(13) -#endif - -#ifdef DOSTORESTATE14 -SHA1_RECOMPRESS(14) -#endif - -#ifdef DOSTORESTATE15 -SHA1_RECOMPRESS(15) -#endif - -#ifdef DOSTORESTATE16 -SHA1_RECOMPRESS(16) -#endif - -#ifdef DOSTORESTATE17 -SHA1_RECOMPRESS(17) -#endif - -#ifdef DOSTORESTATE18 -SHA1_RECOMPRESS(18) -#endif - -#ifdef DOSTORESTATE19 -SHA1_RECOMPRESS(19) -#endif - -#ifdef DOSTORESTATE20 -SHA1_RECOMPRESS(20) -#endif - -#ifdef DOSTORESTATE21 -SHA1_RECOMPRESS(21) -#endif - -#ifdef DOSTORESTATE22 -SHA1_RECOMPRESS(22) -#endif - -#ifdef DOSTORESTATE23 -SHA1_RECOMPRESS(23) -#endif - -#ifdef DOSTORESTATE24 -SHA1_RECOMPRESS(24) -#endif - -#ifdef DOSTORESTATE25 -SHA1_RECOMPRESS(25) -#endif - -#ifdef DOSTORESTATE26 -SHA1_RECOMPRESS(26) -#endif - -#ifdef DOSTORESTATE27 -SHA1_RECOMPRESS(27) -#endif - -#ifdef DOSTORESTATE28 -SHA1_RECOMPRESS(28) -#endif - -#ifdef DOSTORESTATE29 -SHA1_RECOMPRESS(29) -#endif - -#ifdef DOSTORESTATE30 -SHA1_RECOMPRESS(30) -#endif - -#ifdef DOSTORESTATE31 -SHA1_RECOMPRESS(31) -#endif - -#ifdef DOSTORESTATE32 -SHA1_RECOMPRESS(32) -#endif - -#ifdef DOSTORESTATE33 -SHA1_RECOMPRESS(33) -#endif - -#ifdef DOSTORESTATE34 -SHA1_RECOMPRESS(34) -#endif - -#ifdef DOSTORESTATE35 -SHA1_RECOMPRESS(35) -#endif - -#ifdef DOSTORESTATE36 -SHA1_RECOMPRESS(36) -#endif - -#ifdef DOSTORESTATE37 -SHA1_RECOMPRESS(37) -#endif - -#ifdef DOSTORESTATE38 -SHA1_RECOMPRESS(38) -#endif - -#ifdef DOSTORESTATE39 -SHA1_RECOMPRESS(39) -#endif - -#ifdef DOSTORESTATE40 -SHA1_RECOMPRESS(40) -#endif - -#ifdef DOSTORESTATE41 -SHA1_RECOMPRESS(41) -#endif - -#ifdef DOSTORESTATE42 -SHA1_RECOMPRESS(42) -#endif - -#ifdef DOSTORESTATE43 -SHA1_RECOMPRESS(43) -#endif - -#ifdef DOSTORESTATE44 -SHA1_RECOMPRESS(44) -#endif - -#ifdef DOSTORESTATE45 -SHA1_RECOMPRESS(45) -#endif - -#ifdef DOSTORESTATE46 -SHA1_RECOMPRESS(46) -#endif - -#ifdef DOSTORESTATE47 -SHA1_RECOMPRESS(47) -#endif - -#ifdef DOSTORESTATE48 -SHA1_RECOMPRESS(48) -#endif - -#ifdef DOSTORESTATE49 -SHA1_RECOMPRESS(49) -#endif - -#ifdef DOSTORESTATE50 -SHA1_RECOMPRESS(50) -#endif - -#ifdef DOSTORESTATE51 -SHA1_RECOMPRESS(51) -#endif - -#ifdef DOSTORESTATE52 -SHA1_RECOMPRESS(52) -#endif - -#ifdef DOSTORESTATE53 -SHA1_RECOMPRESS(53) -#endif - -#ifdef DOSTORESTATE54 -SHA1_RECOMPRESS(54) -#endif - -#ifdef DOSTORESTATE55 -SHA1_RECOMPRESS(55) -#endif - -#ifdef DOSTORESTATE56 -SHA1_RECOMPRESS(56) -#endif - -#ifdef DOSTORESTATE57 -SHA1_RECOMPRESS(57) -#endif - -#ifdef DOSTORESTATE58 -SHA1_RECOMPRESS(58) -#endif - -#ifdef DOSTORESTATE59 -SHA1_RECOMPRESS(59) -#endif - -#ifdef DOSTORESTATE60 -SHA1_RECOMPRESS(60) -#endif - -#ifdef DOSTORESTATE61 -SHA1_RECOMPRESS(61) -#endif - -#ifdef DOSTORESTATE62 -SHA1_RECOMPRESS(62) -#endif - -#ifdef DOSTORESTATE63 -SHA1_RECOMPRESS(63) -#endif - -#ifdef DOSTORESTATE64 -SHA1_RECOMPRESS(64) -#endif - -#ifdef DOSTORESTATE65 -SHA1_RECOMPRESS(65) -#endif - -#ifdef DOSTORESTATE66 -SHA1_RECOMPRESS(66) -#endif - -#ifdef DOSTORESTATE67 -SHA1_RECOMPRESS(67) -#endif - -#ifdef DOSTORESTATE68 -SHA1_RECOMPRESS(68) -#endif - -#ifdef DOSTORESTATE69 -SHA1_RECOMPRESS(69) -#endif - -#ifdef DOSTORESTATE70 -SHA1_RECOMPRESS(70) -#endif - -#ifdef DOSTORESTATE71 -SHA1_RECOMPRESS(71) -#endif - -#ifdef DOSTORESTATE72 -SHA1_RECOMPRESS(72) -#endif - -#ifdef DOSTORESTATE73 -SHA1_RECOMPRESS(73) -#endif - -#ifdef DOSTORESTATE74 -SHA1_RECOMPRESS(74) -#endif - -#ifdef DOSTORESTATE75 -SHA1_RECOMPRESS(75) -#endif - -#ifdef DOSTORESTATE76 -SHA1_RECOMPRESS(76) -#endif - -#ifdef DOSTORESTATE77 -SHA1_RECOMPRESS(77) -#endif - -#ifdef DOSTORESTATE78 -SHA1_RECOMPRESS(78) -#endif - -#ifdef DOSTORESTATE79 -SHA1_RECOMPRESS(79) -#endif - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -static void sha1_recompression_step(uint32_t step, uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]) -{ - switch (step) - { -#ifdef DOSTORESTATE0 - case 0: - sha1recompress_fast_0(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE1 - case 1: - sha1recompress_fast_1(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE2 - case 2: - sha1recompress_fast_2(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE3 - case 3: - sha1recompress_fast_3(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE4 - case 4: - sha1recompress_fast_4(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE5 - case 5: - sha1recompress_fast_5(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE6 - case 6: - sha1recompress_fast_6(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE7 - case 7: - sha1recompress_fast_7(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE8 - case 8: - sha1recompress_fast_8(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE9 - case 9: - sha1recompress_fast_9(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE10 - case 10: - sha1recompress_fast_10(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE11 - case 11: - sha1recompress_fast_11(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE12 - case 12: - sha1recompress_fast_12(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE13 - case 13: - sha1recompress_fast_13(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE14 - case 14: - sha1recompress_fast_14(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE15 - case 15: - sha1recompress_fast_15(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE16 - case 16: - sha1recompress_fast_16(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE17 - case 17: - sha1recompress_fast_17(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE18 - case 18: - sha1recompress_fast_18(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE19 - case 19: - sha1recompress_fast_19(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE20 - case 20: - sha1recompress_fast_20(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE21 - case 21: - sha1recompress_fast_21(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE22 - case 22: - sha1recompress_fast_22(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE23 - case 23: - sha1recompress_fast_23(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE24 - case 24: - sha1recompress_fast_24(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE25 - case 25: - sha1recompress_fast_25(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE26 - case 26: - sha1recompress_fast_26(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE27 - case 27: - sha1recompress_fast_27(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE28 - case 28: - sha1recompress_fast_28(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE29 - case 29: - sha1recompress_fast_29(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE30 - case 30: - sha1recompress_fast_30(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE31 - case 31: - sha1recompress_fast_31(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE32 - case 32: - sha1recompress_fast_32(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE33 - case 33: - sha1recompress_fast_33(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE34 - case 34: - sha1recompress_fast_34(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE35 - case 35: - sha1recompress_fast_35(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE36 - case 36: - sha1recompress_fast_36(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE37 - case 37: - sha1recompress_fast_37(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE38 - case 38: - sha1recompress_fast_38(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE39 - case 39: - sha1recompress_fast_39(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE40 - case 40: - sha1recompress_fast_40(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE41 - case 41: - sha1recompress_fast_41(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE42 - case 42: - sha1recompress_fast_42(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE43 - case 43: - sha1recompress_fast_43(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE44 - case 44: - sha1recompress_fast_44(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE45 - case 45: - sha1recompress_fast_45(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE46 - case 46: - sha1recompress_fast_46(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE47 - case 47: - sha1recompress_fast_47(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE48 - case 48: - sha1recompress_fast_48(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE49 - case 49: - sha1recompress_fast_49(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE50 - case 50: - sha1recompress_fast_50(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE51 - case 51: - sha1recompress_fast_51(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE52 - case 52: - sha1recompress_fast_52(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE53 - case 53: - sha1recompress_fast_53(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE54 - case 54: - sha1recompress_fast_54(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE55 - case 55: - sha1recompress_fast_55(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE56 - case 56: - sha1recompress_fast_56(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE57 - case 57: - sha1recompress_fast_57(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE58 - case 58: - sha1recompress_fast_58(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE59 - case 59: - sha1recompress_fast_59(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE60 - case 60: - sha1recompress_fast_60(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE61 - case 61: - sha1recompress_fast_61(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE62 - case 62: - sha1recompress_fast_62(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE63 - case 63: - sha1recompress_fast_63(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE64 - case 64: - sha1recompress_fast_64(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE65 - case 65: - sha1recompress_fast_65(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE66 - case 66: - sha1recompress_fast_66(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE67 - case 67: - sha1recompress_fast_67(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE68 - case 68: - sha1recompress_fast_68(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE69 - case 69: - sha1recompress_fast_69(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE70 - case 70: - sha1recompress_fast_70(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE71 - case 71: - sha1recompress_fast_71(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE72 - case 72: - sha1recompress_fast_72(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE73 - case 73: - sha1recompress_fast_73(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE74 - case 74: - sha1recompress_fast_74(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE75 - case 75: - sha1recompress_fast_75(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE76 - case 76: - sha1recompress_fast_76(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE77 - case 77: - sha1recompress_fast_77(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE78 - case 78: - sha1recompress_fast_78(ihvin, ihvout, me2, state); - break; -#endif -#ifdef DOSTORESTATE79 - case 79: - sha1recompress_fast_79(ihvin, ihvout, me2, state); - break; -#endif - default: - abort(); - } - -} - - - -static void sha1_process(SHA1_CTX* ctx, const uint32_t block[16]) -{ - unsigned i, j; - uint32_t ubc_dv_mask[DVMASKSIZE] = { 0xFFFFFFFF }; - uint32_t ihvtmp[5]; - - ctx->ihv1[0] = ctx->ihv[0]; - ctx->ihv1[1] = ctx->ihv[1]; - ctx->ihv1[2] = ctx->ihv[2]; - ctx->ihv1[3] = ctx->ihv[3]; - ctx->ihv1[4] = ctx->ihv[4]; - - sha1_compression_states(ctx->ihv, block, ctx->m1, ctx->states); - - if (ctx->detect_coll) - { - if (ctx->ubc_check) - { - ubc_check(ctx->m1, ubc_dv_mask); - } - - if (ubc_dv_mask[0] != 0) - { - for (i = 0; sha1_dvs[i].dvType != 0; ++i) - { - if (ubc_dv_mask[0] & ((uint32_t)(1) << sha1_dvs[i].maskb)) - { - for (j = 0; j < 80; ++j) - ctx->m2[j] = ctx->m1[j] ^ sha1_dvs[i].dm[j]; - - sha1_recompression_step(sha1_dvs[i].testt, ctx->ihv2, ihvtmp, ctx->m2, ctx->states[sha1_dvs[i].testt]); - - /* to verify SHA-1 collision detection code with collisions for reduced-step SHA-1 */ - if ((0 == ((ihvtmp[0] ^ ctx->ihv[0]) | (ihvtmp[1] ^ ctx->ihv[1]) | (ihvtmp[2] ^ ctx->ihv[2]) | (ihvtmp[3] ^ ctx->ihv[3]) | (ihvtmp[4] ^ ctx->ihv[4]))) - || (ctx->reduced_round_coll && 0==((ctx->ihv1[0] ^ ctx->ihv2[0]) | (ctx->ihv1[1] ^ ctx->ihv2[1]) | (ctx->ihv1[2] ^ ctx->ihv2[2]) | (ctx->ihv1[3] ^ ctx->ihv2[3]) | (ctx->ihv1[4] ^ ctx->ihv2[4])))) - { - ctx->found_collision = 1; - - if (ctx->safe_hash) - { - sha1_compression_W(ctx->ihv, ctx->m1); - sha1_compression_W(ctx->ihv, ctx->m1); - } - - break; - } - } - } - } - } -} - -void SHA1DCInit(SHA1_CTX* ctx) -{ - ctx->total = 0; - ctx->ihv[0] = 0x67452301; - ctx->ihv[1] = 0xEFCDAB89; - ctx->ihv[2] = 0x98BADCFE; - ctx->ihv[3] = 0x10325476; - ctx->ihv[4] = 0xC3D2E1F0; - ctx->found_collision = 0; - ctx->safe_hash = SHA1DC_INIT_SAFE_HASH_DEFAULT; - ctx->ubc_check = 1; - ctx->detect_coll = 1; - ctx->reduced_round_coll = 0; - ctx->callback = NULL; -} - -void SHA1DCSetSafeHash(SHA1_CTX* ctx, int safehash) -{ - if (safehash) - ctx->safe_hash = 1; - else - ctx->safe_hash = 0; -} - - -void SHA1DCSetUseUBC(SHA1_CTX* ctx, int ubc_check) -{ - if (ubc_check) - ctx->ubc_check = 1; - else - ctx->ubc_check = 0; -} - -void SHA1DCSetUseDetectColl(SHA1_CTX* ctx, int detect_coll) -{ - if (detect_coll) - ctx->detect_coll = 1; - else - ctx->detect_coll = 0; -} - -void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX* ctx, int reduced_round_coll) -{ - if (reduced_round_coll) - ctx->reduced_round_coll = 1; - else - ctx->reduced_round_coll = 0; -} - -void SHA1DCSetCallback(SHA1_CTX* ctx, collision_block_callback callback) -{ - ctx->callback = callback; -} - -void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len) -{ - unsigned left, fill; - - if (len == 0) - return; - - left = ctx->total & 63; - fill = 64 - left; - - if (left && len >= fill) - { - ctx->total += fill; - memcpy(ctx->buffer + left, buf, fill); - sha1_process(ctx, (uint32_t*)(ctx->buffer)); - buf += fill; - len -= fill; - left = 0; - } - while (len >= 64) - { - ctx->total += 64; - -#if defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) - sha1_process(ctx, (uint32_t*)(buf)); -#else - memcpy(ctx->buffer, buf, 64); - sha1_process(ctx, (uint32_t*)(ctx->buffer)); -#endif /* defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) */ - buf += 64; - len -= 64; - } - if (len > 0) - { - ctx->total += len; - memcpy(ctx->buffer + left, buf, len); - } -} - -static const unsigned char sha1_padding[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -int SHA1DCFinal(unsigned char output[20], SHA1_CTX *ctx) -{ - uint32_t last = ctx->total & 63; - uint32_t padn = (last < 56) ? (56 - last) : (120 - last); - uint64_t total; - SHA1DCUpdate(ctx, (const char*)(sha1_padding), padn); - - total = ctx->total - padn; - total <<= 3; - ctx->buffer[56] = (unsigned char)(total >> 56); - ctx->buffer[57] = (unsigned char)(total >> 48); - ctx->buffer[58] = (unsigned char)(total >> 40); - ctx->buffer[59] = (unsigned char)(total >> 32); - ctx->buffer[60] = (unsigned char)(total >> 24); - ctx->buffer[61] = (unsigned char)(total >> 16); - ctx->buffer[62] = (unsigned char)(total >> 8); - ctx->buffer[63] = (unsigned char)(total); - sha1_process(ctx, (uint32_t*)(ctx->buffer)); - output[0] = (unsigned char)(ctx->ihv[0] >> 24); - output[1] = (unsigned char)(ctx->ihv[0] >> 16); - output[2] = (unsigned char)(ctx->ihv[0] >> 8); - output[3] = (unsigned char)(ctx->ihv[0]); - output[4] = (unsigned char)(ctx->ihv[1] >> 24); - output[5] = (unsigned char)(ctx->ihv[1] >> 16); - output[6] = (unsigned char)(ctx->ihv[1] >> 8); - output[7] = (unsigned char)(ctx->ihv[1]); - output[8] = (unsigned char)(ctx->ihv[2] >> 24); - output[9] = (unsigned char)(ctx->ihv[2] >> 16); - output[10] = (unsigned char)(ctx->ihv[2] >> 8); - output[11] = (unsigned char)(ctx->ihv[2]); - output[12] = (unsigned char)(ctx->ihv[3] >> 24); - output[13] = (unsigned char)(ctx->ihv[3] >> 16); - output[14] = (unsigned char)(ctx->ihv[3] >> 8); - output[15] = (unsigned char)(ctx->ihv[3]); - output[16] = (unsigned char)(ctx->ihv[4] >> 24); - output[17] = (unsigned char)(ctx->ihv[4] >> 16); - output[18] = (unsigned char)(ctx->ihv[4] >> 8); - output[19] = (unsigned char)(ctx->ihv[4]); - return ctx->found_collision; -} - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/sha1.h r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/sha1.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/sha1.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/sha1.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -/*** -* Copyright 2017 Marc Stevens , Dan Shumow -* Distributed under the MIT Software License. -* See accompanying file LICENSE.txt or copy at -* https://opensource.org/licenses/MIT -***/ - -#ifndef SHA1DC_SHA1_H -#define SHA1DC_SHA1_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#endif - -/* sha-1 compression function that takes an already expanded message, and additionally store intermediate states */ -/* only stores states ii (the state between step ii-1 and step ii) when DOSTORESTATEii is defined in ubc_check.h */ -void sha1_compression_states(uint32_t[5], const uint32_t[16], uint32_t[80], uint32_t[80][5]); - -/* -// Function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]). -// Where 0 <= T < 80 -// me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference.) -// state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block. -// The function will return: -// ihvin: The reconstructed input chaining value. -// ihvout: The reconstructed output chaining value. -*/ -typedef void(*sha1_recompression_type)(uint32_t*, uint32_t*, const uint32_t*, const uint32_t*); - -/* A callback function type that can be set to be called when a collision block has been found: */ -/* void collision_block_callback(uint64_t byteoffset, const uint32_t ihvin1[5], const uint32_t ihvin2[5], const uint32_t m1[80], const uint32_t m2[80]) */ -typedef void(*collision_block_callback)(uint64_t, const uint32_t*, const uint32_t*, const uint32_t*, const uint32_t*); - -/* The SHA-1 context. */ -typedef struct { - uint64_t total; - uint32_t ihv[5]; - unsigned char buffer[64]; - int found_collision; - int safe_hash; - int detect_coll; - int ubc_check; - int reduced_round_coll; - collision_block_callback callback; - - uint32_t ihv1[5]; - uint32_t ihv2[5]; - uint32_t m1[80]; - uint32_t m2[80]; - uint32_t states[80][5]; -} SHA1_CTX; - -/* Initialize SHA-1 context. */ -void SHA1DCInit(SHA1_CTX*); - -/* - Function to enable safe SHA-1 hashing: - Collision attacks are thwarted by hashing a detected near-collision block 3 times. - Think of it as extending SHA-1 from 80-steps to 240-steps for such blocks: - The best collision attacks against SHA-1 have complexity about 2^60, - thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180. - An attacker would be better off using a generic birthday search of complexity 2^80. - - Enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected, - but it will result in a different SHA-1 hash for messages where a collision attack was detected. - This will automatically invalidate SHA-1 based digital signature forgeries. - Enabled by default. -*/ -void SHA1DCSetSafeHash(SHA1_CTX*, int); - -/* - Function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up). - Enabled by default - */ -void SHA1DCSetUseUBC(SHA1_CTX*, int); - -/* - Function to disable or enable the use of Collision Detection. - Enabled by default. - */ -void SHA1DCSetUseDetectColl(SHA1_CTX*, int); - -/* function to disable or enable the detection of reduced-round SHA-1 collisions */ -/* disabled by default */ -void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX*, int); - -/* function to set a callback function, pass NULL to disable */ -/* by default no callback set */ -void SHA1DCSetCallback(SHA1_CTX*, collision_block_callback); - -/* update SHA-1 context with buffer contents */ -void SHA1DCUpdate(SHA1_CTX*, const char*, size_t); - -/* obtain SHA-1 hash from SHA-1 context */ -/* returns: 0 = no collision detected, otherwise = collision found => warn user for active attack */ -int SHA1DCFinal(unsigned char[20], SHA1_CTX*); - -#if defined(__cplusplus) -} -#endif - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H -#endif - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/ubc_check.c r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/ubc_check.c --- r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/ubc_check.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/ubc_check.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,372 +0,0 @@ -/*** -* Copyright 2017 Marc Stevens , Dan Shumow -* Distributed under the MIT Software License. -* See accompanying file LICENSE.txt or copy at -* https://opensource.org/licenses/MIT -***/ - -/* -// this file was generated by the 'parse_bitrel' program in the tools section -// using the data files from directory 'tools/data/3565' -// -// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check -// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper) -// dm[80] is the expanded message block XOR-difference defined by the DV -// testt is the step to do the recompression from for collision detection -// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check -// -// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs -// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met -// thus one needs to do the recompression check for each DV that has its bit set -// -// ubc_check is programmatically generated and the unavoidable bitconditions have been hardcoded -// a directly verifiable version named ubc_check_verify can be found in ubc_check_verify.c -// ubc_check has been verified against ubc_check_verify using the 'ubc_check_test' program in the tools section -*/ - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#endif -#ifdef SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C -#include SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C -#endif -#include "ubc_check.h" - -static const uint32_t DV_I_43_0_bit = (uint32_t)(1) << 0; -static const uint32_t DV_I_44_0_bit = (uint32_t)(1) << 1; -static const uint32_t DV_I_45_0_bit = (uint32_t)(1) << 2; -static const uint32_t DV_I_46_0_bit = (uint32_t)(1) << 3; -static const uint32_t DV_I_46_2_bit = (uint32_t)(1) << 4; -static const uint32_t DV_I_47_0_bit = (uint32_t)(1) << 5; -static const uint32_t DV_I_47_2_bit = (uint32_t)(1) << 6; -static const uint32_t DV_I_48_0_bit = (uint32_t)(1) << 7; -static const uint32_t DV_I_48_2_bit = (uint32_t)(1) << 8; -static const uint32_t DV_I_49_0_bit = (uint32_t)(1) << 9; -static const uint32_t DV_I_49_2_bit = (uint32_t)(1) << 10; -static const uint32_t DV_I_50_0_bit = (uint32_t)(1) << 11; -static const uint32_t DV_I_50_2_bit = (uint32_t)(1) << 12; -static const uint32_t DV_I_51_0_bit = (uint32_t)(1) << 13; -static const uint32_t DV_I_51_2_bit = (uint32_t)(1) << 14; -static const uint32_t DV_I_52_0_bit = (uint32_t)(1) << 15; -static const uint32_t DV_II_45_0_bit = (uint32_t)(1) << 16; -static const uint32_t DV_II_46_0_bit = (uint32_t)(1) << 17; -static const uint32_t DV_II_46_2_bit = (uint32_t)(1) << 18; -static const uint32_t DV_II_47_0_bit = (uint32_t)(1) << 19; -static const uint32_t DV_II_48_0_bit = (uint32_t)(1) << 20; -static const uint32_t DV_II_49_0_bit = (uint32_t)(1) << 21; -static const uint32_t DV_II_49_2_bit = (uint32_t)(1) << 22; -static const uint32_t DV_II_50_0_bit = (uint32_t)(1) << 23; -static const uint32_t DV_II_50_2_bit = (uint32_t)(1) << 24; -static const uint32_t DV_II_51_0_bit = (uint32_t)(1) << 25; -static const uint32_t DV_II_51_2_bit = (uint32_t)(1) << 26; -static const uint32_t DV_II_52_0_bit = (uint32_t)(1) << 27; -static const uint32_t DV_II_53_0_bit = (uint32_t)(1) << 28; -static const uint32_t DV_II_54_0_bit = (uint32_t)(1) << 29; -static const uint32_t DV_II_55_0_bit = (uint32_t)(1) << 30; -static const uint32_t DV_II_56_0_bit = (uint32_t)(1) << 31; - -dv_info_t sha1_dvs[] = -{ - {1,43,0,58,0,0, { 0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803,0x80000161,0x80000599 } } -, {1,44,0,58,0,1, { 0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803,0x80000161 } } -, {1,45,0,58,0,2, { 0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803 } } -, {1,46,0,58,0,3, { 0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c } } -, {1,46,2,58,0,4, { 0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590,0x00001020,0x0000039a,0x00000132 } } -, {1,47,0,58,0,5, { 0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6 } } -, {1,47,2,58,0,6, { 0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590,0x00001020,0x0000039a } } -, {1,48,0,58,0,7, { 0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408 } } -, {1,48,2,58,0,8, { 0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590,0x00001020 } } -, {1,49,0,58,0,9, { 0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164 } } -, {1,49,2,58,0,10, { 0x60000000,0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590 } } -, {1,50,0,65,0,11, { 0x0800000c,0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018 } } -, {1,50,2,65,0,12, { 0x20000030,0x60000000,0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060 } } -, {1,51,0,65,0,13, { 0xe8000000,0x0800000c,0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202 } } -, {1,51,2,65,0,14, { 0xa0000003,0x20000030,0x60000000,0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a } } -, {1,52,0,65,0,15, { 0x04000010,0xe8000000,0x0800000c,0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012 } } -, {2,45,0,58,0,16, { 0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a,0x000002e4,0x80000054,0x00000967 } } -, {2,46,0,58,0,17, { 0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a,0x000002e4,0x80000054 } } -, {2,46,2,58,0,18, { 0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e,0x0000046c,0x000005b6,0x0000106a,0x00000b90,0x00000152 } } -, {2,47,0,58,0,19, { 0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a,0x000002e4 } } -, {2,48,0,58,0,20, { 0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a } } -, {2,49,0,58,0,21, { 0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d } } -, {2,49,2,58,0,22, { 0xf0000010,0xf000006a,0x80000040,0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e,0x0000046c,0x000005b6 } } -, {2,50,0,65,0,23, { 0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b } } -, {2,50,2,65,0,24, { 0xd0000072,0xf0000010,0xf000006a,0x80000040,0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e,0x0000046c } } -, {2,51,0,65,0,25, { 0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b } } -, {2,51,2,65,0,26, { 0x00000043,0xd0000072,0xf0000010,0xf000006a,0x80000040,0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e } } -, {2,52,0,65,0,27, { 0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014 } } -, {2,53,0,65,0,28, { 0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089 } } -, {2,54,0,65,0,29, { 0x0400001c,0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107 } } -, {2,55,0,65,0,30, { 0x00000010,0x0400001c,0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b } } -, {2,56,0,65,0,31, { 0x2600001a,0x00000010,0x0400001c,0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046 } } -, {0,0,0,0,0,0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} -}; -void ubc_check(const uint32_t W[80], uint32_t dvmask[1]) -{ - uint32_t mask = ~((uint32_t)(0)); - mask &= (((((W[44]^W[45])>>29)&1)-1) | ~(DV_I_48_0_bit|DV_I_51_0_bit|DV_I_52_0_bit|DV_II_45_0_bit|DV_II_46_0_bit|DV_II_50_0_bit|DV_II_51_0_bit)); - mask &= (((((W[49]^W[50])>>29)&1)-1) | ~(DV_I_46_0_bit|DV_II_45_0_bit|DV_II_50_0_bit|DV_II_51_0_bit|DV_II_55_0_bit|DV_II_56_0_bit)); - mask &= (((((W[48]^W[49])>>29)&1)-1) | ~(DV_I_45_0_bit|DV_I_52_0_bit|DV_II_49_0_bit|DV_II_50_0_bit|DV_II_54_0_bit|DV_II_55_0_bit)); - mask &= ((((W[47]^(W[50]>>25))&(1<<4))-(1<<4)) | ~(DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_51_0_bit|DV_II_56_0_bit)); - mask &= (((((W[47]^W[48])>>29)&1)-1) | ~(DV_I_44_0_bit|DV_I_51_0_bit|DV_II_48_0_bit|DV_II_49_0_bit|DV_II_53_0_bit|DV_II_54_0_bit)); - mask &= (((((W[46]>>4)^(W[49]>>29))&1)-1) | ~(DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit|DV_II_50_0_bit|DV_II_55_0_bit)); - mask &= (((((W[46]^W[47])>>29)&1)-1) | ~(DV_I_43_0_bit|DV_I_50_0_bit|DV_II_47_0_bit|DV_II_48_0_bit|DV_II_52_0_bit|DV_II_53_0_bit)); - mask &= (((((W[45]>>4)^(W[48]>>29))&1)-1) | ~(DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit|DV_II_49_0_bit|DV_II_54_0_bit)); - mask &= (((((W[45]^W[46])>>29)&1)-1) | ~(DV_I_49_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_47_0_bit|DV_II_51_0_bit|DV_II_52_0_bit)); - mask &= (((((W[44]>>4)^(W[47]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit|DV_II_48_0_bit|DV_II_53_0_bit)); - mask &= (((((W[43]>>4)^(W[46]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit|DV_II_47_0_bit|DV_II_52_0_bit)); - mask &= (((((W[43]^W[44])>>29)&1)-1) | ~(DV_I_47_0_bit|DV_I_50_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_49_0_bit|DV_II_50_0_bit)); - mask &= (((((W[42]>>4)^(W[45]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_51_0_bit)); - mask &= (((((W[41]>>4)^(W[44]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_50_0_bit)); - mask &= (((((W[40]^W[41])>>29)&1)-1) | ~(DV_I_44_0_bit|DV_I_47_0_bit|DV_I_48_0_bit|DV_II_46_0_bit|DV_II_47_0_bit|DV_II_56_0_bit)); - mask &= (((((W[54]^W[55])>>29)&1)-1) | ~(DV_I_51_0_bit|DV_II_47_0_bit|DV_II_50_0_bit|DV_II_55_0_bit|DV_II_56_0_bit)); - mask &= (((((W[53]^W[54])>>29)&1)-1) | ~(DV_I_50_0_bit|DV_II_46_0_bit|DV_II_49_0_bit|DV_II_54_0_bit|DV_II_55_0_bit)); - mask &= (((((W[52]^W[53])>>29)&1)-1) | ~(DV_I_49_0_bit|DV_II_45_0_bit|DV_II_48_0_bit|DV_II_53_0_bit|DV_II_54_0_bit)); - mask &= ((((W[50]^(W[53]>>25))&(1<<4))-(1<<4)) | ~(DV_I_50_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_48_0_bit|DV_II_54_0_bit)); - mask &= (((((W[50]^W[51])>>29)&1)-1) | ~(DV_I_47_0_bit|DV_II_46_0_bit|DV_II_51_0_bit|DV_II_52_0_bit|DV_II_56_0_bit)); - mask &= ((((W[49]^(W[52]>>25))&(1<<4))-(1<<4)) | ~(DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_47_0_bit|DV_II_53_0_bit)); - mask &= ((((W[48]^(W[51]>>25))&(1<<4))-(1<<4)) | ~(DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_52_0_bit)); - mask &= (((((W[42]^W[43])>>29)&1)-1) | ~(DV_I_46_0_bit|DV_I_49_0_bit|DV_I_50_0_bit|DV_II_48_0_bit|DV_II_49_0_bit)); - mask &= (((((W[41]^W[42])>>29)&1)-1) | ~(DV_I_45_0_bit|DV_I_48_0_bit|DV_I_49_0_bit|DV_II_47_0_bit|DV_II_48_0_bit)); - mask &= (((((W[40]>>4)^(W[43]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_50_0_bit|DV_II_49_0_bit|DV_II_56_0_bit)); - mask &= (((((W[39]>>4)^(W[42]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_49_0_bit|DV_II_48_0_bit|DV_II_55_0_bit)); - if (mask & (DV_I_44_0_bit|DV_I_48_0_bit|DV_II_47_0_bit|DV_II_54_0_bit|DV_II_56_0_bit)) - mask &= (((((W[38]>>4)^(W[41]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_48_0_bit|DV_II_47_0_bit|DV_II_54_0_bit|DV_II_56_0_bit)); - mask &= (((((W[37]>>4)^(W[40]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_47_0_bit|DV_II_46_0_bit|DV_II_53_0_bit|DV_II_55_0_bit)); - if (mask & (DV_I_52_0_bit|DV_II_48_0_bit|DV_II_51_0_bit|DV_II_56_0_bit)) - mask &= (((((W[55]^W[56])>>29)&1)-1) | ~(DV_I_52_0_bit|DV_II_48_0_bit|DV_II_51_0_bit|DV_II_56_0_bit)); - if (mask & (DV_I_52_0_bit|DV_II_48_0_bit|DV_II_50_0_bit|DV_II_56_0_bit)) - mask &= ((((W[52]^(W[55]>>25))&(1<<4))-(1<<4)) | ~(DV_I_52_0_bit|DV_II_48_0_bit|DV_II_50_0_bit|DV_II_56_0_bit)); - if (mask & (DV_I_51_0_bit|DV_II_47_0_bit|DV_II_49_0_bit|DV_II_55_0_bit)) - mask &= ((((W[51]^(W[54]>>25))&(1<<4))-(1<<4)) | ~(DV_I_51_0_bit|DV_II_47_0_bit|DV_II_49_0_bit|DV_II_55_0_bit)); - if (mask & (DV_I_48_0_bit|DV_II_47_0_bit|DV_II_52_0_bit|DV_II_53_0_bit)) - mask &= (((((W[51]^W[52])>>29)&1)-1) | ~(DV_I_48_0_bit|DV_II_47_0_bit|DV_II_52_0_bit|DV_II_53_0_bit)); - if (mask & (DV_I_46_0_bit|DV_I_49_0_bit|DV_II_45_0_bit|DV_II_48_0_bit)) - mask &= (((((W[36]>>4)^(W[40]>>29))&1)-1) | ~(DV_I_46_0_bit|DV_I_49_0_bit|DV_II_45_0_bit|DV_II_48_0_bit)); - if (mask & (DV_I_52_0_bit|DV_II_48_0_bit|DV_II_49_0_bit)) - mask &= ((0-(((W[53]^W[56])>>29)&1)) | ~(DV_I_52_0_bit|DV_II_48_0_bit|DV_II_49_0_bit)); - if (mask & (DV_I_50_0_bit|DV_II_46_0_bit|DV_II_47_0_bit)) - mask &= ((0-(((W[51]^W[54])>>29)&1)) | ~(DV_I_50_0_bit|DV_II_46_0_bit|DV_II_47_0_bit)); - if (mask & (DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit)) - mask &= ((0-(((W[50]^W[52])>>29)&1)) | ~(DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit)); - if (mask & (DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit)) - mask &= ((0-(((W[49]^W[51])>>29)&1)) | ~(DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit)); - if (mask & (DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit)) - mask &= ((0-(((W[48]^W[50])>>29)&1)) | ~(DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit)); - if (mask & (DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit)) - mask &= ((0-(((W[47]^W[49])>>29)&1)) | ~(DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit)); - if (mask & (DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit)) - mask &= ((0-(((W[46]^W[48])>>29)&1)) | ~(DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit)); - mask &= ((((W[45]^W[47])&(1<<6))-(1<<6)) | ~(DV_I_47_2_bit|DV_I_49_2_bit|DV_I_51_2_bit)); - if (mask & (DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit)) - mask &= ((0-(((W[45]^W[47])>>29)&1)) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit)); - mask &= (((((W[44]^W[46])>>6)&1)-1) | ~(DV_I_46_2_bit|DV_I_48_2_bit|DV_I_50_2_bit)); - if (mask & (DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit)) - mask &= ((0-(((W[44]^W[46])>>29)&1)) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit)); - mask &= ((0-((W[41]^(W[42]>>5))&(1<<1))) | ~(DV_I_48_2_bit|DV_II_46_2_bit|DV_II_51_2_bit)); - mask &= ((0-((W[40]^(W[41]>>5))&(1<<1))) | ~(DV_I_47_2_bit|DV_I_51_2_bit|DV_II_50_2_bit)); - if (mask & (DV_I_44_0_bit|DV_I_46_0_bit|DV_II_56_0_bit)) - mask &= ((0-(((W[40]^W[42])>>4)&1)) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_II_56_0_bit)); - mask &= ((0-((W[39]^(W[40]>>5))&(1<<1))) | ~(DV_I_46_2_bit|DV_I_50_2_bit|DV_II_49_2_bit)); - if (mask & (DV_I_43_0_bit|DV_I_45_0_bit|DV_II_55_0_bit)) - mask &= ((0-(((W[39]^W[41])>>4)&1)) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_II_55_0_bit)); - if (mask & (DV_I_44_0_bit|DV_II_54_0_bit|DV_II_56_0_bit)) - mask &= ((0-(((W[38]^W[40])>>4)&1)) | ~(DV_I_44_0_bit|DV_II_54_0_bit|DV_II_56_0_bit)); - if (mask & (DV_I_43_0_bit|DV_II_53_0_bit|DV_II_55_0_bit)) - mask &= ((0-(((W[37]^W[39])>>4)&1)) | ~(DV_I_43_0_bit|DV_II_53_0_bit|DV_II_55_0_bit)); - mask &= ((0-((W[36]^(W[37]>>5))&(1<<1))) | ~(DV_I_47_2_bit|DV_I_50_2_bit|DV_II_46_2_bit)); - if (mask & (DV_I_45_0_bit|DV_I_48_0_bit|DV_II_47_0_bit)) - mask &= (((((W[35]>>4)^(W[39]>>29))&1)-1) | ~(DV_I_45_0_bit|DV_I_48_0_bit|DV_II_47_0_bit)); - if (mask & (DV_I_48_0_bit|DV_II_48_0_bit)) - mask &= ((0-((W[63]^(W[64]>>5))&(1<<0))) | ~(DV_I_48_0_bit|DV_II_48_0_bit)); - if (mask & (DV_I_45_0_bit|DV_II_45_0_bit)) - mask &= ((0-((W[63]^(W[64]>>5))&(1<<1))) | ~(DV_I_45_0_bit|DV_II_45_0_bit)); - if (mask & (DV_I_47_0_bit|DV_II_47_0_bit)) - mask &= ((0-((W[62]^(W[63]>>5))&(1<<0))) | ~(DV_I_47_0_bit|DV_II_47_0_bit)); - if (mask & (DV_I_46_0_bit|DV_II_46_0_bit)) - mask &= ((0-((W[61]^(W[62]>>5))&(1<<0))) | ~(DV_I_46_0_bit|DV_II_46_0_bit)); - mask &= ((0-((W[61]^(W[62]>>5))&(1<<2))) | ~(DV_I_46_2_bit|DV_II_46_2_bit)); - if (mask & (DV_I_45_0_bit|DV_II_45_0_bit)) - mask &= ((0-((W[60]^(W[61]>>5))&(1<<0))) | ~(DV_I_45_0_bit|DV_II_45_0_bit)); - if (mask & (DV_II_51_0_bit|DV_II_54_0_bit)) - mask &= (((((W[58]^W[59])>>29)&1)-1) | ~(DV_II_51_0_bit|DV_II_54_0_bit)); - if (mask & (DV_II_50_0_bit|DV_II_53_0_bit)) - mask &= (((((W[57]^W[58])>>29)&1)-1) | ~(DV_II_50_0_bit|DV_II_53_0_bit)); - if (mask & (DV_II_52_0_bit|DV_II_54_0_bit)) - mask &= ((((W[56]^(W[59]>>25))&(1<<4))-(1<<4)) | ~(DV_II_52_0_bit|DV_II_54_0_bit)); - if (mask & (DV_II_51_0_bit|DV_II_52_0_bit)) - mask &= ((0-(((W[56]^W[59])>>29)&1)) | ~(DV_II_51_0_bit|DV_II_52_0_bit)); - if (mask & (DV_II_49_0_bit|DV_II_52_0_bit)) - mask &= (((((W[56]^W[57])>>29)&1)-1) | ~(DV_II_49_0_bit|DV_II_52_0_bit)); - if (mask & (DV_II_51_0_bit|DV_II_53_0_bit)) - mask &= ((((W[55]^(W[58]>>25))&(1<<4))-(1<<4)) | ~(DV_II_51_0_bit|DV_II_53_0_bit)); - if (mask & (DV_II_50_0_bit|DV_II_52_0_bit)) - mask &= ((((W[54]^(W[57]>>25))&(1<<4))-(1<<4)) | ~(DV_II_50_0_bit|DV_II_52_0_bit)); - if (mask & (DV_II_49_0_bit|DV_II_51_0_bit)) - mask &= ((((W[53]^(W[56]>>25))&(1<<4))-(1<<4)) | ~(DV_II_49_0_bit|DV_II_51_0_bit)); - mask &= ((((W[51]^(W[50]>>5))&(1<<1))-(1<<1)) | ~(DV_I_50_2_bit|DV_II_46_2_bit)); - mask &= ((((W[48]^W[50])&(1<<6))-(1<<6)) | ~(DV_I_50_2_bit|DV_II_46_2_bit)); - if (mask & (DV_I_51_0_bit|DV_I_52_0_bit)) - mask &= ((0-(((W[48]^W[55])>>29)&1)) | ~(DV_I_51_0_bit|DV_I_52_0_bit)); - mask &= ((((W[47]^W[49])&(1<<6))-(1<<6)) | ~(DV_I_49_2_bit|DV_I_51_2_bit)); - mask &= ((((W[48]^(W[47]>>5))&(1<<1))-(1<<1)) | ~(DV_I_47_2_bit|DV_II_51_2_bit)); - mask &= ((((W[46]^W[48])&(1<<6))-(1<<6)) | ~(DV_I_48_2_bit|DV_I_50_2_bit)); - mask &= ((((W[47]^(W[46]>>5))&(1<<1))-(1<<1)) | ~(DV_I_46_2_bit|DV_II_50_2_bit)); - mask &= ((0-((W[44]^(W[45]>>5))&(1<<1))) | ~(DV_I_51_2_bit|DV_II_49_2_bit)); - mask &= ((((W[43]^W[45])&(1<<6))-(1<<6)) | ~(DV_I_47_2_bit|DV_I_49_2_bit)); - mask &= (((((W[42]^W[44])>>6)&1)-1) | ~(DV_I_46_2_bit|DV_I_48_2_bit)); - mask &= ((((W[43]^(W[42]>>5))&(1<<1))-(1<<1)) | ~(DV_II_46_2_bit|DV_II_51_2_bit)); - mask &= ((((W[42]^(W[41]>>5))&(1<<1))-(1<<1)) | ~(DV_I_51_2_bit|DV_II_50_2_bit)); - mask &= ((((W[41]^(W[40]>>5))&(1<<1))-(1<<1)) | ~(DV_I_50_2_bit|DV_II_49_2_bit)); - if (mask & (DV_I_52_0_bit|DV_II_51_0_bit)) - mask &= ((((W[39]^(W[43]>>25))&(1<<4))-(1<<4)) | ~(DV_I_52_0_bit|DV_II_51_0_bit)); - if (mask & (DV_I_51_0_bit|DV_II_50_0_bit)) - mask &= ((((W[38]^(W[42]>>25))&(1<<4))-(1<<4)) | ~(DV_I_51_0_bit|DV_II_50_0_bit)); - if (mask & (DV_I_48_2_bit|DV_I_51_2_bit)) - mask &= ((0-((W[37]^(W[38]>>5))&(1<<1))) | ~(DV_I_48_2_bit|DV_I_51_2_bit)); - if (mask & (DV_I_50_0_bit|DV_II_49_0_bit)) - mask &= ((((W[37]^(W[41]>>25))&(1<<4))-(1<<4)) | ~(DV_I_50_0_bit|DV_II_49_0_bit)); - if (mask & (DV_II_52_0_bit|DV_II_54_0_bit)) - mask &= ((0-((W[36]^W[38])&(1<<4))) | ~(DV_II_52_0_bit|DV_II_54_0_bit)); - mask &= ((0-((W[35]^(W[36]>>5))&(1<<1))) | ~(DV_I_46_2_bit|DV_I_49_2_bit)); - if (mask & (DV_I_51_0_bit|DV_II_47_0_bit)) - mask &= ((((W[35]^(W[39]>>25))&(1<<3))-(1<<3)) | ~(DV_I_51_0_bit|DV_II_47_0_bit)); -if (mask) { - - if (mask & DV_I_43_0_bit) - if ( - !((W[61]^(W[62]>>5)) & (1<<1)) - || !(!((W[59]^(W[63]>>25)) & (1<<5))) - || !((W[58]^(W[63]>>30)) & (1<<0)) - ) mask &= ~DV_I_43_0_bit; - if (mask & DV_I_44_0_bit) - if ( - !((W[62]^(W[63]>>5)) & (1<<1)) - || !(!((W[60]^(W[64]>>25)) & (1<<5))) - || !((W[59]^(W[64]>>30)) & (1<<0)) - ) mask &= ~DV_I_44_0_bit; - if (mask & DV_I_46_2_bit) - mask &= ((~((W[40]^W[42])>>2)) | ~DV_I_46_2_bit); - if (mask & DV_I_47_2_bit) - if ( - !((W[62]^(W[63]>>5)) & (1<<2)) - || !(!((W[41]^W[43]) & (1<<6))) - ) mask &= ~DV_I_47_2_bit; - if (mask & DV_I_48_2_bit) - if ( - !((W[63]^(W[64]>>5)) & (1<<2)) - || !(!((W[48]^(W[49]<<5)) & (1<<6))) - ) mask &= ~DV_I_48_2_bit; - if (mask & DV_I_49_2_bit) - if ( - !(!((W[49]^(W[50]<<5)) & (1<<6))) - || !((W[42]^W[50]) & (1<<1)) - || !(!((W[39]^(W[40]<<5)) & (1<<6))) - || !((W[38]^W[40]) & (1<<1)) - ) mask &= ~DV_I_49_2_bit; - if (mask & DV_I_50_0_bit) - mask &= ((((W[36]^W[37])<<7)) | ~DV_I_50_0_bit); - if (mask & DV_I_50_2_bit) - mask &= ((((W[43]^W[51])<<11)) | ~DV_I_50_2_bit); - if (mask & DV_I_51_0_bit) - mask &= ((((W[37]^W[38])<<9)) | ~DV_I_51_0_bit); - if (mask & DV_I_51_2_bit) - if ( - !(!((W[51]^(W[52]<<5)) & (1<<6))) - || !(!((W[49]^W[51]) & (1<<6))) - || !(!((W[37]^(W[37]>>5)) & (1<<1))) - || !(!((W[35]^(W[39]>>25)) & (1<<5))) - ) mask &= ~DV_I_51_2_bit; - if (mask & DV_I_52_0_bit) - mask &= ((((W[38]^W[39])<<11)) | ~DV_I_52_0_bit); - if (mask & DV_II_46_2_bit) - mask &= ((((W[47]^W[51])<<17)) | ~DV_II_46_2_bit); - if (mask & DV_II_48_0_bit) - if ( - !(!((W[36]^(W[40]>>25)) & (1<<3))) - || !((W[35]^(W[40]<<2)) & (1<<30)) - ) mask &= ~DV_II_48_0_bit; - if (mask & DV_II_49_0_bit) - if ( - !(!((W[37]^(W[41]>>25)) & (1<<3))) - || !((W[36]^(W[41]<<2)) & (1<<30)) - ) mask &= ~DV_II_49_0_bit; - if (mask & DV_II_49_2_bit) - if ( - !(!((W[53]^(W[54]<<5)) & (1<<6))) - || !(!((W[51]^W[53]) & (1<<6))) - || !((W[50]^W[54]) & (1<<1)) - || !(!((W[45]^(W[46]<<5)) & (1<<6))) - || !(!((W[37]^(W[41]>>25)) & (1<<5))) - || !((W[36]^(W[41]>>30)) & (1<<0)) - ) mask &= ~DV_II_49_2_bit; - if (mask & DV_II_50_0_bit) - if ( - !((W[55]^W[58]) & (1<<29)) - || !(!((W[38]^(W[42]>>25)) & (1<<3))) - || !((W[37]^(W[42]<<2)) & (1<<30)) - ) mask &= ~DV_II_50_0_bit; - if (mask & DV_II_50_2_bit) - if ( - !(!((W[54]^(W[55]<<5)) & (1<<6))) - || !(!((W[52]^W[54]) & (1<<6))) - || !((W[51]^W[55]) & (1<<1)) - || !((W[45]^W[47]) & (1<<1)) - || !(!((W[38]^(W[42]>>25)) & (1<<5))) - || !((W[37]^(W[42]>>30)) & (1<<0)) - ) mask &= ~DV_II_50_2_bit; - if (mask & DV_II_51_0_bit) - if ( - !(!((W[39]^(W[43]>>25)) & (1<<3))) - || !((W[38]^(W[43]<<2)) & (1<<30)) - ) mask &= ~DV_II_51_0_bit; - if (mask & DV_II_51_2_bit) - if ( - !(!((W[55]^(W[56]<<5)) & (1<<6))) - || !(!((W[53]^W[55]) & (1<<6))) - || !((W[52]^W[56]) & (1<<1)) - || !((W[46]^W[48]) & (1<<1)) - || !(!((W[39]^(W[43]>>25)) & (1<<5))) - || !((W[38]^(W[43]>>30)) & (1<<0)) - ) mask &= ~DV_II_51_2_bit; - if (mask & DV_II_52_0_bit) - if ( - !(!((W[59]^W[60]) & (1<<29))) - || !(!((W[40]^(W[44]>>25)) & (1<<3))) - || !(!((W[40]^(W[44]>>25)) & (1<<4))) - || !((W[39]^(W[44]<<2)) & (1<<30)) - ) mask &= ~DV_II_52_0_bit; - if (mask & DV_II_53_0_bit) - if ( - !((W[58]^W[61]) & (1<<29)) - || !(!((W[57]^(W[61]>>25)) & (1<<4))) - || !(!((W[41]^(W[45]>>25)) & (1<<3))) - || !(!((W[41]^(W[45]>>25)) & (1<<4))) - ) mask &= ~DV_II_53_0_bit; - if (mask & DV_II_54_0_bit) - if ( - !(!((W[58]^(W[62]>>25)) & (1<<4))) - || !(!((W[42]^(W[46]>>25)) & (1<<3))) - || !(!((W[42]^(W[46]>>25)) & (1<<4))) - ) mask &= ~DV_II_54_0_bit; - if (mask & DV_II_55_0_bit) - if ( - !(!((W[59]^(W[63]>>25)) & (1<<4))) - || !(!((W[57]^(W[59]>>25)) & (1<<4))) - || !(!((W[43]^(W[47]>>25)) & (1<<3))) - || !(!((W[43]^(W[47]>>25)) & (1<<4))) - ) mask &= ~DV_II_55_0_bit; - if (mask & DV_II_56_0_bit) - if ( - !(!((W[60]^(W[64]>>25)) & (1<<4))) - || !(!((W[44]^(W[48]>>25)) & (1<<3))) - || !(!((W[44]^(W[48]>>25)) & (1<<4))) - ) mask &= ~DV_II_56_0_bit; -} - - dvmask[0]=mask; -} - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/ubc_check.h r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/ubc_check.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash/sha1dc/ubc_check.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash/sha1dc/ubc_check.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/*** -* Copyright 2017 Marc Stevens , Dan Shumow -* Distributed under the MIT Software License. -* See accompanying file LICENSE.txt or copy at -* https://opensource.org/licenses/MIT -***/ - -/* -// this file was generated by the 'parse_bitrel' program in the tools section -// using the data files from directory 'tools/data/3565' -// -// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check -// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper) -// dm[80] is the expanded message block XOR-difference defined by the DV -// testt is the step to do the recompression from for collision detection -// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check -// -// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs -// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met -// thus one needs to do the recompression check for each DV that has its bit set -*/ - -#ifndef SHA1DC_UBC_CHECK_H -#define SHA1DC_UBC_CHECK_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef SHA1DC_NO_STANDARD_INCLUDES -#include -#endif - -#define DVMASKSIZE 1 -typedef struct { int dvType; int dvK; int dvB; int testt; int maski; int maskb; uint32_t dm[80]; } dv_info_t; -extern dv_info_t sha1_dvs[]; -void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]); - -#define DOSTORESTATE58 -#define DOSTORESTATE65 - -#define CHECK_DVMASK(_DVMASK) (0 != _DVMASK[0]) - -#if defined(__cplusplus) -} -#endif - -#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H -#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H -#endif - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash.c r-cran-git2r-0.22.1/src/libgit2/src/hash.c --- r-cran-git2r-0.21.0/src/libgit2/src/hash.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,6 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "hash.h" int git_hash_buf(git_oid *out, const void *data, size_t len) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hash.h r-cran-git2r-0.22.1/src/libgit2/src/hash.h --- r-cran-git2r-0.21.0/src/libgit2/src/hash.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hash.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_hash_h__ #define INCLUDE_hash_h__ +#include "common.h" + #include "git2/oid.h" typedef struct git_hash_prov git_hash_prov; @@ -40,4 +42,4 @@ int git_hash_buf(git_oid *out, const void *data, size_t len); int git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n); -#endif /* INCLUDE_hash_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/hashsig.c r-cran-git2r-0.22.1/src/libgit2/src/hashsig.c --- r-cran-git2r-0.21.0/src/libgit2/src/hashsig.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/hashsig.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,6 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "common.h" + #include "git2/sys/hashsig.h" #include "fileops.h" #include "util.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/ident.c r-cran-git2r-0.22.1/src/libgit2/src/ident.c --- r-cran-git2r-0.21.0/src/libgit2/src/ident.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/ident.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #include "git2/sys/filter.h" #include "filter.h" #include "buffer.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/idxmap.h r-cran-git2r-0.22.1/src/libgit2/src/idxmap.h --- r-cran-git2r-0.21.0/src/libgit2/src/idxmap.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/idxmap.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,8 +7,9 @@ #ifndef INCLUDE_idxmap_h__ #define INCLUDE_idxmap_h__ -#include #include "common.h" + +#include #include "git2/index.h" #define kmalloc git__malloc diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/ignore.c r-cran-git2r-0.22.1/src/libgit2/src/ignore.c --- r-cran-git2r-0.21.0/src/libgit2/src/ignore.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/ignore.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,14 @@ +/* + * 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. + */ + +#include "ignore.h" + #include "git2/ignore.h" #include "common.h" -#include "ignore.h" #include "attrcache.h" #include "path.h" #include "config.h" @@ -40,38 +48,42 @@ */ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg) { + int (*cmp)(const char *, const char *, size_t); git_attr_fnmatch *longer, *shorter; char *p; - if ((rule->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0 - && (neg->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0) { - - /* If lengths match we need to have an exact match */ - if (rule->length == neg->length) { - return strcmp(rule->pattern, neg->pattern) == 0; - } else if (rule->length < neg->length) { - shorter = rule; - longer = neg; - } else { - shorter = neg; - longer = rule; - } - - /* Otherwise, we need to check if the shorter - * rule is a basename only (that is, it contains - * no path separator) and, if so, if it - * matches the tail of the longer rule */ - p = longer->pattern + longer->length - shorter->length; - - if (p[-1] != '/') - return false; - if (memchr(shorter->pattern, '/', shorter->length) != NULL) - return false; - - return memcmp(p, shorter->pattern, shorter->length) == 0; + if ((rule->flags & GIT_ATTR_FNMATCH_NEGATIVE) != 0 + || (neg->flags & GIT_ATTR_FNMATCH_NEGATIVE) == 0) + return false; + + if (neg->flags & GIT_ATTR_FNMATCH_ICASE) + cmp = git__strncasecmp; + else + cmp = git__strncmp; + + /* If lengths match we need to have an exact match */ + if (rule->length == neg->length) { + return cmp(rule->pattern, neg->pattern, rule->length) == 0; + } else if (rule->length < neg->length) { + shorter = rule; + longer = neg; + } else { + shorter = neg; + longer = rule; } - return false; + /* Otherwise, we need to check if the shorter + * rule is a basename only (that is, it contains + * no path separator) and, if so, if it + * matches the tail of the longer rule */ + p = longer->pattern + longer->length - shorter->length; + + if (p[-1] != '/') + return false; + if (memchr(shorter->pattern, '/', shorter->length) != NULL) + return false; + + return cmp(p, shorter->pattern, shorter->length) == 0; } /** @@ -89,7 +101,7 @@ */ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match) { - int error = 0; + int error = 0, fnflags; size_t i; git_attr_fnmatch *rule; char *path; @@ -97,6 +109,10 @@ *out = 0; + fnflags = FNM_PATHNAME; + if (match->flags & GIT_ATTR_FNMATCH_ICASE) + fnflags |= FNM_IGNORECASE; + /* path of the file relative to the workdir, so we match the rules in subdirs */ if (match->containing_dir) { git_buf_puts(&buf, match->containing_dir); @@ -117,12 +133,12 @@ continue; } - /* - * When dealing with a directory, we add '/' so - * p_fnmatch() honours FNM_PATHNAME. Checking for LEADINGDIR - * alone isn't enough as that's also set for nagations, so we - * need to check that NEGATIVE is off. - */ + /* + * When dealing with a directory, we add '/' so + * p_fnmatch() honours FNM_PATHNAME. Checking for LEADINGDIR + * alone isn't enough as that's also set for nagations, so we + * need to check that NEGATIVE is off. + */ git_buf_clear(&buf); if (rule->containing_dir) { git_buf_puts(&buf, rule->containing_dir); @@ -136,7 +152,7 @@ if (error < 0) goto out; - if ((error = p_fnmatch(git_buf_cstr(&buf), path, FNM_PATHNAME)) < 0) { + if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) { giterr_set(GITERR_INVALID, "error matching pattern"); goto out; } @@ -199,8 +215,14 @@ scan = git__next_line(scan); - /* if a negative match doesn't actually do anything, throw it away */ - if (match->flags & GIT_ATTR_FNMATCH_NEGATIVE) + /* + * If a negative match doesn't actually do anything, + * throw it away. As we cannot always verify whether a + * rule containing wildcards negates another rule, we + * do not optimize away these rules, though. + * */ + if (match->flags & GIT_ATTR_FNMATCH_NEGATIVE + && !(match->flags & GIT_ATTR_FNMATCH_HASWILD)) error = does_negate_rule(&valid_rule, &attrs->rules, match); if (!error && valid_rule) @@ -508,6 +530,7 @@ git_ignores ignores; unsigned int i; git_attr_file *file; + git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN; assert(repo && ignored && pathname); @@ -516,7 +539,10 @@ memset(&path, 0, sizeof(path)); memset(&ignores, 0, sizeof(ignores)); - if ((error = git_attr_path__init(&path, pathname, workdir, GIT_DIR_FLAG_UNKNOWN)) < 0 || + if (git_repository_is_bare(repo)) + dir_flag = GIT_DIR_FLAG_FALSE; + + if ((error = git_attr_path__init(&path, pathname, workdir, dir_flag)) < 0 || (error = git_ignore__for_path(repo, path.path, &ignores)) < 0) goto cleanup; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/ignore.h r-cran-git2r-0.22.1/src/libgit2/src/ignore.h --- r-cran-git2r-0.21.0/src/libgit2/src/ignore.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/ignore.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_ignore_h__ #define INCLUDE_ignore_h__ +#include "common.h" + #include "repository.h" #include "vector.h" #include "attr_file.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/index.c r-cran-git2r-0.22.1/src/libgit2/src/index.c --- r-cran-git2r-0.21.0/src/libgit2/src/index.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/index.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,11 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "index.h" + #include -#include "common.h" #include "repository.h" -#include "index.h" #include "tree.h" #include "tree-cache.h" #include "hash.h" @@ -884,11 +884,13 @@ git_index_entry **out, git_repository *repo, const char *path, + struct stat *st, bool from_workdir) { size_t pathlen = strlen(path), alloclen; struct entry_internal *entry; unsigned int path_valid_flags = GIT_PATH_REJECT_INDEX_DEFAULTS; + uint16_t mode = 0; /* always reject placing `.git` in the index and directory traversal. * when requested, disallow platform-specific filenames and upgrade to @@ -896,8 +898,10 @@ */ if (from_workdir) path_valid_flags |= GIT_PATH_REJECT_WORKDIR_DEFAULTS; + if (st) + mode = st->st_mode; - if (!git_path_isvalid(repo, path, path_valid_flags)) { + if (!git_path_isvalid(repo, path, mode, path_valid_flags)) { giterr_set(GITERR_INDEX, "invalid path: '%s'", path); return -1; } @@ -922,15 +926,35 @@ { int error = 0; git_index_entry *entry = NULL; + git_buf path = GIT_BUF_INIT; struct stat st; git_oid oid; + git_repository *repo; if (INDEX_OWNER(index) == NULL) return create_index_error(-1, "could not initialize index entry. " "Index is not backed up by an existing repository."); - if (index_entry_create(&entry, INDEX_OWNER(index), rel_path, true) < 0) + /* + * FIXME: this is duplicated with the work in + * git_blob__create_from_paths. It should accept an optional stat + * structure so we can pass in the one we have to do here. + */ + repo = INDEX_OWNER(index); + if (git_repository__ensure_not_bare(repo, "create blob from file") < 0) + return GIT_EBAREREPO; + + if (git_buf_joinpath(&path, git_repository_workdir(repo), rel_path) < 0) + return -1; + + error = git_path_lstat(path.ptr, &st); + git_buf_free(&path); + + if (error < 0) + return error; + + if (index_entry_create(&entry, INDEX_OWNER(index), rel_path, &st, true) < 0) return -1; /* write the blob to disk and get the oid and stat info */ @@ -1016,7 +1040,7 @@ git_index *index, const git_index_entry *src) { - if (index_entry_create(out, INDEX_OWNER(index), src->path, false) < 0) + if (index_entry_create(out, INDEX_OWNER(index), src->path, NULL, false) < 0) return -1; index_entry_cpy(*out, src); @@ -1038,7 +1062,7 @@ git_index *index, const git_index_entry *src) { - if (index_entry_create(out, INDEX_OWNER(index), src->path, false) < 0) + if (index_entry_create(out, INDEX_OWNER(index), src->path, NULL, false) < 0) return -1; index_entry_cpy_nocache(*out, src); @@ -1396,12 +1420,16 @@ return ret; } -static bool valid_filemode(const int filemode) +GIT_INLINE(bool) is_file_or_link(const int filemode) { return (filemode == GIT_FILEMODE_BLOB || filemode == GIT_FILEMODE_BLOB_EXECUTABLE || - filemode == GIT_FILEMODE_LINK || - filemode == GIT_FILEMODE_COMMIT); + filemode == GIT_FILEMODE_LINK); +} + +GIT_INLINE(bool) valid_filemode(const int filemode) +{ + return (is_file_or_link(filemode) || filemode == GIT_FILEMODE_COMMIT); } int git_index_add_frombuffer( @@ -1419,7 +1447,7 @@ "could not initialize index entry. " "Index is not backed up by an existing repository."); - if (!valid_filemode(source_entry->mode)) { + if (!is_file_or_link(source_entry->mode)) { giterr_set(GITERR_INDEX, "invalid filemode"); return -1; } @@ -1457,9 +1485,6 @@ struct stat st; int error; - if (index_entry_create(&entry, INDEX_OWNER(index), path, true) < 0) - return -1; - if ((error = git_buf_joinpath(&abspath, git_repository_workdir(repo), path)) < 0) return error; @@ -1468,6 +1493,9 @@ return -1; } + if (index_entry_create(&entry, INDEX_OWNER(index), path, &st, true) < 0) + return -1; + git_index_entry__init_from_stat(entry, &st, !index->distrust_filemode); if ((error = git_repository_open(&sub, abspath.ptr)) < 0) @@ -1605,7 +1633,7 @@ assert(index && source_entry && source_entry->path); if (!valid_filemode(source_entry->mode)) { - giterr_set(GITERR_INDEX, "invalid filemode"); + giterr_set(GITERR_INDEX, "invalid entry mode"); return -1; } @@ -2295,8 +2323,9 @@ } } -static size_t read_entry( +static int read_entry( git_index_entry **out, + size_t *out_size, git_index *index, const void *buffer, size_t buffer_size, @@ -2310,7 +2339,7 @@ char *tmp_path = NULL; if (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size) - return 0; + return -1; /* buffer is not guaranteed to be aligned */ memcpy(&source, buffer, sizeof(struct entry_short)); @@ -2352,7 +2381,7 @@ path_end = memchr(path_ptr, '\0', buffer_size); if (path_end == NULL) - return 0; + return -1; path_length = path_end - path_ptr; } @@ -2360,19 +2389,24 @@ entry_size = index_entry_size(path_length, 0, entry.flags); entry.path = (char *)path_ptr; } else { - size_t varint_len; - size_t strip_len = git_decode_varint((const unsigned char *)path_ptr, - &varint_len); - size_t last_len = strlen(last); - size_t prefix_len = last_len - strip_len; - size_t suffix_len = strlen(path_ptr + varint_len); - size_t path_len; + size_t varint_len, last_len, prefix_len, suffix_len, path_len; + uintmax_t strip_len; + + strip_len = git_decode_varint((const unsigned char *)path_ptr, &varint_len); + last_len = strlen(last); - if (varint_len == 0) + if (varint_len == 0 || last_len < strip_len) return index_error_invalid("incorrect prefix length"); + prefix_len = last_len - strip_len; + suffix_len = strlen(path_ptr + varint_len); + GITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len); GITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1); + + if (path_len > GIT_PATH_MAX) + return index_error_invalid("unreasonable path length"); + tmp_path = git__malloc(path_len); GITERR_CHECK_ALLOC(tmp_path); @@ -2382,16 +2416,20 @@ entry.path = tmp_path; } + if (entry_size == 0) + return -1; + if (INDEX_FOOTER_SIZE + entry_size > buffer_size) - return 0; + return -1; if (index_entry_dup(out, index, &entry) < 0) { git__free(tmp_path); - return 0; + return -1; } git__free(tmp_path); - return entry_size; + *out_size = entry_size; + return 0; } static int read_header(struct index_header *dest, const void *buffer) @@ -2494,11 +2532,10 @@ /* Parse all the entries */ for (i = 0; i < header.entry_count && buffer_size > INDEX_FOOTER_SIZE; ++i) { - git_index_entry *entry; - size_t entry_size = read_entry(&entry, index, buffer, buffer_size, last); + git_index_entry *entry = NULL; + size_t entry_size; - /* 0 bytes read means an object corruption */ - if (entry_size == 0) { + if ((error = read_entry(&entry, &entry_size, index, buffer, buffer_size, last)) < 0) { error = index_error_invalid("invalid entry"); goto done; } @@ -2952,7 +2989,7 @@ if (git_buf_joinpath(&path, root, tentry->filename) < 0) return -1; - if (index_entry_create(&entry, INDEX_OWNER(data->index), path.ptr, false) < 0) + if (index_entry_create(&entry, INDEX_OWNER(data->index), path.ptr, NULL, false) < 0) return -1; entry->mode = tentry->attr; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/indexer.c r-cran-git2r-0.22.1/src/libgit2/src/indexer.c --- r-cran-git2r-0.21.0/src/libgit2/src/indexer.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/indexer.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,10 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "indexer.h" + #include "git2/indexer.h" #include "git2/object.h" -#include "common.h" #include "pack.h" #include "mwindow.h" #include "posix.h" @@ -186,13 +187,17 @@ return 0; } -static void hash_header(git_hash_ctx *ctx, git_off_t len, git_otype type) +static int hash_header(git_hash_ctx *ctx, git_off_t len, git_otype type) { char buffer[64]; size_t hdrlen; + int error; + + if ((error = git_odb__format_object_header(&hdrlen, + buffer, sizeof(buffer), (size_t)len, type)) < 0) + return error; - hdrlen = git_odb__format_object_header(buffer, sizeof(buffer), (size_t)len, type); - git_hash_update(ctx, buffer, hdrlen); + return git_hash_update(ctx, buffer, hdrlen); } static int hash_object_stream(git_indexer*idx, git_packfile_stream *stream) @@ -620,7 +625,10 @@ idx->have_delta = 1; } else { idx->have_delta = 0; - hash_header(&idx->hash_ctx, entry_size, type); + + error = hash_header(&idx->hash_ctx, entry_size, type); + if (error < 0) + goto on_error; } idx->have_stream = 1; @@ -843,6 +851,7 @@ static int resolve_deltas(git_indexer *idx, git_transfer_progress *stats) { unsigned int i; + int error; struct delta_info *delta; int progressed = 0, non_null = 0, progress_cb_result; @@ -857,8 +866,13 @@ non_null = 1; idx->off = delta->delta_off; - if (git_packfile_unpack(&obj, idx->pack, &idx->off) < 0) - continue; + if ((error = git_packfile_unpack(&obj, idx->pack, &idx->off)) < 0) { + if (error == GIT_PASSTHROUGH) { + /* We have not seen the base object, we'll try again later. */ + continue; + } + return -1; + } if (hash_and_save(idx, &obj, delta->delta_off) < 0) continue; @@ -950,6 +964,10 @@ giterr_set(GITERR_INDEXER, "unexpected data at the end of the pack"); return -1; } + if (idx->off + 20 > idx->pack->mwf.size) { + giterr_set(GITERR_INDEXER, "missing trailer at the end of the pack"); + return -1; + } packfile_trailer = git_mwindow_open(&idx->pack->mwf, &w, idx->pack->mwf.size - GIT_OID_RAWSZ, GIT_OID_RAWSZ, &left); if (packfile_trailer == NULL) { @@ -1118,6 +1136,9 @@ if (idx == NULL) return; + if (idx->have_stream) + git_packfile_stream_free(&idx->stream); + git_vector_free_deep(&idx->objects); if (idx->pack->idx_cache) { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/indexer.h r-cran-git2r-0.22.1/src/libgit2/src/indexer.h --- r-cran-git2r-0.21.0/src/libgit2/src/indexer.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/indexer.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,10 @@ #ifndef INCLUDE_indexer_h__ #define INCLUDE_indexer_h__ -extern int git_indexer__set_fsync(git_indexer *idx, int do_fsync); +#include "common.h" + +#include "git2/indexer.h" + +extern void git_indexer__set_fsync(git_indexer *idx, int do_fsync); #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/index.h r-cran-git2r-0.22.1/src/libgit2/src/index.h --- r-cran-git2r-0.21.0/src/libgit2/src/index.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/index.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_index_h__ #define INCLUDE_index_h__ +#include "common.h" + #include "fileops.h" #include "filebuf.h" #include "vector.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/integer.h r-cran-git2r-0.22.1/src/libgit2/src/integer.h --- r-cran-git2r-0.21.0/src/libgit2/src/integer.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/integer.h 2018-07-10 13:23:34.000000000 +0000 @@ -93,4 +93,4 @@ #endif -#endif /* INCLUDE_integer_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/iterator.c r-cran-git2r-0.22.1/src/libgit2/src/iterator.c --- r-cran-git2r-0.21.0/src/libgit2/src/iterator.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/iterator.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "iterator.h" + #include "tree.h" #include "index.h" @@ -22,6 +23,7 @@ #define iterator__has_been_accessed(I) iterator__flag(I,FIRST_ACCESS) #define iterator__honor_ignores(I) iterator__flag(I,HONOR_IGNORES) #define iterator__ignore_dot_git(I) iterator__flag(I,IGNORE_DOT_GIT) +#define iterator__descend_symlinks(I) iterator__flag(I,DESCEND_SYMLINKS) static void iterator_set_ignore_case(git_iterator *iter, bool ignore_case) @@ -1456,10 +1458,15 @@ filesystem_iterator_entry *entry) { iter->entry.ctime.seconds = entry->st.st_ctime; - iter->entry.ctime.nanoseconds = entry->st.st_ctime_nsec; - iter->entry.mtime.seconds = entry->st.st_mtime; + +#if defined(GIT_USE_NSEC) + iter->entry.ctime.nanoseconds = entry->st.st_ctime_nsec; iter->entry.mtime.nanoseconds = entry->st.st_mtime_nsec; +#else + iter->entry.ctime.nanoseconds = 0; + iter->entry.mtime.nanoseconds = 0; +#endif iter->entry.dev = entry->st.st_dev; iter->entry.ino = entry->st.st_ino; @@ -1490,10 +1497,41 @@ return 0; } +static int filesystem_iterator_is_dir( + bool *is_dir, + const filesystem_iterator *iter, + const filesystem_iterator_entry *entry) +{ + struct stat st; + git_buf fullpath = GIT_BUF_INIT; + int error = 0; + + if (S_ISDIR(entry->st.st_mode)) { + *is_dir = 1; + goto done; + } + + if (!iterator__descend_symlinks(iter) || !S_ISLNK(entry->st.st_mode)) { + *is_dir = 0; + goto done; + } + + if ((error = git_buf_joinpath(&fullpath, iter->root, entry->path)) < 0 || + (error = p_stat(fullpath.ptr, &st)) < 0) + goto done; + + *is_dir = S_ISDIR(st.st_mode); + +done: + git_buf_free(&fullpath); + return error; +} + static int filesystem_iterator_advance( const git_index_entry **out, git_iterator *i) { filesystem_iterator *iter = (filesystem_iterator *)i; + bool is_dir; int error = 0; iter->base.flags |= GIT_ITERATOR_FIRST_ACCESS; @@ -1518,7 +1556,10 @@ entry = frame->entries.contents[frame->next_idx]; frame->next_idx++; - if (S_ISDIR(entry->st.st_mode)) { + if ((error = filesystem_iterator_is_dir(&is_dir, iter, entry)) < 0) + break; + + if (is_dir) { if (iterator__do_autoexpand(iter)) { error = filesystem_iterator_frame_push(iter, entry); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/iterator.h r-cran-git2r-0.22.1/src/libgit2/src/iterator.h --- r-cran-git2r-0.21.0/src/libgit2/src/iterator.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/iterator.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_iterator_h__ #include "common.h" + #include "git2/index.h" #include "vector.h" #include "buffer.h" @@ -38,6 +39,8 @@ GIT_ITERATOR_DONT_PRECOMPOSE_UNICODE = (1u << 5), /** include conflicts */ GIT_ITERATOR_INCLUDE_CONFLICTS = (1u << 6), + /** descend into symlinked directories */ + GIT_ITERATOR_DESCEND_SYMLINKS = (1u << 7), } git_iterator_flag_t; typedef enum { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/map.h r-cran-git2r-0.22.1/src/libgit2/src/map.h --- r-cran-git2r-0.21.0/src/libgit2/src/map.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/map.h 2018-07-10 13:23:34.000000000 +0000 @@ -43,4 +43,4 @@ extern int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset); extern int p_munmap(git_map *map); -#endif /* INCLUDE_map_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/merge.c r-cran-git2r-0.22.1/src/libgit2/src/merge.c --- r-cran-git2r-0.21.0/src/libgit2/src/merge.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/merge.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,13 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "merge.h" + #include "posix.h" #include "buffer.h" #include "repository.h" #include "revwalk.h" #include "commit_list.h" -#include "merge.h" #include "path.h" #include "refs.h" #include "object.h" @@ -32,6 +32,8 @@ #include "commit.h" #include "oidarray.h" #include "merge_driver.h" +#include "oidmap.h" +#include "array.h" #include "git2/types.h" #include "git2/repository.h" @@ -1005,27 +1007,6 @@ size_t other_idx; }; -static int index_entry_similarity_exact( - git_repository *repo, - git_index_entry *a, - size_t a_idx, - git_index_entry *b, - size_t b_idx, - void **cache, - const git_merge_options *opts) -{ - GIT_UNUSED(repo); - GIT_UNUSED(a_idx); - GIT_UNUSED(b_idx); - GIT_UNUSED(cache); - GIT_UNUSED(opts); - - if (git_oid__cmp(&a->id, &b->id) == 0) - return 100; - - return 0; -} - static int index_entry_similarity_calc( void **out, git_repository *repo, @@ -1102,12 +1083,154 @@ return score; } -static int merge_diff_mark_similarity( +/* Tracks deletes by oid for merge_diff_mark_similarity_exact(). This is a +* non-shrinking queue where next_pos is the next position to dequeue. +*/ +typedef struct { + git_array_t(size_t) arr; + size_t next_pos; + size_t first_entry; +} deletes_by_oid_queue; + +static void deletes_by_oid_free(git_oidmap *map) { + deletes_by_oid_queue *queue; + + if (!map) + return; + + git_oidmap_foreach_value(map, queue, { + git_array_clear(queue->arr); + }); + git_oidmap_free(map); +} + +static int deletes_by_oid_enqueue(git_oidmap *map, git_pool* pool, const git_oid *id, size_t idx) { + khint_t pos; + deletes_by_oid_queue *queue; + size_t *array_entry; + int error; + + pos = git_oidmap_lookup_index(map, id); + if (!git_oidmap_valid_index(map, pos)) { + queue = git_pool_malloc(pool, sizeof(deletes_by_oid_queue)); + GITERR_CHECK_ALLOC(queue); + + git_array_init(queue->arr); + queue->next_pos = 0; + queue->first_entry = idx; + + git_oidmap_insert(map, id, queue, &error); + if (error < 0) + return -1; + } else { + queue = git_oidmap_value_at(map, pos); + array_entry = git_array_alloc(queue->arr); + GITERR_CHECK_ALLOC(array_entry); + *array_entry = idx; + } + + return 0; +} + +static int deletes_by_oid_dequeue(size_t *idx, git_oidmap *map, const git_oid *id) { + khint_t pos; + deletes_by_oid_queue *queue; + size_t *array_entry; + + pos = git_oidmap_lookup_index(map, id); + + if (!git_oidmap_valid_index(map, pos)) + return GIT_ENOTFOUND; + + queue = git_oidmap_value_at(map, pos); + + if (queue->next_pos == 0) { + *idx = queue->first_entry; + } else { + array_entry = git_array_get(queue->arr, queue->next_pos - 1); + if (array_entry == NULL) + return GIT_ENOTFOUND; + + *idx = *array_entry; + } + + queue->next_pos++; + return 0; +} + +static int merge_diff_mark_similarity_exact( + git_merge_diff_list *diff_list, + struct merge_diff_similarity *similarity_ours, + struct merge_diff_similarity *similarity_theirs) +{ + size_t i, j; + git_merge_diff *conflict_src, *conflict_tgt; + git_oidmap *ours_deletes_by_oid = NULL, *theirs_deletes_by_oid = NULL; + int error = 0; + + if (!(ours_deletes_by_oid = git_oidmap_alloc()) || + !(theirs_deletes_by_oid = git_oidmap_alloc())) { + error = -1; + goto done; + } + + /* Build a map of object ids to conflicts */ + git_vector_foreach(&diff_list->conflicts, i, conflict_src) { + /* Items can be the source of a rename iff they have an item in the + * ancestor slot and lack an item in the ours or theirs slot. */ + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->ancestor_entry)) + continue; + + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) { + error = deletes_by_oid_enqueue(ours_deletes_by_oid, &diff_list->pool, &conflict_src->ancestor_entry.id, i); + if (error < 0) + goto done; + } + + if (!GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) { + error = deletes_by_oid_enqueue(theirs_deletes_by_oid, &diff_list->pool, &conflict_src->ancestor_entry.id, i); + if (error < 0) + goto done; + } + } + + git_vector_foreach(&diff_list->conflicts, j, conflict_tgt) { + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->ancestor_entry)) + continue; + + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry)) { + if (deletes_by_oid_dequeue(&i, ours_deletes_by_oid, &conflict_tgt->our_entry.id) == 0) { + similarity_ours[i].similarity = 100; + similarity_ours[i].other_idx = j; + + similarity_ours[j].similarity = 100; + similarity_ours[j].other_idx = i; + } + } + + if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry)) { + if (deletes_by_oid_dequeue(&i, theirs_deletes_by_oid, &conflict_tgt->their_entry.id) == 0) { + similarity_theirs[i].similarity = 100; + similarity_theirs[i].other_idx = j; + + similarity_theirs[j].similarity = 100; + similarity_theirs[j].other_idx = i; + } + } + } + +done: + deletes_by_oid_free(ours_deletes_by_oid); + deletes_by_oid_free(theirs_deletes_by_oid); + + return error; +} + +static int merge_diff_mark_similarity_inexact( git_repository *repo, git_merge_diff_list *diff_list, struct merge_diff_similarity *similarity_ours, struct merge_diff_similarity *similarity_theirs, - int (*similarity_fn)(git_repository *, git_index_entry *, size_t, git_index_entry *, size_t, void **, const git_merge_options *), void **cache, const git_merge_options *opts) { @@ -1132,7 +1255,7 @@ if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->our_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->our_entry)) { - similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->our_entry, our_idx, cache, opts); + similarity = index_entry_similarity_inexact(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->our_entry, our_idx, cache, opts); if (similarity == GIT_EBUFS) continue; @@ -1158,7 +1281,7 @@ if (GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_tgt->their_entry) && !GIT_MERGE_INDEX_ENTRY_EXISTS(conflict_src->their_entry)) { - similarity = similarity_fn(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->their_entry, their_idx, cache, opts); + similarity = index_entry_similarity_inexact(repo, &conflict_src->ancestor_entry, i, &conflict_tgt->their_entry, their_idx, cache, opts); if (similarity > similarity_theirs[i].similarity && similarity > similarity_theirs[j].similarity) { @@ -1396,11 +1519,10 @@ /* Calculate similarity between items that were deleted from the ancestor * and added in the other branch. */ - if ((error = merge_diff_mark_similarity(repo, diff_list, similarity_ours, - similarity_theirs, index_entry_similarity_exact, NULL, opts)) < 0) + if ((error = merge_diff_mark_similarity_exact(diff_list, similarity_ours, similarity_theirs)) < 0) goto done; - if (diff_list->conflicts.length <= opts->target_limit) { + if (opts->rename_threshold < 100 && diff_list->conflicts.length <= opts->target_limit) { GITERR_CHECK_ALLOC_MULTIPLY(&cache_size, diff_list->conflicts.length, 3); cache = git__calloc(cache_size, sizeof(void *)); GITERR_CHECK_ALLOC(cache); @@ -1410,9 +1532,8 @@ if (src_count > opts->target_limit || tgt_count > opts->target_limit) { /* TODO: report! */ } else { - if ((error = merge_diff_mark_similarity( - repo, diff_list, similarity_ours, similarity_theirs, - index_entry_similarity_inexact, cache, opts)) < 0) + if ((error = merge_diff_mark_similarity_inexact( + repo, diff_list, similarity_ours, similarity_theirs, cache, opts)) < 0) goto done; } } @@ -1954,6 +2075,7 @@ file_opts.our_label = "Temporary merge branch 1"; file_opts.their_label = "Temporary merge branch 2"; file_opts.flags |= GIT_MERGE_FILE_FAVOR__CONFLICTED; + file_opts.marker_size = GIT_MERGE_CONFLICT_MARKER_SIZE + 2; } diff_list = git_merge_diff_list__alloc(repo); @@ -2141,7 +2263,7 @@ git_oidarray bases = {0}; git_annotated_commit *base = NULL, *other = NULL, *new_base = NULL; git_merge_options opts = GIT_MERGE_OPTIONS_INIT; - size_t i; + size_t i, base_count; int error; *out = NULL; @@ -2149,17 +2271,27 @@ if (given_opts) memcpy(&opts, given_opts, sizeof(git_merge_options)); - if ((error = insert_head_ids(&head_ids, one)) < 0 || - (error = insert_head_ids(&head_ids, two)) < 0) + /* With more than two commits, merge_bases_many finds the base of + * the first commit and a hypothetical merge of the others. Since + * "one" may itself be a virtual commit, which insert_head_ids + * substitutes multiple ancestors for, it needs to be added + * after "two" which is always a single real commit. + */ + if ((error = insert_head_ids(&head_ids, two)) < 0 || + (error = insert_head_ids(&head_ids, one)) < 0 || + (error = git_merge_bases_many(&bases, repo, + head_ids.size, head_ids.ptr)) < 0) goto done; - if ((error = git_merge_bases_many(&bases, repo, - head_ids.size, head_ids.ptr)) < 0 || - (error = git_annotated_commit_lookup(&base, repo, &bases.ids[0])) < 0 || - (opts.flags & GIT_MERGE_NO_RECURSIVE)) + base_count = (opts.flags & GIT_MERGE_NO_RECURSIVE) ? 0 : bases.count; + + if (base_count) + git_oidarray__reverse(&bases); + + if ((error = git_annotated_commit_lookup(&base, repo, &bases.ids[0])) < 0) goto done; - for (i = 1; i < bases.count; i++) { + for (i = 1; i < base_count; i++) { recursion_level++; if (opts.recursion_limit && recursion_level > opts.recursion_limit) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/merge_driver.c r-cran-git2r-0.22.1/src/libgit2/src/merge_driver.c --- r-cran-git2r-0.21.0/src/libgit2/src/merge_driver.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/merge_driver.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,11 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "merge_driver.h" + #include "vector.h" #include "global.h" #include "merge.h" -#include "merge_driver.h" #include "git2/merge.h" #include "git2/sys/merge.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/merge_driver.h r-cran-git2r-0.22.1/src/libgit2/src/merge_driver.h --- r-cran-git2r-0.21.0/src/libgit2/src/merge_driver.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/merge_driver.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_merge_driver_h__ #define INCLUDE_merge_driver_h__ +#include "common.h" + #include "git2/merge.h" #include "git2/index.h" #include "git2/sys/merge.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/merge_file.c r-cran-git2r-0.22.1/src/libgit2/src/merge_file.c --- r-cran-git2r-0.21.0/src/libgit2/src/merge_file.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/merge_file.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "repository.h" #include "posix.h" #include "fileops.h" @@ -125,6 +126,8 @@ if (options.flags & GIT_MERGE_FILE_DIFF_MINIMAL) xmparam.xpp.flags |= XDF_NEED_MINIMAL; + xmparam.marker_size = options.marker_size; + if ((xdl_result = xdl_merge(&ancestor_mmfile, &our_mmfile, &their_mmfile, &xmparam, &mmbuffer)) < 0) { giterr_set(GITERR_MERGE, "failed to merge files"); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/merge.h r-cran-git2r-0.22.1/src/libgit2/src/merge.h --- r-cran-git2r-0.21.0/src/libgit2/src/merge.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/merge.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_merge_h__ #define INCLUDE_merge_h__ +#include "common.h" + #include "vector.h" #include "commit_list.h" #include "pool.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/message.h r-cran-git2r-0.22.1/src/libgit2/src/message.h --- r-cran-git2r-0.21.0/src/libgit2/src/message.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/message.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,9 +7,11 @@ #ifndef INCLUDE_message_h__ #define INCLUDE_message_h__ +#include "common.h" + #include "git2/message.h" #include "buffer.h" int git_message__prettify(git_buf *message_out, const char *message, int strip_comments); -#endif /* INCLUDE_message_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/mwindow.c r-cran-git2r-0.22.1/src/libgit2/src/mwindow.c --- r-cran-git2r-0.21.0/src/libgit2/src/mwindow.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/mwindow.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "mwindow.h" + #include "vector.h" #include "fileops.h" #include "map.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/mwindow.h r-cran-git2r-0.22.1/src/libgit2/src/mwindow.h --- r-cran-git2r-0.21.0/src/libgit2/src/mwindow.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/mwindow.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,8 @@ #ifndef INCLUDE_mwindow__ #define INCLUDE_mwindow__ +#include "common.h" + #include "map.h" #include "vector.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/netops.c r-cran-git2r-0.22.1/src/libgit2/src/netops.c --- r-cran-git2r-0.21.0/src/libgit2/src/netops.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/netops.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,11 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "netops.h" + #include #include "git2/errors.h" -#include "common.h" -#include "netops.h" #include "posix.h" #include "buffer.h" #include "http_parser.h" @@ -206,83 +206,96 @@ git__free(d->pass); d->pass = NULL; } -#define hex2c(c) ((c | 32) % 39 - 9) -static char* unescape(char *str) -{ - int x, y; - int len = (int)strlen(str); - - for (x=y=0; str[y]; ++x, ++y) { - if ((str[x] = str[y]) == '%') { - if (y < len-2 && isxdigit(str[y+1]) && isxdigit(str[y+2])) { - str[x] = (hex2c(str[y+1]) << 4) + hex2c(str[y+2]); - y += 2; - } - } - } - str[x] = '\0'; - return str; -} - int gitno_extract_url_parts( - char **host, - char **port, - char **path, - char **username, - char **password, - const char *url, - const char *default_port) + char **host_out, + char **port_out, + char **path_out, + char **username_out, + char **password_out, + const char *url, + const char *default_port) { struct http_parser_url u = {0}; - const char *_host, *_port, *_path, *_userinfo; + bool has_host, has_port, has_path, has_userinfo; + git_buf host = GIT_BUF_INIT, + port = GIT_BUF_INIT, + path = GIT_BUF_INIT, + username = GIT_BUF_INIT, + password = GIT_BUF_INIT; + int error = 0; if (http_parser_parse_url(url, strlen(url), false, &u)) { giterr_set(GITERR_NET, "malformed URL '%s'", url); - return GIT_EINVALIDSPEC; + error = GIT_EINVALIDSPEC; + goto done; } - _host = url+u.field_data[UF_HOST].off; - _port = url+u.field_data[UF_PORT].off; - _path = url+u.field_data[UF_PATH].off; - _userinfo = url+u.field_data[UF_USERINFO].off; - - if (u.field_set & (1 << UF_HOST)) { - *host = git__substrdup(_host, u.field_data[UF_HOST].len); - GITERR_CHECK_ALLOC(*host); + has_host = !!(u.field_set & (1 << UF_HOST)); + has_port = !!(u.field_set & (1 << UF_PORT)); + has_path = !!(u.field_set & (1 << UF_PATH)); + has_userinfo = !!(u.field_set & (1 << UF_USERINFO)); + + if (has_host) { + const char *url_host = url + u.field_data[UF_HOST].off; + size_t url_host_len = u.field_data[UF_HOST].len; + git_buf_decode_percent(&host, url_host, url_host_len); } - if (u.field_set & (1 << UF_PORT)) - *port = git__substrdup(_port, u.field_data[UF_PORT].len); - else - *port = git__strdup(default_port); - GITERR_CHECK_ALLOC(*port); - - if (path) { - if (u.field_set & (1 << UF_PATH)) { - *path = git__substrdup(_path, u.field_data[UF_PATH].len); - GITERR_CHECK_ALLOC(*path); - } else { - git__free(*port); - *port = NULL; - git__free(*host); - *host = NULL; - giterr_set(GITERR_NET, "invalid url, missing path"); - return GIT_EINVALIDSPEC; - } + if (has_port) { + const char *url_port = url + u.field_data[UF_PORT].off; + size_t url_port_len = u.field_data[UF_PORT].len; + git_buf_put(&port, url_port, url_port_len); + } else { + git_buf_puts(&port, default_port); } - if (u.field_set & (1 << UF_USERINFO)) { - const char *colon = memchr(_userinfo, ':', u.field_data[UF_USERINFO].len); + if (has_path && path_out) { + const char *url_path = url + u.field_data[UF_PATH].off; + size_t url_path_len = u.field_data[UF_PATH].len; + git_buf_decode_percent(&path, url_path, url_path_len); + } else if (path_out) { + giterr_set(GITERR_NET, "invalid url, missing path"); + error = GIT_EINVALIDSPEC; + goto done; + } + + if (has_userinfo) { + const char *url_userinfo = url + u.field_data[UF_USERINFO].off; + size_t url_userinfo_len = u.field_data[UF_USERINFO].len; + const char *colon = memchr(url_userinfo, ':', url_userinfo_len); + if (colon) { - *username = unescape(git__substrdup(_userinfo, colon - _userinfo)); - *password = unescape(git__substrdup(colon+1, u.field_data[UF_USERINFO].len - (colon+1-_userinfo))); - GITERR_CHECK_ALLOC(*password); + const char *url_username = url_userinfo; + size_t url_username_len = colon - url_userinfo; + const char *url_password = colon + 1; + size_t url_password_len = url_userinfo_len - (url_username_len + 1); + + git_buf_decode_percent(&username, url_username, url_username_len); + git_buf_decode_percent(&password, url_password, url_password_len); } else { - *username = git__substrdup(_userinfo, u.field_data[UF_USERINFO].len); + git_buf_decode_percent(&username, url_userinfo, url_userinfo_len); } - GITERR_CHECK_ALLOC(*username); - } - return 0; + if (git_buf_oom(&host) || + git_buf_oom(&port) || + git_buf_oom(&path) || + git_buf_oom(&username) || + git_buf_oom(&password)) + return -1; + + *host_out = git_buf_detach(&host); + *port_out = git_buf_detach(&port); + if (path_out) + *path_out = git_buf_detach(&path); + *username_out = git_buf_detach(&username); + *password_out = git_buf_detach(&password); + +done: + git_buf_free(&host); + git_buf_free(&port); + git_buf_free(&path); + git_buf_free(&username); + git_buf_free(&password); + return error; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/netops.h r-cran-git2r-0.22.1/src/libgit2/src/netops.h --- r-cran-git2r-0.21.0/src/libgit2/src/netops.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/netops.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,8 +7,9 @@ #ifndef INCLUDE_netops_h__ #define INCLUDE_netops_h__ -#include "posix.h" #include "common.h" + +#include "posix.h" #include "stream.h" #ifdef GIT_OPENSSL diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/notes.c r-cran-git2r-0.22.1/src/libgit2/src/notes.c --- r-cran-git2r-0.21.0/src/libgit2/src/notes.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/notes.c 2018-07-10 13:23:34.000000000 +0000 @@ -268,7 +268,9 @@ GIT_FILEMODE_BLOB); } -static int note_write(git_oid *out, +static int note_write( + git_oid *notes_commit_out, + git_oid *notes_blob_out, git_repository *repo, const git_signature *author, const git_signature *committer, @@ -294,13 +296,17 @@ insert_note_in_tree_enotfound_cb)) < 0) goto cleanup; - if (out) - git_oid_cpy(out, &oid); + if (notes_blob_out) + git_oid_cpy(notes_blob_out, &oid); + error = git_commit_create(&oid, repo, notes_ref, author, committer, NULL, GIT_NOTES_DEFAULT_MSG_ADD, tree, *parents == NULL ? 0 : 1, (const git_commit **) parents); + if (notes_commit_out) + git_oid_cpy(notes_commit_out, &oid); + cleanup: git_tree_free(tree); return error; @@ -363,7 +369,9 @@ return error; } -static int note_remove(git_repository *repo, +static int note_remove( + git_oid *notes_commit_out, + git_repository *repo, const git_signature *author, const git_signature *committer, const char *notes_ref, git_tree *tree, const char *target, git_commit **parents) @@ -383,6 +391,12 @@ *parents == NULL ? 0 : 1, (const git_commit **) parents); + if (error < 0) + goto cleanup; + + if (notes_commit_out) + git_oid_cpy(notes_commit_out, &oid); + cleanup: git_tree_free(tree_after_removal); return error; @@ -410,8 +424,7 @@ return note_get_default_ref(out, repo); } -static int retrieve_note_tree_and_commit( - git_tree **tree_out, +static int retrieve_note_commit( git_commit **commit_out, char **notes_ref_out, git_repository *repo, @@ -429,34 +442,82 @@ if (git_commit_lookup(commit_out, repo, &oid) < 0) return error; - if ((error = git_commit_tree(tree_out, *commit_out)) < 0) - return error; - return 0; } +int git_note_commit_read( + git_note **out, + git_repository *repo, + git_commit *notes_commit, + const git_oid *oid) +{ + int error; + git_tree *tree = NULL; + char target[GIT_OID_HEXSZ + 1]; + + git_oid_tostr(target, sizeof(target), oid); + + if ((error = git_commit_tree(&tree, notes_commit)) < 0) + goto cleanup; + + error = note_lookup(out, repo, notes_commit, tree, target); + +cleanup: + git_tree_free(tree); + return error; +} + int git_note_read(git_note **out, git_repository *repo, const char *notes_ref_in, const git_oid *oid) { int error; - char *target = NULL, *notes_ref = NULL; - git_tree *tree = NULL; + char *notes_ref = NULL; git_commit *commit = NULL; - target = git_oid_allocfmt(oid); - GITERR_CHECK_ALLOC(target); + error = retrieve_note_commit(&commit, ¬es_ref, repo, notes_ref_in); + + if (error < 0) + goto cleanup; - if (!(error = retrieve_note_tree_and_commit( - &tree, &commit, ¬es_ref, repo, notes_ref_in))) - error = note_lookup(out, repo, commit, tree, target); + error = git_note_commit_read(out, repo, commit, oid); +cleanup: git__free(notes_ref); - git__free(target); - git_tree_free(tree); git_commit_free(commit); return error; } +int git_note_commit_create( + git_oid *notes_commit_out, + git_oid *notes_blob_out, + git_repository *repo, + git_commit *parent, + const git_signature *author, + const git_signature *committer, + const git_oid *oid, + const char *note, + int allow_note_overwrite) +{ + int error; + git_tree *tree = NULL; + char target[GIT_OID_HEXSZ + 1]; + + git_oid_tostr(target, sizeof(target), oid); + + if (parent != NULL && (error = git_commit_tree(&tree, parent)) < 0) + goto cleanup; + + error = note_write(notes_commit_out, notes_blob_out, repo, author, + committer, NULL, note, tree, target, &parent, allow_note_overwrite); + + if (error < 0) + goto cleanup; + +cleanup: + git_tree_free(tree); + return error; +} + int git_note_create( git_oid *out, git_repository *repo, @@ -468,25 +529,59 @@ int allow_note_overwrite) { int error; - char *target = NULL, *notes_ref = NULL; - git_commit *commit = NULL; - git_tree *tree = NULL; - - target = git_oid_allocfmt(oid); - GITERR_CHECK_ALLOC(target); + char *notes_ref = NULL; + git_commit *existing_notes_commit = NULL; + git_reference *ref = NULL; + git_oid notes_blob_oid, notes_commit_oid; - error = retrieve_note_tree_and_commit(&tree, &commit, ¬es_ref, repo, notes_ref_in); + error = retrieve_note_commit(&existing_notes_commit, ¬es_ref, + repo, notes_ref_in); if (error < 0 && error != GIT_ENOTFOUND) goto cleanup; - error = note_write(out, repo, author, committer, notes_ref, - note, tree, target, &commit, allow_note_overwrite); + error = git_note_commit_create(¬es_commit_oid, + ¬es_blob_oid, + repo, existing_notes_commit, author, + committer, oid, note, + allow_note_overwrite); + if (error < 0) + goto cleanup; + + error = git_reference_create(&ref, repo, notes_ref, + ¬es_commit_oid, 1, NULL); + + if (out != NULL) + git_oid_cpy(out, ¬es_blob_oid); cleanup: git__free(notes_ref); - git__free(target); - git_commit_free(commit); + git_commit_free(existing_notes_commit); + git_reference_free(ref); + return error; +} + +int git_note_commit_remove( + git_oid *notes_commit_out, + git_repository *repo, + git_commit *notes_commit, + const git_signature *author, + const git_signature *committer, + const git_oid *oid) +{ + int error; + git_tree *tree = NULL; + char target[GIT_OID_HEXSZ + 1]; + + git_oid_tostr(target, sizeof(target), oid); + + if ((error = git_commit_tree(&tree, notes_commit)) < 0) + goto cleanup; + + error = note_remove(notes_commit_out, + repo, author, committer, NULL, tree, target, ¬es_commit); + +cleanup: git_tree_free(tree); return error; } @@ -496,22 +591,29 @@ const git_oid *oid) { int error; - char *target = NULL, *notes_ref; - git_commit *commit = NULL; - git_tree *tree = NULL; + char *notes_ref_target = NULL; + git_commit *existing_notes_commit = NULL; + git_oid new_notes_commit; + git_reference *notes_ref = NULL; - target = git_oid_allocfmt(oid); - GITERR_CHECK_ALLOC(target); + error = retrieve_note_commit(&existing_notes_commit, ¬es_ref_target, + repo, notes_ref_in); - if (!(error = retrieve_note_tree_and_commit( - &tree, &commit, ¬es_ref, repo, notes_ref_in))) - error = note_remove( - repo, author, committer, notes_ref, tree, target, &commit); + if (error < 0) + goto cleanup; - git__free(notes_ref); - git__free(target); - git_commit_free(commit); - git_tree_free(tree); + error = git_note_commit_remove(&new_notes_commit, repo, + existing_notes_commit, author, committer, oid); + if (error < 0) + goto cleanup; + + error = git_reference_create(¬es_ref, repo, notes_ref_target, + &new_notes_commit, 1, NULL); + +cleanup: + git__free(notes_ref_target); + git_reference_free(notes_ref); + git_commit_free(existing_notes_commit); return error; } @@ -639,7 +741,6 @@ return error; } - void git_note_iterator_free(git_note_iterator *it) { if (it == NULL) @@ -648,6 +749,24 @@ git_iterator_free(it); } +int git_note_commit_iterator_new( + git_note_iterator **it, + git_commit *notes_commit) +{ + int error; + git_tree *tree; + + if ((error = git_commit_tree(&tree, notes_commit)) < 0) + goto cleanup; + + if ((error = git_iterator_for_tree(it, tree, NULL)) < 0) + git_iterator_free(*it); + +cleanup: + git_tree_free(tree); + + return error; +} int git_note_iterator_new( git_note_iterator **it, @@ -656,19 +775,16 @@ { int error; git_commit *commit = NULL; - git_tree *tree = NULL; char *notes_ref; - error = retrieve_note_tree_and_commit(&tree, &commit, ¬es_ref, repo, notes_ref_in); + error = retrieve_note_commit(&commit, ¬es_ref, repo, notes_ref_in); if (error < 0) goto cleanup; - if ((error = git_iterator_for_tree(it, tree, NULL)) < 0) - git_iterator_free(*it); + error = git_note_commit_iterator_new(it, commit); cleanup: git__free(notes_ref); - git_tree_free(tree); git_commit_free(commit); return error; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/notes.h r-cran-git2r-0.22.1/src/libgit2/src/notes.h --- r-cran-git2r-0.21.0/src/libgit2/src/notes.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/notes.h 2018-07-10 13:23:34.000000000 +0000 @@ -29,4 +29,4 @@ char *message; }; -#endif /* INCLUDE_notes_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/object_api.c r-cran-git2r-0.22.1/src/libgit2/src/object_api.c --- r-cran-git2r-0.21.0/src/libgit2/src/object_api.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/object_api.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,11 +4,12 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "git2/object.h" #include "common.h" -#include "repository.h" +#include "git2/object.h" + +#include "repository.h" #include "commit.h" #include "tree.h" #include "blob.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/object.c r-cran-git2r-0.22.1/src/libgit2/src/object.c --- r-cran-git2r-0.21.0/src/libgit2/src/object.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/object.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,9 +4,11 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "object.h" + #include "git2/object.h" -#include "common.h" #include "repository.h" #include "commit.h" @@ -234,13 +236,22 @@ git_otype git_object_string2type(const char *str) { + if (!str) + return GIT_OBJ_BAD; + + return git_object_stringn2type(str, strlen(str)); +} + +git_otype git_object_stringn2type(const char *str, size_t len) +{ size_t i; - if (!str || !*str) + if (!str || !len || !*str) return GIT_OBJ_BAD; for (i = 0; i < ARRAY_SIZE(git_objects_table); i++) - if (!strcmp(str, git_objects_table[i].str)) + if (*git_objects_table[i].str && + !git__prefixncmp(str, len, git_objects_table[i].str)) return (git_otype)i; return GIT_OBJ_BAD; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/object.h r-cran-git2r-0.22.1/src/libgit2/src/object.h --- r-cran-git2r-0.21.0/src/libgit2/src/object.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/object.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_object_h__ #define INCLUDE_object_h__ +#include "common.h" + #include "repository.h" extern bool git_object__strict_input_validation; @@ -28,6 +30,8 @@ int git_object__resolve_to_type(git_object **obj, git_otype type); +git_otype git_object_stringn2type(const char *str, size_t len); + int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end, const char *header); void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/odb.c r-cran-git2r-0.22.1/src/libgit2/src/odb.c --- r-cran-git2r-0.21.0/src/libgit2/src/odb.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/odb.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,13 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "odb.h" + #include #include "git2/object.h" #include "git2/sys/odb_backend.h" #include "fileops.h" #include "hash.h" -#include "odb.h" #include "delta.h" #include "filter.h" #include "repository.h" @@ -53,6 +53,7 @@ static int odb_otype_fast(git_otype *type_p, git_odb *db, const git_oid *id); static int load_alternates(git_odb *odb, const char *objects_dir, int alternate_depth); +static int error_null_oid(int error, const char *message); static git_otype odb_hardcoded_type(const git_oid *id) { @@ -65,50 +66,75 @@ return GIT_OBJ_BAD; } -static int odb_read_hardcoded(git_rawobj *raw, const git_oid *id) +static int odb_read_hardcoded(bool *found, git_rawobj *raw, const git_oid *id) { - git_otype type = odb_hardcoded_type(id); - if (type == GIT_OBJ_BAD) - return -1; + git_otype type; + + *found = false; + + if ((type = odb_hardcoded_type(id)) == GIT_OBJ_BAD) + return 0; raw->type = type; raw->len = 0; raw->data = git__calloc(1, sizeof(uint8_t)); + GITERR_CHECK_ALLOC(raw->data); + + *found = true; return 0; } -int git_odb__format_object_header(char *hdr, size_t n, git_off_t obj_len, git_otype obj_type) +int git_odb__format_object_header( + size_t *written, + char *hdr, + size_t hdr_size, + git_off_t obj_len, + git_otype obj_type) { const char *type_str = git_object_type2string(obj_type); - int len = p_snprintf(hdr, n, "%s %lld", type_str, (long long)obj_len); - assert(len > 0 && len <= (int)n); - return len+1; + int hdr_max = (hdr_size > INT_MAX-2) ? (INT_MAX-2) : (int)hdr_size; + int len; + + len = p_snprintf(hdr, hdr_max, "%s %lld", type_str, (long long)obj_len); + + if (len < 0 || len >= hdr_max) { + giterr_set(GITERR_OS, "object header creation failed"); + return -1; + } + + *written = (size_t)(len + 1); + return 0; } int git_odb__hashobj(git_oid *id, git_rawobj *obj) { git_buf_vec vec[2]; char header[64]; - int hdrlen; + size_t hdrlen; + int error; assert(id && obj); - if (!git_object_typeisloose(obj->type)) + if (!git_object_typeisloose(obj->type)) { + giterr_set(GITERR_INVALID, "invalid object type"); return -1; + } - if (!obj->data && obj->len != 0) + if (!obj->data && obj->len != 0) { + giterr_set(GITERR_INVALID, "invalid object"); return -1; + } - hdrlen = git_odb__format_object_header(header, sizeof(header), obj->len, obj->type); + if ((error = git_odb__format_object_header(&hdrlen, + header, sizeof(header), obj->len, obj->type)) < 0) + return error; vec[0].data = header; vec[0].len = hdrlen; vec[1].data = obj->data; vec[1].len = obj->len; - git_hash_vec(id, vec, 2); - - return 0; + return git_hash_vec(id, vec, 2); } @@ -171,7 +197,7 @@ int git_odb__hashfd(git_oid *out, git_file fd, size_t size, git_otype type) { - int hdr_len; + size_t hdr_len; char hdr[64], buffer[FILEIO_BUFSIZE]; git_hash_ctx ctx; ssize_t read_len = 0; @@ -183,9 +209,11 @@ } if ((error = git_hash_ctx_init(&ctx)) < 0) - return -1; + return error; - hdr_len = git_odb__format_object_header(hdr, sizeof(hdr), size, type); + if ((error = git_odb__format_object_header(&hdr_len, hdr, + sizeof(hdr), size, type)) < 0) + goto done; if ((error = git_hash_update(&ctx, hdr, hdr_len)) < 0) goto done; @@ -341,8 +369,7 @@ { fake_wstream *stream = (fake_wstream *)_stream; - if (stream->written + len > stream->size) - return -1; + assert(stream->written + len <= stream->size); memcpy(stream->buffer + stream->written, data, len); stream->written += len; @@ -735,6 +762,9 @@ assert(db && id); + if (git_oid_iszero(id)) + return 0; + if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { git_odb_object_free(object); return 1; @@ -796,7 +826,7 @@ git_oid *out, git_odb *db, const git_oid *short_id, size_t len) { int error; - git_oid key = {{0}}; + git_oid key = {{0}}; assert(db && short_id); @@ -958,6 +988,11 @@ assert(db && id && out && len_p && type_p); + *out = NULL; + + if (git_oid_iszero(id)) + return error_null_oid(GIT_ENOTFOUND, "cannot read object"); + if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { *len_p = object->cached.size; *type_p = object->cached.type; @@ -965,7 +1000,6 @@ return 0; } - *out = NULL; error = odb_read_header_1(len_p, type_p, db, id, false); if (error == GIT_ENOTFOUND && !git_odb_refresh(db)) @@ -1004,8 +1038,10 @@ bool found = false; int error = 0; - if (!only_refreshed && odb_read_hardcoded(&raw, id) == 0) - found = true; + if (!only_refreshed) { + if ((error = odb_read_hardcoded(&found, &raw, id)) < 0) + return error; + } for (i = 0; i < db->backends.length && !found; ++i) { backend_internal *internal = git_vector_get(&db->backends, i); @@ -1040,8 +1076,10 @@ } giterr_clear(); - if ((object = odb_object__alloc(id, &raw)) == NULL) + if ((object = odb_object__alloc(id, &raw)) == NULL) { + error = -1; goto out; + } *out = git_cache_store_raw(odb_cache(db), object); @@ -1057,6 +1095,9 @@ assert(out && db && id); + if (git_oid_iszero(id)) + return error_null_oid(GIT_ENOTFOUND, "cannot read object"); + *out = git_cache_get_raw(odb_cache(db), id); if (*out != NULL) return 0; @@ -1078,11 +1119,14 @@ size_t _unused; int error; + if (git_oid_iszero(id)) + return error_null_oid(GIT_ENOTFOUND, "cannot get object type"); + if ((object = git_cache_get_raw(odb_cache(db), id)) != NULL) { *type_p = object->cached.type; return 0; } - + error = odb_read_header_1(&_unused, type_p, db, id, false); if (error == GIT_PASSTHROUGH) { @@ -1161,8 +1205,10 @@ } } - if ((object = odb_object__alloc(&found_full_oid, &raw)) == NULL) + if ((object = odb_object__alloc(&found_full_oid, &raw)) == NULL) { + error = -1; goto out; + } *out = git_cache_store_raw(odb_cache(db), object); @@ -1231,6 +1277,10 @@ assert(oid && db); git_odb_hash(oid, data, len, type); + + if (git_oid_iszero(oid)) + return error_null_oid(GIT_EINVALID, "cannot write object"); + if (git_odb__freshen(db, oid)) return 0; @@ -1263,13 +1313,17 @@ return error; } -static void hash_header(git_hash_ctx *ctx, git_off_t size, git_otype type) +static int hash_header(git_hash_ctx *ctx, git_off_t size, git_otype type) { char header[64]; - int hdrlen; + size_t hdrlen; + int error; - hdrlen = git_odb__format_object_header(header, sizeof(header), size, type); - git_hash_update(ctx, header, hdrlen); + if ((error = git_odb__format_object_header(&hdrlen, + header, sizeof(header), size, type)) < 0) + return error; + + return git_hash_update(ctx, header, hdrlen); } int git_odb_open_wstream( @@ -1310,16 +1364,17 @@ ctx = git__malloc(sizeof(git_hash_ctx)); GITERR_CHECK_ALLOC(ctx); - if ((error = git_hash_ctx_init(ctx)) < 0) + if ((error = git_hash_ctx_init(ctx)) < 0 || + (error = hash_header(ctx, size, type)) < 0) goto done; - hash_header(ctx, size, type); (*stream)->hash_ctx = ctx; - (*stream)->declared_size = size; (*stream)->received_bytes = 0; done: + if (error) + git__free(ctx); return error; } @@ -1378,7 +1433,12 @@ stream->free(stream); } -int git_odb_open_rstream(git_odb_stream **stream, git_odb *db, const git_oid *oid) +int git_odb_open_rstream( + git_odb_stream **stream, + size_t *len, + git_otype *type, + git_odb *db, + const git_oid *oid) { size_t i, reads = 0; int error = GIT_ERROR; @@ -1391,7 +1451,7 @@ if (b->readstream != NULL) { ++reads; - error = b->readstream(stream, b, oid); + error = b->readstream(stream, len, type, b, oid); } } @@ -1484,6 +1544,12 @@ return GIT_ENOTFOUND; } +static int error_null_oid(int error, const char *message) +{ + giterr_set(GITERR_ODB, "odb: %s: null OID cannot exist", message); + return error; +} + int git_odb__error_ambiguous(const char *message) { giterr_set(GITERR_ODB, "ambiguous SHA1 prefix - %s", message); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/odb.h r-cran-git2r-0.22.1/src/libgit2/src/odb.h --- r-cran-git2r-0.21.0/src/libgit2/src/odb.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/odb.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_odb_h__ #define INCLUDE_odb_h__ +#include "common.h" + #include "git2/odb.h" #include "git2/oid.h" #include "git2/types.h" @@ -68,7 +70,7 @@ /* * Format the object header such as it would appear in the on-disk object */ -int git_odb__format_object_header(char *hdr, size_t n, git_off_t obj_len, git_otype obj_type); +int git_odb__format_object_header(size_t *out_len, char *hdr, size_t hdr_size, git_off_t obj_len, git_otype obj_type); /* * Hash an open file descriptor. * This is a performance call when the contents of a fd need to be hashed, diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/odb_loose.c r-cran-git2r-0.22.1/src/libgit2/src/odb_loose.c --- r-cran-git2r-0.21.0/src/libgit2/src/odb_loose.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/odb_loose.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include #include "git2/object.h" #include "git2/sys/odb_backend.h" @@ -15,10 +16,14 @@ #include "delta.h" #include "filebuf.h" #include "object.h" +#include "zstream.h" #include "git2/odb_backend.h" #include "git2/types.h" +/* maximum possible header length */ +#define MAX_HEADER_LEN 64 + typedef struct { /* object header data */ git_otype type; /* object type */ size_t size; /* object size */ @@ -29,6 +34,15 @@ git_filebuf fbuf; } loose_writestream; +typedef struct { + git_odb_stream stream; + git_map map; + char start[MAX_HEADER_LEN]; + size_t start_len; + size_t start_read; + git_zstream zstream; +} loose_readstream; + typedef struct loose_backend { git_odb_backend parent; @@ -90,222 +104,117 @@ GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST | GIT_MKDIR_VERIFY_DIR, NULL); } -static size_t get_binary_object_header(obj_hdr *hdr, git_buf *obj) +static int parse_header_packlike( + obj_hdr *out, size_t *out_len, const unsigned char *data, size_t len) { unsigned long c; - unsigned char *data = (unsigned char *)obj->ptr; size_t shift, size, used = 0; - if (git_buf_len(obj) == 0) - return 0; + if (len == 0) + goto on_error; c = data[used++]; - hdr->type = (c >> 4) & 7; + out->type = (c >> 4) & 7; size = c & 15; shift = 4; while (c & 0x80) { - if (git_buf_len(obj) <= used) - return 0; + if (len <= used) + goto on_error; + if (sizeof(size_t) * 8 <= shift) - return 0; + goto on_error; + c = data[used++]; size += (c & 0x7f) << shift; shift += 7; } - hdr->size = size; - - return used; -} - -static size_t get_object_header(obj_hdr *hdr, unsigned char *data) -{ - char c, typename[10]; - size_t size, used = 0; - - /* - * type name string followed by space. - */ - while ((c = data[used]) != ' ') { - typename[used++] = c; - if (used >= sizeof(typename)) - return 0; - } - typename[used] = 0; - if (used == 0) - return 0; - hdr->type = git_object_string2type(typename); - used++; /* consume the space */ - - /* - * length follows immediately in decimal (without - * leading zeros). - */ - size = data[used++] - '0'; - if (size > 9) - return 0; - if (size) { - while ((c = data[used]) != '\0') { - size_t d = c - '0'; - if (d > 9) - break; - used++; - size = size * 10 + d; - } - } - hdr->size = size; - - /* - * the length must be followed by a zero byte - */ - if (data[used++] != '\0') - return 0; - - return used; -} - + out->size = size; -/*********************************************************** - * - * ZLIB RELATED FUNCTIONS - * - ***********************************************************/ - -static void init_stream(z_stream *s, void *out, size_t len) -{ - memset(s, 0, sizeof(*s)); - s->next_out = out; - s->avail_out = (uInt)len; -} + if (out_len) + *out_len = used; -static void set_stream_input(z_stream *s, void *in, size_t len) -{ - s->next_in = in; - s->avail_in = (uInt)len; -} + return 0; -static void set_stream_output(z_stream *s, void *out, size_t len) -{ - s->next_out = out; - s->avail_out = (uInt)len; +on_error: + giterr_set(GITERR_OBJECT, "failed to parse loose object: invalid header"); + return -1; } - -static int start_inflate(z_stream *s, git_buf *obj, void *out, size_t len) +static int parse_header( + obj_hdr *out, + size_t *out_len, + const unsigned char *_data, + size_t data_len) { - int status; + const char *data = (char *)_data; + size_t i, typename_len, size_idx, size_len; + int64_t size; - init_stream(s, out, len); - set_stream_input(s, obj->ptr, git_buf_len(obj)); + *out_len = 0; - if ((status = inflateInit(s)) < Z_OK) - return status; + /* find the object type name */ + for (i = 0, typename_len = 0; i < data_len; i++, typename_len++) { + if (data[i] == ' ') + break; + } - return inflate(s, 0); -} + if (typename_len == data_len) + goto on_error; -static void abort_inflate(z_stream *s) -{ - inflateEnd(s); -} + out->type = git_object_stringn2type(data, typename_len); -static int finish_inflate(z_stream *s) -{ - int status = Z_OK; + size_idx = typename_len + 1; + for (i = size_idx, size_len = 0; i < data_len; i++, size_len++) { + if (data[i] == '\0') + break; + } - while (status == Z_OK) - status = inflate(s, Z_FINISH); + if (i == data_len) + goto on_error; - inflateEnd(s); + if (git__strntol64(&size, &data[size_idx], size_len, NULL, 10) < 0 || + size < 0) + goto on_error; - if ((status != Z_STREAM_END) || (s->avail_in != 0)) { - giterr_set(GITERR_ZLIB, "failed to finish zlib inflation; stream aborted prematurely"); + if ((uint64_t)size > SIZE_MAX) { + giterr_set(GITERR_OBJECT, "object is larger than available memory"); return -1; } + out->size = size; + + if (GIT_ADD_SIZET_OVERFLOW(out_len, i, 1)) + goto on_error; + return 0; + +on_error: + giterr_set(GITERR_OBJECT, "failed to parse loose object: invalid header"); + return -1; } -static int is_zlib_compressed_data(unsigned char *data) +static int is_zlib_compressed_data(unsigned char *data, size_t data_len) { unsigned int w; + if (data_len < 2) + return 0; + w = ((unsigned int)(data[0]) << 8) + data[1]; return (data[0] & 0x8F) == 0x08 && !(w % 31); } -static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen) -{ - z_stream zs; - int status = Z_OK; - - memset(&zs, 0x0, sizeof(zs)); - - zs.next_out = out; - zs.avail_out = (uInt)outlen; - - zs.next_in = in; - zs.avail_in = (uInt)inlen; - - if (inflateInit(&zs) < Z_OK) { - giterr_set(GITERR_ZLIB, "failed to inflate buffer"); - return -1; - } - - while (status == Z_OK) - status = inflate(&zs, Z_FINISH); - - inflateEnd(&zs); - - if (status != Z_STREAM_END /* || zs.avail_in != 0 */ || - zs.total_out != outlen) - { - giterr_set(GITERR_ZLIB, "failed to inflate buffer; stream aborted prematurely"); - return -1; - } - - return 0; -} - -static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr) -{ - unsigned char *buf, *head = hb; - size_t tail, alloc_size; - - /* - * allocate a buffer to hold the inflated data and copy the - * initial sequence of inflated data from the tail of the - * head buffer, if any. - */ - if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr->size, 1) || - (buf = git__malloc(alloc_size)) == NULL) { - inflateEnd(s); - return NULL; - } - tail = s->total_out - used; - if (used > 0 && tail > 0) { - if (tail > hdr->size) - tail = hdr->size; - memcpy(buf, head + used, tail); - } - used = tail; - - /* - * inflate the remainder of the object data, if any - */ - if (hdr->size < used) - inflateEnd(s); - else { - set_stream_output(s, buf + used, hdr->size - used); - if (finish_inflate(s)) { - git__free(buf); - return NULL; - } - } +/*********************************************************** + * + * ODB OBJECT READING & WRITING + * + * Backend for the public API; read headers and full objects + * from the ODB. Write raw data to the ODB. + * + ***********************************************************/ - return buf; -} /* * At one point, there was a loose object format that was intended to @@ -313,98 +222,122 @@ * of loose object data into packs. This format is no longer used, but * we must still read it. */ -static int inflate_packlike_loose_disk_obj(git_rawobj *out, git_buf *obj) +static int read_loose_packlike(git_rawobj *out, git_buf *obj) { - unsigned char *in, *buf; + git_buf body = GIT_BUF_INIT; + const unsigned char *obj_data; obj_hdr hdr; - size_t len, used, alloclen; + size_t obj_len, head_len, alloc_size; + int error; + + obj_data = (unsigned char *)obj->ptr; + obj_len = obj->size; /* * read the object header, which is an (uncompressed) * binary encoding of the object type and size. */ - if ((used = get_binary_object_header(&hdr, obj)) == 0 || - !git_object_typeisloose(hdr.type)) { + if ((error = parse_header_packlike(&hdr, &head_len, obj_data, obj_len)) < 0) + goto done; + + if (!git_object_typeisloose(hdr.type) || head_len > obj_len) { giterr_set(GITERR_ODB, "failed to inflate loose object"); - return -1; + error = -1; + goto done; } + obj_data += head_len; + obj_len -= head_len; + /* * allocate a buffer and inflate the data into it */ - GITERR_CHECK_ALLOC_ADD(&alloclen, hdr.size, 1); - buf = git__malloc(alloclen); - GITERR_CHECK_ALLOC(buf); - - in = ((unsigned char *)obj->ptr) + used; - len = obj->size - used; - if (inflate_buffer(in, len, buf, hdr.size) < 0) { - git__free(buf); - return -1; + if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) || + git_buf_init(&body, alloc_size) < 0) { + error = -1; + goto done; } - buf[hdr.size] = '\0'; - out->data = buf; + if ((error = git_zstream_inflatebuf(&body, obj_data, obj_len)) < 0) + goto done; + out->len = hdr.size; out->type = hdr.type; + out->data = git_buf_detach(&body); - return 0; +done: + git_buf_free(&body); + return error; } -static int inflate_disk_obj(git_rawobj *out, git_buf *obj) +static int read_loose_standard(git_rawobj *out, git_buf *obj) { - unsigned char head[64], *buf; - z_stream zs; + git_zstream zstream = GIT_ZSTREAM_INIT; + unsigned char head[MAX_HEADER_LEN], *body = NULL; + size_t decompressed, head_len, body_len, alloc_size; obj_hdr hdr; - size_t used; + int error; - /* - * check for a pack-like loose object - */ - if (!is_zlib_compressed_data((unsigned char *)obj->ptr)) - return inflate_packlike_loose_disk_obj(out, obj); + if ((error = git_zstream_init(&zstream, GIT_ZSTREAM_INFLATE)) < 0 || + (error = git_zstream_set_input(&zstream, git_buf_cstr(obj), git_buf_len(obj))) < 0) + goto done; + + decompressed = sizeof(head); /* - * inflate the initial part of the io buffer in order - * to parse the object header (type and size). + * inflate the initial part of the compressed buffer in order to + * parse the header; read the largest header possible, then push the + * remainder into the body buffer. */ - if (start_inflate(&zs, obj, head, sizeof(head)) < Z_OK || - (used = get_object_header(&hdr, head)) == 0 || - !git_object_typeisloose(hdr.type)) - { - abort_inflate(&zs); + if ((error = git_zstream_get_output(head, &decompressed, &zstream)) < 0 || + (error = parse_header(&hdr, &head_len, head, decompressed)) < 0) + goto done; + + if (!git_object_typeisloose(hdr.type)) { giterr_set(GITERR_ODB, "failed to inflate disk object"); - return -1; + error = -1; + goto done; } /* * allocate a buffer and inflate the object data into it * (including the initial sequence in the head buffer). */ - if ((buf = inflate_tail(&zs, head, used, &hdr)) == NULL) - return -1; - buf[hdr.size] = '\0'; + if (GIT_ADD_SIZET_OVERFLOW(&alloc_size, hdr.size, 1) || + (body = git__malloc(alloc_size)) == NULL) { + error = -1; + goto done; + } - out->data = buf; - out->len = hdr.size; - out->type = hdr.type; + assert(decompressed >= head_len); + body_len = decompressed - head_len; - return 0; -} + if (body_len) + memcpy(body, head + head_len, body_len); + decompressed = hdr.size - body_len; + if ((error = git_zstream_get_output(body + body_len, &decompressed, &zstream)) < 0) + goto done; + if (!git_zstream_done(&zstream)) { + giterr_set(GITERR_ZLIB, "failed to finish zlib inflation: stream aborted prematurely"); + error = -1; + goto done; + } + body[hdr.size] = '\0'; + out->data = body; + out->len = hdr.size; + out->type = hdr.type; +done: + if (error < 0) + git__free(body); -/*********************************************************** - * - * ODB OBJECT READING & WRITING - * - * Backend for the public API; read headers and full objects - * from the ODB. Write raw data to the ODB. - * - ***********************************************************/ + git_zstream_free(&zstream); + return error; +} static int read_loose(git_rawobj *out, git_buf *loc) { @@ -420,21 +353,62 @@ out->len = 0; out->type = GIT_OBJ_BAD; - if (!(error = git_futils_readbuffer(&obj, loc->ptr))) - error = inflate_disk_obj(out, &obj); + if ((error = git_futils_readbuffer(&obj, loc->ptr)) < 0) + goto done; + if (!is_zlib_compressed_data((unsigned char *)obj.ptr, obj.size)) + error = read_loose_packlike(out, &obj); + else + error = read_loose_standard(out, &obj); + +done: git_buf_free(&obj); + return error; +} + +static int read_header_loose_packlike( + git_rawobj *out, const unsigned char *data, size_t len) +{ + obj_hdr hdr; + size_t header_len; + int error; + + if ((error = parse_header_packlike(&hdr, &header_len, data, len)) < 0) + return error; + + out->len = hdr.size; + out->type = hdr.type; + + return error; +} + +static int read_header_loose_standard( + git_rawobj *out, const unsigned char *data, size_t len) +{ + git_zstream zs = GIT_ZSTREAM_INIT; + obj_hdr hdr; + unsigned char inflated[MAX_HEADER_LEN]; + size_t header_len, inflated_len = sizeof(inflated); + int error; + if ((error = git_zstream_init(&zs, GIT_ZSTREAM_INFLATE)) < 0 || + (error = git_zstream_set_input(&zs, data, len)) < 0 || + (error = git_zstream_get_output_chunk(inflated, &inflated_len, &zs)) < 0 || + (error = parse_header(&hdr, &header_len, inflated, inflated_len)) < 0) + goto done; + + out->len = hdr.size; + out->type = hdr.type; + +done: + git_zstream_free(&zs); return error; } static int read_header_loose(git_rawobj *out, git_buf *loc) { - int error = 0, z_return = Z_ERRNO, read_bytes; - git_file fd; - z_stream zs; - obj_hdr header_obj; - unsigned char raw_buffer[16], inflated_buffer[64]; + unsigned char obj[1024]; + int fd, obj_len, error; assert(out && loc); @@ -443,35 +417,24 @@ out->data = NULL; - if ((fd = git_futils_open_ro(loc->ptr)) < 0) - return fd; + if ((error = fd = git_futils_open_ro(loc->ptr)) < 0 || + (error = obj_len = p_read(fd, obj, sizeof(obj))) < 0) + goto done; - init_stream(&zs, inflated_buffer, sizeof(inflated_buffer)); - - z_return = inflateInit(&zs); - - while (z_return == Z_OK) { - if ((read_bytes = p_read(fd, raw_buffer, sizeof(raw_buffer))) > 0) { - set_stream_input(&zs, raw_buffer, read_bytes); - z_return = inflate(&zs, 0); - } else - z_return = Z_STREAM_END; - } + if (!is_zlib_compressed_data(obj, (size_t)obj_len)) + error = read_header_loose_packlike(out, obj, (size_t)obj_len); + else + error = read_header_loose_standard(out, obj, (size_t)obj_len); - if ((z_return != Z_STREAM_END && z_return != Z_BUF_ERROR) - || get_object_header(&header_obj, inflated_buffer) == 0 - || git_object_typeisloose(header_obj.type) == 0) - { + if (!error && !git_object_typeisloose(out->type)) { giterr_set(GITERR_ZLIB, "failed to read loose object header"); error = -1; - } else { - out->len = header_obj.size; - out->type = header_obj.type; + goto done; } - finish_inflate(&zs); - p_close(fd); - +done: + if (fd >= 0) + p_close(fd); return error; } @@ -812,7 +775,7 @@ return error; } -static int loose_backend__stream_fwrite(git_odb_stream *_stream, const git_oid *oid) +static int loose_backend__writestream_finalize(git_odb_stream *_stream, const git_oid *oid) { loose_writestream *stream = (loose_writestream *)_stream; loose_backend *backend = (loose_backend *)_stream->backend; @@ -831,13 +794,13 @@ return error; } -static int loose_backend__stream_write(git_odb_stream *_stream, const char *data, size_t len) +static int loose_backend__writestream_write(git_odb_stream *_stream, const char *data, size_t len) { loose_writestream *stream = (loose_writestream *)_stream; return git_filebuf_write(&stream->fbuf, data, len); } -static void loose_backend__stream_free(git_odb_stream *_stream) +static void loose_backend__writestream_free(git_odb_stream *_stream) { loose_writestream *stream = (loose_writestream *)_stream; @@ -856,29 +819,32 @@ return flags; } -static int loose_backend__stream(git_odb_stream **stream_out, git_odb_backend *_backend, git_off_t length, git_otype type) +static int loose_backend__writestream(git_odb_stream **stream_out, git_odb_backend *_backend, git_off_t length, git_otype type) { loose_backend *backend; loose_writestream *stream = NULL; - char hdr[64]; + char hdr[MAX_HEADER_LEN]; git_buf tmp_path = GIT_BUF_INIT; - int hdrlen; + size_t hdrlen; + int error; assert(_backend && length >= 0); backend = (loose_backend *)_backend; *stream_out = NULL; - hdrlen = git_odb__format_object_header(hdr, sizeof(hdr), length, type); + if ((error = git_odb__format_object_header(&hdrlen, + hdr, sizeof(hdr), length, type)) < 0) + return error; stream = git__calloc(1, sizeof(loose_writestream)); GITERR_CHECK_ALLOC(stream); stream->stream.backend = _backend; stream->stream.read = NULL; /* read only */ - stream->stream.write = &loose_backend__stream_write; - stream->stream.finalize_write = &loose_backend__stream_fwrite; - stream->stream.free = &loose_backend__stream_free; + stream->stream.write = &loose_backend__writestream_write; + stream->stream.finalize_write = &loose_backend__writestream_finalize; + stream->stream.free = &loose_backend__writestream_free; stream->stream.mode = GIT_STREAM_WRONLY; if (git_buf_joinpath(&tmp_path, backend->objects_dir, "tmp_object") < 0 || @@ -896,18 +862,198 @@ return !stream ? -1 : 0; } +static int loose_backend__readstream_read( + git_odb_stream *_stream, + char *buffer, + size_t buffer_len) +{ + loose_readstream *stream = (loose_readstream *)_stream; + size_t start_remain = stream->start_len - stream->start_read; + int total = 0, error; + + /* + * if we read more than just the header in the initial read, play + * that back for the caller. + */ + if (start_remain && buffer_len) { + size_t chunk = min(start_remain, buffer_len); + memcpy(buffer, stream->start + stream->start_read, chunk); + + buffer += chunk; + stream->start_read += chunk; + + total += chunk; + buffer_len -= chunk; + } + + if (buffer_len) { + size_t chunk = min(buffer_len, INT_MAX); + + if ((error = git_zstream_get_output(buffer, &chunk, &stream->zstream)) < 0) + return error; + + total += chunk; + } + + return total; +} + +static void loose_backend__readstream_free(git_odb_stream *_stream) +{ + loose_readstream *stream = (loose_readstream *)_stream; + + git_futils_mmap_free(&stream->map); + git_zstream_free(&stream->zstream); + git__free(stream); +} + +static int loose_backend__readstream_packlike( + obj_hdr *hdr, + loose_readstream *stream) +{ + const unsigned char *data; + size_t data_len, head_len; + int error; + + data = stream->map.data; + data_len = stream->map.len; + + /* + * read the object header, which is an (uncompressed) + * binary encoding of the object type and size. + */ + if ((error = parse_header_packlike(hdr, &head_len, data, data_len)) < 0) + return error; + + if (!git_object_typeisloose(hdr->type)) { + giterr_set(GITERR_ODB, "failed to inflate loose object"); + return -1; + } + + return git_zstream_set_input(&stream->zstream, + data + head_len, data_len - head_len); +} + +static int loose_backend__readstream_standard( + obj_hdr *hdr, + loose_readstream *stream) +{ + unsigned char head[MAX_HEADER_LEN]; + size_t init, head_len; + int error; + + if ((error = git_zstream_set_input(&stream->zstream, + stream->map.data, stream->map.len)) < 0) + return error; + + init = sizeof(head); + + /* + * inflate the initial part of the compressed buffer in order to + * parse the header; read the largest header possible, then store + * it in the `start` field of the stream object. + */ + if ((error = git_zstream_get_output(head, &init, &stream->zstream)) < 0 || + (error = parse_header(hdr, &head_len, head, init)) < 0) + return error; + + if (!git_object_typeisloose(hdr->type)) { + giterr_set(GITERR_ODB, "failed to inflate disk object"); + return -1; + } + + if (init > head_len) { + stream->start_len = init - head_len; + memcpy(stream->start, head + head_len, init - head_len); + } + + return 0; +} + +static int loose_backend__readstream( + git_odb_stream **stream_out, + size_t *len_out, + git_otype *type_out, + git_odb_backend *_backend, + const git_oid *oid) +{ + loose_backend *backend; + loose_readstream *stream = NULL; + git_hash_ctx *hash_ctx = NULL; + git_buf object_path = GIT_BUF_INIT; + obj_hdr hdr; + int error = 0; + + assert(stream_out && len_out && type_out && _backend && oid); + + backend = (loose_backend *)_backend; + *stream_out = NULL; + *len_out = 0; + *type_out = GIT_OBJ_BAD; + + if (locate_object(&object_path, backend, oid) < 0) { + error = git_odb__error_notfound("no matching loose object", + oid, GIT_OID_HEXSZ); + goto done; + } + + stream = git__calloc(1, sizeof(loose_readstream)); + GITERR_CHECK_ALLOC(stream); + + hash_ctx = git__malloc(sizeof(git_hash_ctx)); + GITERR_CHECK_ALLOC(hash_ctx); + + if ((error = git_hash_ctx_init(hash_ctx)) < 0 || + (error = git_futils_mmap_ro_file(&stream->map, object_path.ptr)) < 0 || + (error = git_zstream_init(&stream->zstream, GIT_ZSTREAM_INFLATE)) < 0) + goto done; + + /* check for a packlike loose object */ + if (!is_zlib_compressed_data(stream->map.data, stream->map.len)) + error = loose_backend__readstream_packlike(&hdr, stream); + else + error = loose_backend__readstream_standard(&hdr, stream); + + if (error < 0) + goto done; + + stream->stream.backend = _backend; + stream->stream.hash_ctx = hash_ctx; + stream->stream.read = &loose_backend__readstream_read; + stream->stream.free = &loose_backend__readstream_free; + + *stream_out = (git_odb_stream *)stream; + *len_out = hdr.size; + *type_out = hdr.type; + +done: + if (error < 0) { + git_futils_mmap_free(&stream->map); + git_zstream_free(&stream->zstream); + git_hash_ctx_cleanup(hash_ctx); + git__free(hash_ctx); + git__free(stream); + } + + git_buf_free(&object_path); + return error; +} + static int loose_backend__write(git_odb_backend *_backend, const git_oid *oid, const void *data, size_t len, git_otype type) { - int error = 0, header_len; + int error = 0; git_buf final_path = GIT_BUF_INIT; - char header[64]; + char header[MAX_HEADER_LEN]; + size_t header_len; git_filebuf fbuf = GIT_FILEBUF_INIT; loose_backend *backend; backend = (loose_backend *)_backend; /* prepare the header for the file */ - header_len = git_odb__format_object_header(header, sizeof(header), len, type); + if ((error = git_odb__format_object_header(&header_len, + header, sizeof(header), len, type)) < 0) + goto cleanup; if (git_buf_joinpath(&final_path, backend->objects_dir, "tmp_object") < 0 || git_filebuf_open(&fbuf, final_path.ptr, filebuf_flags(backend), @@ -1002,7 +1148,8 @@ backend->parent.write = &loose_backend__write; backend->parent.read_prefix = &loose_backend__read_prefix; backend->parent.read_header = &loose_backend__read_header; - backend->parent.writestream = &loose_backend__stream; + backend->parent.writestream = &loose_backend__writestream; + backend->parent.readstream = &loose_backend__readstream; backend->parent.exists = &loose_backend__exists; backend->parent.exists_prefix = &loose_backend__exists_prefix; backend->parent.foreach = &loose_backend__foreach; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/odb_mempack.c r-cran-git2r-0.22.1/src/libgit2/src/odb_mempack.c --- r-cran-git2r-0.21.0/src/libgit2/src/odb_mempack.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/odb_mempack.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,8 +6,10 @@ */ #include "common.h" + #include "git2/object.h" #include "git2/sys/odb_backend.h" +#include "git2/sys/mempack.h" #include "fileops.h" #include "hash.h" #include "odb.h" @@ -155,6 +157,7 @@ { struct memory_packer_db *db = (struct memory_packer_db *)_backend; + git_mempack_reset(_backend); git_oidmap_free(db->objects); git__free(db); } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/odb_pack.c r-cran-git2r-0.22.1/src/libgit2/src/odb_pack.c --- r-cran-git2r-0.21.0/src/libgit2/src/odb_pack.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/odb_pack.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include #include "git2/repository.h" #include "git2/indexer.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/offmap.h r-cran-git2r-0.22.1/src/libgit2/src/offmap.h --- r-cran-git2r-0.21.0/src/libgit2/src/offmap.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/offmap.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_offmap_h__ #include "common.h" + #include "git2/types.h" #define kmalloc git__malloc diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/oidarray.c r-cran-git2r-0.22.1/src/libgit2/src/oidarray.c --- r-cran-git2r-0.21.0/src/libgit2/src/oidarray.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/oidarray.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "git2/oidarray.h" #include "oidarray.h" + +#include "git2/oidarray.h" #include "array.h" void git_oidarray_free(git_oidarray *arr) @@ -19,3 +20,15 @@ arr->count = array->size; arr->ids = array->ptr; } + +void git_oidarray__reverse(git_oidarray *arr) +{ + size_t i; + git_oid tmp; + + for (i = 0; i < arr->count / 2; i++) { + git_oid_cpy(&tmp, &arr->ids[i]); + git_oid_cpy(&arr->ids[i], &arr->ids[(arr->count-1)-i]); + git_oid_cpy(&arr->ids[(arr->count-1)-i], &tmp); + } +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/oidarray.h r-cran-git2r-0.22.1/src/libgit2/src/oidarray.h --- r-cran-git2r-0.21.0/src/libgit2/src/oidarray.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/oidarray.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,11 +8,13 @@ #define INCLUDE_oidarray_h__ #include "common.h" + #include "git2/oidarray.h" #include "array.h" typedef git_array_t(git_oid) git_array_oid_t; +extern void git_oidarray__reverse(git_oidarray *arr); extern void git_oidarray__from_array(git_oidarray *arr, git_array_oid_t *array); #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/oid.c r-cran-git2r-0.22.1/src/libgit2/src/oid.c --- r-cran-git2r-0.21.0/src/libgit2/src/oid.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/oid.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "oid.h" + #include "git2/oid.h" #include "repository.h" #include "global.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/oid.h r-cran-git2r-0.22.1/src/libgit2/src/oid.h --- r-cran-git2r-0.21.0/src/libgit2/src/oid.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/oid.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_oid_h__ #define INCLUDE_oid_h__ +#include "common.h" + #include "git2/oid.h" /** @@ -22,14 +24,7 @@ GIT_INLINE(int) git_oid__hashcmp(const unsigned char *sha1, const unsigned char *sha2) { - int i; - - for (i = 0; i < GIT_OID_RAWSZ; i++, sha1++, sha2++) { - if (*sha1 != *sha2) - return *sha1 - *sha2; - } - - return 0; + return memcmp(sha1, sha2, GIT_OID_RAWSZ); } /* diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/oidmap.h r-cran-git2r-0.22.1/src/libgit2/src/oidmap.h --- r-cran-git2r-0.21.0/src/libgit2/src/oidmap.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/oidmap.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_oidmap_h__ #include "common.h" + #include "git2/oid.h" #define kmalloc git__malloc diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/openssl_stream.c r-cran-git2r-0.22.1/src/libgit2/src/openssl_stream.c --- r-cran-git2r-0.21.0/src/libgit2/src/openssl_stream.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/openssl_stream.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,656 +0,0 @@ -/* - * 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. - */ - -#ifdef GIT_OPENSSL - -#include - -#include "global.h" -#include "posix.h" -#include "stream.h" -#include "socket_stream.h" -#include "openssl_stream.h" -#include "netops.h" -#include "git2/transport.h" -#include "git2/sys/openssl.h" - -#ifdef GIT_CURL -# include "curl_stream.h" -#endif - -#ifndef GIT_WIN32 -# include -# include -# include -#endif - -#include -#include -#include -#include - -SSL_CTX *git__ssl_ctx; - -#define GIT_SSL_DEFAULT_CIPHERS "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES128-SHA256:DHE-DSS-AES256-SHA256:DHE-DSS-AES128-SHA:DHE-DSS-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA" - -#if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L - -static git_mutex *openssl_locks; - -static void openssl_locking_function( - int mode, int n, const char *file, int line) -{ - int lock; - - GIT_UNUSED(file); - GIT_UNUSED(line); - - lock = mode & CRYPTO_LOCK; - - if (lock) { - git_mutex_lock(&openssl_locks[n]); - } else { - git_mutex_unlock(&openssl_locks[n]); - } -} - -static void shutdown_ssl_locking(void) -{ - int num_locks, i; - - num_locks = CRYPTO_num_locks(); - CRYPTO_set_locking_callback(NULL); - - for (i = 0; i < num_locks; ++i) - git_mutex_free(&openssl_locks[i]); - git__free(openssl_locks); -} - -#endif /* GIT_THREADS && OPENSSL_VERSION_NUMBER < 0x10100000L */ - -static BIO_METHOD *git_stream_bio_method; -static int init_bio_method(void); - -/** - * This function aims to clean-up the SSL context which - * we allocated. - */ -static void shutdown_ssl(void) -{ - if (git_stream_bio_method) { - BIO_meth_free(git_stream_bio_method); - git_stream_bio_method = NULL; - } - - if (git__ssl_ctx) { - SSL_CTX_free(git__ssl_ctx); - git__ssl_ctx = NULL; - } -} - -int git_openssl_stream_global_init(void) -{ -#ifdef GIT_OPENSSL - long ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; - const char *ciphers = git_libgit2__ssl_ciphers(); - - /* Older OpenSSL and MacOS OpenSSL doesn't have this */ -#ifdef SSL_OP_NO_COMPRESSION - ssl_opts |= SSL_OP_NO_COMPRESSION; -#endif - -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - SSL_load_error_strings(); - OpenSSL_add_ssl_algorithms(); -#else - OPENSSL_init_ssl(0, NULL); -#endif - - /* - * Load SSLv{2,3} and TLSv1 so that we can talk with servers - * which use the SSL hellos, which are often used for - * compatibility. We then disable SSL so we only allow OpenSSL - * to speak TLSv1 to perform the encryption itself. - */ - git__ssl_ctx = SSL_CTX_new(SSLv23_method()); - SSL_CTX_set_options(git__ssl_ctx, ssl_opts); - SSL_CTX_set_mode(git__ssl_ctx, SSL_MODE_AUTO_RETRY); - SSL_CTX_set_verify(git__ssl_ctx, SSL_VERIFY_NONE, NULL); - if (!SSL_CTX_set_default_verify_paths(git__ssl_ctx)) { - SSL_CTX_free(git__ssl_ctx); - git__ssl_ctx = NULL; - return -1; - } - - if (!ciphers) { - ciphers = GIT_SSL_DEFAULT_CIPHERS; - } - - if(!SSL_CTX_set_cipher_list(git__ssl_ctx, ciphers)) { - SSL_CTX_free(git__ssl_ctx); - git__ssl_ctx = NULL; - return -1; - } - - if (init_bio_method() < 0) { - SSL_CTX_free(git__ssl_ctx); - git__ssl_ctx = NULL; - return -1; - } - -#endif - - git__on_shutdown(shutdown_ssl); - - return 0; -} - -int git_openssl_set_locking(void) -{ -#if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L - int num_locks, i; - - num_locks = CRYPTO_num_locks(); - openssl_locks = git__calloc(num_locks, sizeof(git_mutex)); - GITERR_CHECK_ALLOC(openssl_locks); - - for (i = 0; i < num_locks; i++) { - if (git_mutex_init(&openssl_locks[i]) != 0) { - giterr_set(GITERR_SSL, "failed to initialize openssl locks"); - return -1; - } - } - - CRYPTO_set_locking_callback(openssl_locking_function); - git__on_shutdown(shutdown_ssl_locking); - return 0; -#elif OPENSSL_VERSION_NUMBER >= 0x10100000L - return 0; -#else - giterr_set(GITERR_THREAD, "libgit2 was not built with threads"); - return -1; -#endif -} - - -static int bio_create(BIO *b) -{ - BIO_set_init(b, 1); - BIO_set_data(b, NULL); - - return 1; -} - -static int bio_destroy(BIO *b) -{ - if (!b) - return 0; - - BIO_set_data(b, NULL); - - return 1; -} - -static int bio_read(BIO *b, char *buf, int len) -{ - git_stream *io = (git_stream *) BIO_get_data(b); - - return (int) git_stream_read(io, buf, len); -} - -static int bio_write(BIO *b, const char *buf, int len) -{ - git_stream *io = (git_stream *) BIO_get_data(b); - - return (int) git_stream_write(io, buf, len, 0); -} - -static long bio_ctrl(BIO *b, int cmd, long num, void *ptr) -{ - GIT_UNUSED(b); - GIT_UNUSED(num); - GIT_UNUSED(ptr); - - if (cmd == BIO_CTRL_FLUSH) - return 1; - - return 0; -} - -static int bio_gets(BIO *b, char *buf, int len) -{ - GIT_UNUSED(b); - GIT_UNUSED(buf); - GIT_UNUSED(len); - return -1; -} - -static int bio_puts(BIO *b, const char *str) -{ - return bio_write(b, str, strlen(str)); -} - -static int init_bio_method(void) -{ - /* Set up the BIO_METHOD we use for wrapping our own stream implementations */ - git_stream_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK | BIO_get_new_index(), "git_stream"); - GITERR_CHECK_ALLOC(git_stream_bio_method); - - BIO_meth_set_write(git_stream_bio_method, bio_write); - BIO_meth_set_read(git_stream_bio_method, bio_read); - BIO_meth_set_puts(git_stream_bio_method, bio_puts); - BIO_meth_set_gets(git_stream_bio_method, bio_gets); - BIO_meth_set_ctrl(git_stream_bio_method, bio_ctrl); - BIO_meth_set_create(git_stream_bio_method, bio_create); - BIO_meth_set_destroy(git_stream_bio_method, bio_destroy); - - return 0; -} - -static int ssl_set_error(SSL *ssl, int error) -{ - int err; - unsigned long e; - - err = SSL_get_error(ssl, error); - - assert(err != SSL_ERROR_WANT_READ); - assert(err != SSL_ERROR_WANT_WRITE); - - switch (err) { - case SSL_ERROR_WANT_CONNECT: - case SSL_ERROR_WANT_ACCEPT: - giterr_set(GITERR_NET, "SSL error: connection failure"); - break; - case SSL_ERROR_WANT_X509_LOOKUP: - giterr_set(GITERR_NET, "SSL error: x509 error"); - break; - case SSL_ERROR_SYSCALL: - e = ERR_get_error(); - if (e > 0) { - giterr_set(GITERR_NET, "SSL error: %s", - ERR_error_string(e, NULL)); - break; - } else if (error < 0) { - giterr_set(GITERR_OS, "SSL error: syscall failure"); - break; - } - giterr_set(GITERR_NET, "SSL error: received early EOF"); - return GIT_EEOF; - break; - case SSL_ERROR_SSL: - e = ERR_get_error(); - giterr_set(GITERR_NET, "SSL error: %s", - ERR_error_string(e, NULL)); - break; - case SSL_ERROR_NONE: - case SSL_ERROR_ZERO_RETURN: - default: - giterr_set(GITERR_NET, "SSL error: unknown error"); - break; - } - return -1; -} - -static int ssl_teardown(SSL *ssl) -{ - int ret; - - ret = SSL_shutdown(ssl); - if (ret < 0) - ret = ssl_set_error(ssl, ret); - else - ret = 0; - - return ret; -} - -static int check_host_name(const char *name, const char *host) -{ - if (!strcasecmp(name, host)) - return 0; - - if (gitno__match_host(name, host) < 0) - return -1; - - return 0; -} - -static int verify_server_cert(SSL *ssl, const char *host) -{ - X509 *cert; - X509_NAME *peer_name; - ASN1_STRING *str; - unsigned char *peer_cn = NULL; - int matched = -1, type = GEN_DNS; - GENERAL_NAMES *alts; - struct in6_addr addr6; - struct in_addr addr4; - void *addr; - int i = -1,j; - - if (SSL_get_verify_result(ssl) != X509_V_OK) { - giterr_set(GITERR_SSL, "the SSL certificate is invalid"); - return GIT_ECERTIFICATE; - } - - /* Try to parse the host as an IP address to see if it is */ - if (p_inet_pton(AF_INET, host, &addr4)) { - type = GEN_IPADD; - addr = &addr4; - } else { - if(p_inet_pton(AF_INET6, host, &addr6)) { - type = GEN_IPADD; - addr = &addr6; - } - } - - - cert = SSL_get_peer_certificate(ssl); - if (!cert) { - giterr_set(GITERR_SSL, "the server did not provide a certificate"); - return -1; - } - - /* Check the alternative names */ - alts = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); - if (alts) { - int num; - - num = sk_GENERAL_NAME_num(alts); - for (i = 0; i < num && matched != 1; i++) { - const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i); - const char *name = (char *) ASN1_STRING_get0_data(gn->d.ia5); - size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5); - - /* Skip any names of a type we're not looking for */ - if (gn->type != type) - continue; - - if (type == GEN_DNS) { - /* If it contains embedded NULs, don't even try */ - if (memchr(name, '\0', namelen)) - continue; - - if (check_host_name(name, host) < 0) - matched = 0; - else - matched = 1; - } else if (type == GEN_IPADD) { - /* Here name isn't so much a name but a binary representation of the IP */ - matched = !!memcmp(name, addr, namelen); - } - } - } - GENERAL_NAMES_free(alts); - - if (matched == 0) - goto cert_fail_name; - - if (matched == 1) - return 0; - - /* If no alternative names are available, check the common name */ - peer_name = X509_get_subject_name(cert); - if (peer_name == NULL) - goto on_error; - - if (peer_name) { - /* Get the index of the last CN entry */ - while ((j = X509_NAME_get_index_by_NID(peer_name, NID_commonName, i)) >= 0) - i = j; - } - - if (i < 0) - goto on_error; - - str = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(peer_name, i)); - if (str == NULL) - goto on_error; - - /* Work around a bug in OpenSSL whereby ASN1_STRING_to_UTF8 fails if it's already in utf-8 */ - if (ASN1_STRING_type(str) == V_ASN1_UTF8STRING) { - int size = ASN1_STRING_length(str); - - if (size > 0) { - peer_cn = OPENSSL_malloc(size + 1); - GITERR_CHECK_ALLOC(peer_cn); - memcpy(peer_cn, ASN1_STRING_get0_data(str), size); - peer_cn[size] = '\0'; - } else { - goto cert_fail_name; - } - } else { - int size = ASN1_STRING_to_UTF8(&peer_cn, str); - GITERR_CHECK_ALLOC(peer_cn); - if (memchr(peer_cn, '\0', size)) - goto cert_fail_name; - } - - if (check_host_name((char *)peer_cn, host) < 0) - goto cert_fail_name; - - OPENSSL_free(peer_cn); - - return 0; - -on_error: - OPENSSL_free(peer_cn); - return ssl_set_error(ssl, 0); - -cert_fail_name: - OPENSSL_free(peer_cn); - giterr_set(GITERR_SSL, "hostname does not match certificate"); - return GIT_ECERTIFICATE; -} - -typedef struct { - git_stream parent; - git_stream *io; - bool connected; - char *host; - SSL *ssl; - git_cert_x509 cert_info; -} openssl_stream; - -int openssl_close(git_stream *stream); - -int openssl_connect(git_stream *stream) -{ - int ret; - BIO *bio; - openssl_stream *st = (openssl_stream *) stream; - - if ((ret = git_stream_connect(st->io)) < 0) - return ret; - - st->connected = true; - - bio = BIO_new(git_stream_bio_method); - GITERR_CHECK_ALLOC(bio); - - BIO_set_data(bio, st->io); - SSL_set_bio(st->ssl, bio, bio); - - /* specify the host in case SNI is needed */ -#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME - SSL_set_tlsext_host_name(st->ssl, st->host); -#endif - - if ((ret = SSL_connect(st->ssl)) <= 0) - return ssl_set_error(st->ssl, ret); - - return verify_server_cert(st->ssl, st->host); -} - -int openssl_certificate(git_cert **out, git_stream *stream) -{ - openssl_stream *st = (openssl_stream *) stream; - int len; - X509 *cert = SSL_get_peer_certificate(st->ssl); - unsigned char *guard, *encoded_cert; - - /* Retrieve the length of the certificate first */ - len = i2d_X509(cert, NULL); - if (len < 0) { - giterr_set(GITERR_NET, "failed to retrieve certificate information"); - return -1; - } - - encoded_cert = git__malloc(len); - GITERR_CHECK_ALLOC(encoded_cert); - /* i2d_X509 makes 'guard' point to just after the data */ - guard = encoded_cert; - - len = i2d_X509(cert, &guard); - if (len < 0) { - git__free(encoded_cert); - giterr_set(GITERR_NET, "failed to retrieve certificate information"); - return -1; - } - - st->cert_info.parent.cert_type = GIT_CERT_X509; - st->cert_info.data = encoded_cert; - st->cert_info.len = len; - - *out = &st->cert_info.parent; - - return 0; -} - -static int openssl_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts) -{ - openssl_stream *st = (openssl_stream *) stream; - - return git_stream_set_proxy(st->io, proxy_opts); -} - -ssize_t openssl_write(git_stream *stream, const char *data, size_t len, int flags) -{ - openssl_stream *st = (openssl_stream *) stream; - int ret; - - GIT_UNUSED(flags); - - if ((ret = SSL_write(st->ssl, data, len)) <= 0) { - return ssl_set_error(st->ssl, ret); - } - - return ret; -} - -ssize_t openssl_read(git_stream *stream, void *data, size_t len) -{ - openssl_stream *st = (openssl_stream *) stream; - int ret; - - if ((ret = SSL_read(st->ssl, data, len)) <= 0) - return ssl_set_error(st->ssl, ret); - - return ret; -} - -int openssl_close(git_stream *stream) -{ - openssl_stream *st = (openssl_stream *) stream; - int ret; - - if (st->connected && (ret = ssl_teardown(st->ssl)) < 0) - return -1; - - st->connected = false; - - return git_stream_close(st->io); -} - -void openssl_free(git_stream *stream) -{ - openssl_stream *st = (openssl_stream *) stream; - - SSL_free(st->ssl); - git__free(st->host); - git__free(st->cert_info.data); - git_stream_free(st->io); - git__free(st); -} - -int git_openssl_stream_new(git_stream **out, const char *host, const char *port) -{ - int error; - openssl_stream *st; - - st = git__calloc(1, sizeof(openssl_stream)); - GITERR_CHECK_ALLOC(st); - - st->io = NULL; -#ifdef GIT_CURL - error = git_curl_stream_new(&st->io, host, port); -#else - error = git_socket_stream_new(&st->io, host, port); -#endif - - if (error < 0) - goto out_err; - - st->ssl = SSL_new(git__ssl_ctx); - if (st->ssl == NULL) { - giterr_set(GITERR_SSL, "failed to create ssl object"); - error = -1; - goto out_err; - } - - st->host = git__strdup(host); - GITERR_CHECK_ALLOC(st->host); - - st->parent.version = GIT_STREAM_VERSION; - st->parent.encrypted = 1; - st->parent.proxy_support = git_stream_supports_proxy(st->io); - st->parent.connect = openssl_connect; - st->parent.certificate = openssl_certificate; - st->parent.set_proxy = openssl_set_proxy; - st->parent.read = openssl_read; - st->parent.write = openssl_write; - st->parent.close = openssl_close; - st->parent.free = openssl_free; - - *out = (git_stream *) st; - return 0; - -out_err: - git_stream_free(st->io); - git__free(st); - - return error; -} - -#else - -#include "stream.h" -#include "git2/sys/openssl.h" - -int git_openssl_stream_global_init(void) -{ - return 0; -} - -int git_openssl_set_locking(void) -{ - giterr_set(GITERR_SSL, "libgit2 was not built with OpenSSL support"); - return -1; -} - -int git_openssl_stream_new(git_stream **out, const char *host, const char *port) -{ - GIT_UNUSED(out); - GIT_UNUSED(host); - GIT_UNUSED(port); - - giterr_set(GITERR_SSL, "openssl is not supported in this version"); - return -1; -} - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/openssl_stream.h r-cran-git2r-0.22.1/src/libgit2/src/openssl_stream.h --- r-cran-git2r-0.21.0/src/libgit2/src/openssl_stream.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/openssl_stream.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -/* - * 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_openssl_stream_h__ -#define INCLUDE_openssl_stream_h__ - -#include "git2/sys/stream.h" - -extern int git_openssl_stream_global_init(void); - -extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port); - -/* - * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it - * which do not exist in previous versions. We define these inline functions so - * we can program against the interface instead of littering the implementation - * with ifdefs. - */ -#ifdef GIT_OPENSSL -# include -# include -# include -# include - - - -# if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) - -GIT_INLINE(BIO_METHOD*) BIO_meth_new(int type, const char *name) -{ - BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD)); - if (!meth) { - return NULL; - } - - meth->type = type; - meth->name = name; - - return meth; -} - -GIT_INLINE(void) BIO_meth_free(BIO_METHOD *biom) -{ - git__free(biom); -} - -GIT_INLINE(int) BIO_meth_set_write(BIO_METHOD *biom, int (*write) (BIO *, const char *, int)) -{ - biom->bwrite = write; - return 1; -} - -GIT_INLINE(int) BIO_meth_set_read(BIO_METHOD *biom, int (*read) (BIO *, char *, int)) -{ - biom->bread = read; - return 1; -} - -GIT_INLINE(int) BIO_meth_set_puts(BIO_METHOD *biom, int (*puts) (BIO *, const char *)) -{ - biom->bputs = puts; - return 1; -} - -GIT_INLINE(int) BIO_meth_set_gets(BIO_METHOD *biom, int (*gets) (BIO *, char *, int)) - -{ - biom->bgets = gets; - return 1; -} - -GIT_INLINE(int) BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *)) -{ - biom->ctrl = ctrl; - return 1; -} - -GIT_INLINE(int) BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *)) -{ - biom->create = create; - return 1; -} - -GIT_INLINE(int) BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *)) -{ - biom->destroy = destroy; - return 1; -} - -GIT_INLINE(int) BIO_get_new_index(void) -{ - /* This exists as of 1.1 so before we'd just have 0 */ - return 0; -} - -GIT_INLINE(void) BIO_set_init(BIO *b, int init) -{ - b->init = init; -} - -GIT_INLINE(void) BIO_set_data(BIO *a, void *ptr) -{ - a->ptr = ptr; -} - -GIT_INLINE(void*) BIO_get_data(BIO *a) -{ - return a->ptr; -} - -GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x) -{ - return ASN1_STRING_data((ASN1_STRING *)x); -} - -# endif // OpenSSL < 1.1 -#endif // GIT_OPENSSL - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pack.c r-cran-git2r-0.22.1/src/libgit2/src/pack.c --- r-cran-git2r-0.21.0/src/libgit2/src/pack.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pack.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "odb.h" #include "pack.h" + +#include "odb.h" #include "delta.h" #include "sha1_lookup.h" #include "mwindow.h" @@ -716,8 +716,11 @@ error = packfile_unpack_compressed(&delta, p, &w_curs, &curpos, elem->size, elem->type); git_mwindow_close(&w_curs); - if (error < 0) + if (error < 0) { + /* We have transferred ownership of the data to the cache. */ + obj->data = NULL; break; + } /* the current object becomes the new base, on which we apply the delta */ base = *obj; @@ -934,19 +937,19 @@ if (type == GIT_OBJ_OFS_DELTA) { unsigned used = 0; unsigned char c = base_info[used++]; - base_offset = c & 127; + size_t unsigned_base_offset = c & 127; while (c & 128) { if (left <= used) return GIT_EBUFS; - base_offset += 1; - if (!base_offset || MSB(base_offset, 7)) + unsigned_base_offset += 1; + if (!unsigned_base_offset || MSB(unsigned_base_offset, 7)) return 0; /* overflow */ c = base_info[used++]; - base_offset = (base_offset << 7) + (c & 127); + unsigned_base_offset = (unsigned_base_offset << 7) + (c & 127); } - base_offset = delta_obj_offset - base_offset; - if (base_offset <= 0 || base_offset >= delta_obj_offset) + if (unsigned_base_offset == 0 || (size_t)delta_obj_offset <= unsigned_base_offset) return 0; /* out of bound */ + base_offset = delta_obj_offset - unsigned_base_offset; *curpos += used; } else if (type == GIT_OBJ_REF_DELTA) { /* If we have the cooperative cache, search in it first */ @@ -1316,11 +1319,7 @@ short_oid->id[0], short_oid->id[1], short_oid->id[2], lo, hi, p->num_objects); #endif -#ifdef GIT_USE_LOOKUP - pos = sha1_entry_pos(index, stride, 0, lo, hi, p->num_objects, short_oid->id); -#else pos = sha1_position(index, stride, lo, hi, short_oid->id); -#endif if (pos >= 0) { /* An object matching exactly the oid was found */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pack.h r-cran-git2r-0.22.1/src/libgit2/src/pack.h --- r-cran-git2r-0.21.0/src/libgit2/src/pack.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pack.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,11 +8,12 @@ #ifndef INCLUDE_pack_h__ #define INCLUDE_pack_h__ +#include "common.h" + #include #include "git2/oid.h" -#include "common.h" #include "map.h" #include "mwindow.h" #include "odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pack-objects.c r-cran-git2r-0.22.1/src/libgit2/src/pack-objects.c --- r-cran-git2r-0.21.0/src/libgit2/src/pack-objects.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pack-objects.c 2018-07-10 13:23:34.000000000 +0000 @@ -1642,7 +1642,7 @@ if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0) return error; - if (obj->seen) + if (obj->seen || obj->uninteresting) return 0; obj->seen = 1; @@ -1666,6 +1666,10 @@ break; case GIT_OBJ_BLOB: + if ((error = retrieve_object(&obj, pb, git_tree_id(tree))) < 0) + return error; + if (obj->uninteresting) + continue; name = git_tree_entry_name(entry); if ((error = git_packbuilder_insert(pb, entry_id, name)) < 0) return error; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pack-objects.h r-cran-git2r-0.22.1/src/libgit2/src/pack-objects.h --- r-cran-git2r-0.21.0/src/libgit2/src/pack-objects.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pack-objects.h 2018-07-10 13:23:34.000000000 +0000 @@ -104,4 +104,4 @@ int git_packbuilder_write_buf(git_buf *buf, git_packbuilder *pb); -#endif /* INCLUDE_pack_objects_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/parse.c r-cran-git2r-0.22.1/src/libgit2/src/parse.c --- r-cran-git2r-0.21.0/src/libgit2/src/parse.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/parse.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,121 @@ +/* + * 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. + */ +#include "parse.h" + +int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_len) +{ + if (content_len) + ctx->content = content; + else + ctx->content = NULL; + + ctx->content_len = content_len; + ctx->remain = ctx->content; + ctx->remain_len = ctx->content_len; + ctx->line = ctx->remain; + ctx->line_len = git__linenlen(ctx->line, ctx->remain_len); + ctx->line_num = 1; + + return 0; +} + +void git_parse_ctx_clear(git_parse_ctx *ctx) +{ + memset(ctx, 0, sizeof(*ctx)); +} + +void git_parse_advance_line(git_parse_ctx *ctx) +{ + ctx->line += ctx->line_len; + ctx->remain_len -= ctx->line_len; + ctx->line_len = git__linenlen(ctx->line, ctx->remain_len); + ctx->line_num++; +} + +void git_parse_advance_chars(git_parse_ctx *ctx, size_t char_cnt) +{ + ctx->line += char_cnt; + ctx->remain_len -= char_cnt; + ctx->line_len -= char_cnt; +} + +int git_parse_advance_expected( + git_parse_ctx *ctx, + const char *expected, + size_t expected_len) +{ + if (ctx->line_len < expected_len) + return -1; + + if (memcmp(ctx->line, expected, expected_len) != 0) + return -1; + + git_parse_advance_chars(ctx, expected_len); + return 0; +} + +int git_parse_advance_ws(git_parse_ctx *ctx) +{ + int ret = -1; + + while (ctx->line_len > 0 && + ctx->line[0] != '\n' && + git__isspace(ctx->line[0])) { + ctx->line++; + ctx->line_len--; + ctx->remain_len--; + ret = 0; + } + + return ret; +} + +int git_parse_advance_nl(git_parse_ctx *ctx) +{ + if (ctx->line_len != 1 || ctx->line[0] != '\n') + return -1; + + git_parse_advance_line(ctx); + return 0; +} + +int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base) +{ + const char *end; + int ret; + + if (ctx->line_len < 1 || !git__isdigit(ctx->line[0])) + return -1; + + if ((ret = git__strntol64(out, ctx->line, ctx->line_len, &end, base)) < 0) + return -1; + + git_parse_advance_chars(ctx, (end - ctx->line)); + return 0; +} + +int git_parse_peek(char *out, git_parse_ctx *ctx, int flags) +{ + size_t remain = ctx->line_len; + const char *ptr = ctx->line; + + while (remain) { + char c = *ptr; + + if ((flags & GIT_PARSE_PEEK_SKIP_WHITESPACE) && + git__isspace(c)) { + remain--; + ptr++; + continue; + } + + *out = c; + return 0; + } + + return -1; +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/parse.h r-cran-git2r-0.22.1/src/libgit2/src/parse.h --- r-cran-git2r-0.21.0/src/libgit2/src/parse.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/parse.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,61 @@ +/* + * 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_parse_h__ +#define INCLUDE_parse_h__ + +#include "common.h" + +typedef struct { + /* Original content buffer */ + const char *content; + size_t content_len; + + /* The remaining (unparsed) buffer */ + const char *remain; + size_t remain_len; + + const char *line; + size_t line_len; + size_t line_num; +} git_parse_ctx; + +int git_parse_ctx_init(git_parse_ctx *ctx, const char *content, size_t content_len); +void git_parse_ctx_clear(git_parse_ctx *ctx); + +#define git_parse_err(...) \ + ( giterr_set(GITERR_PATCH, __VA_ARGS__), -1 ) + +#define git_parse_ctx_contains_s(ctx, str) \ + git_parse_ctx_contains(ctx, str, sizeof(str) - 1) + +GIT_INLINE(bool) git_parse_ctx_contains( + git_parse_ctx *ctx, const char *str, size_t len) +{ + return (ctx->line_len >= len && memcmp(ctx->line, str, len) == 0); +} + +void git_parse_advance_line(git_parse_ctx *ctx); +void git_parse_advance_chars(git_parse_ctx *ctx, size_t char_cnt); +int git_parse_advance_expected( + git_parse_ctx *ctx, + const char *expected, + size_t expected_len); + +#define git_parse_advance_expected_str(ctx, str) \ + git_parse_advance_expected(ctx, str, strlen(str)) + +int git_parse_advance_ws(git_parse_ctx *ctx); +int git_parse_advance_nl(git_parse_ctx *ctx); +int git_parse_advance_digit(int64_t *out, git_parse_ctx *ctx, int base); + +enum GIT_PARSE_PEEK_FLAGS { + GIT_PARSE_PEEK_SKIP_WHITESPACE = (1 << 0) +}; + +int git_parse_peek(char *out, git_parse_ctx *ctx, int flags); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/patch.c r-cran-git2r-0.22.1/src/libgit2/src/patch.c --- r-cran-git2r-0.21.0/src/libgit2/src/patch.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/patch.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,7 +1,14 @@ -#include "git2/patch.h" -#include "diff.h" +/* +* 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. +*/ + #include "patch.h" +#include "git2/patch.h" +#include "diff.h" int git_patch__invoke_callbacks( git_patch *patch, diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/patch_generate.c r-cran-git2r-0.22.1/src/libgit2/src/patch_generate.c --- r-cran-git2r-0.21.0/src/libgit2/src/patch_generate.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/patch_generate.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,13 +4,14 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + +#include "patch_generate.h" + #include "git2/blob.h" #include "diff.h" #include "diff_generate.h" #include "diff_file.h" #include "diff_driver.h" -#include "patch_generate.h" #include "diff_xdiff.h" #include "delta.h" #include "zstream.h" @@ -138,7 +139,7 @@ if (!(error = patch_generated_init(patch, diff, delta_index))) { patch->flags |= GIT_PATCH_GENERATED_ALLOCATED; - GIT_REFCOUNT_INC(patch); + GIT_REFCOUNT_INC(&patch->base); } else { git__free(patch); patch = NULL; @@ -641,7 +642,7 @@ git_patch **out, const git_blob *old_blob, const char *old_path, - const char *buf, + const void *buf, size_t buflen, const char *buf_path, const git_diff_options *opts) @@ -680,7 +681,7 @@ const void *old_buf, size_t old_len, const char *old_path, - const char *new_buf, + const void *new_buf, size_t new_len, const char *new_path, const git_diff_options *opts) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/patch_generate.h r-cran-git2r-0.22.1/src/libgit2/src/patch_generate.h --- r-cran-git2r-0.21.0/src/libgit2/src/patch_generate.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/patch_generate.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_patch_generate_h__ #include "common.h" + #include "diff.h" #include "diff_file.h" #include "patch.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/patch.h r-cran-git2r-0.22.1/src/libgit2/src/patch.h --- r-cran-git2r-0.21.0/src/libgit2/src/patch.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/patch.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_patch_h__ #define INCLUDE_patch_h__ +#include "common.h" + #include "git2/patch.h" #include "array.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/patch_parse.c r-cran-git2r-0.22.1/src/libgit2/src/patch_parse.c --- r-cran-git2r-0.21.0/src/libgit2/src/patch_parse.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/patch_parse.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,15 +4,14 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "patch_parse.h" + #include "git2/patch.h" #include "patch.h" -#include "patch_parse.h" #include "diff_parse.h" #include "path.h" -#define parse_err(...) \ - ( giterr_set(GITERR_PATCH, __VA_ARGS__), -1 ) - typedef struct { git_patch base; @@ -34,104 +33,34 @@ char *old_prefix, *new_prefix; } git_patch_parsed; - -GIT_INLINE(bool) parse_ctx_contains( - git_patch_parse_ctx *ctx, const char *str, size_t len) -{ - return (ctx->line_len >= len && memcmp(ctx->line, str, len) == 0); -} - -#define parse_ctx_contains_s(ctx, str) \ - parse_ctx_contains(ctx, str, sizeof(str) - 1) - -static void parse_advance_line(git_patch_parse_ctx *ctx) -{ - ctx->line += ctx->line_len; - ctx->remain_len -= ctx->line_len; - ctx->line_len = git__linenlen(ctx->line, ctx->remain_len); - ctx->line_num++; -} - -static void parse_advance_chars(git_patch_parse_ctx *ctx, size_t char_cnt) -{ - ctx->line += char_cnt; - ctx->remain_len -= char_cnt; - ctx->line_len -= char_cnt; -} - -static int parse_advance_expected( - git_patch_parse_ctx *ctx, - const char *expected, - size_t expected_len) -{ - if (ctx->line_len < expected_len) - return -1; - - if (memcmp(ctx->line, expected, expected_len) != 0) - return -1; - - parse_advance_chars(ctx, expected_len); - return 0; -} - -#define parse_advance_expected_str(ctx, str) \ - parse_advance_expected(ctx, str, strlen(str)) - -static int parse_advance_ws(git_patch_parse_ctx *ctx) -{ - int ret = -1; - - while (ctx->line_len > 0 && - ctx->line[0] != '\n' && - git__isspace(ctx->line[0])) { - ctx->line++; - ctx->line_len--; - ctx->remain_len--; - ret = 0; - } - - return ret; -} - -static int parse_advance_nl(git_patch_parse_ctx *ctx) -{ - if (ctx->line_len != 1 || ctx->line[0] != '\n') - return -1; - - parse_advance_line(ctx); - return 0; -} - static int header_path_len(git_patch_parse_ctx *ctx) { bool inquote = 0; - bool quoted = (ctx->line_len > 0 && ctx->line[0] == '"'); + bool quoted = git_parse_ctx_contains_s(&ctx->parse_ctx, "\""); size_t len; - for (len = quoted; len < ctx->line_len; len++) { - if (!quoted && git__isspace(ctx->line[len])) + for (len = quoted; len < ctx->parse_ctx.line_len; len++) { + if (!quoted && git__isspace(ctx->parse_ctx.line[len])) break; - else if (quoted && !inquote && ctx->line[len] == '"') { + else if (quoted && !inquote && ctx->parse_ctx.line[len] == '"') { len++; break; } - inquote = (!inquote && ctx->line[len] == '\\'); + inquote = (!inquote && ctx->parse_ctx.line[len] == '\\'); } return len; } -static int parse_header_path_buf(git_buf *path, git_patch_parse_ctx *ctx) +static int parse_header_path_buf(git_buf *path, git_patch_parse_ctx *ctx, size_t path_len) { - int path_len, error = 0; - - path_len = header_path_len(ctx); + int error; - if ((error = git_buf_put(path, ctx->line, path_len)) < 0) + if ((error = git_buf_put(path, ctx->parse_ctx.line, path_len)) < 0) goto done; - parse_advance_chars(ctx, path_len); + git_parse_advance_chars(&ctx->parse_ctx, path_len); git_buf_rtrim(path); @@ -150,7 +79,7 @@ static int parse_header_path(char **out, git_patch_parse_ctx *ctx) { git_buf path = GIT_BUF_INIT; - int error = parse_header_path_buf(&path, ctx); + int error = parse_header_path_buf(&path, ctx, header_path_len(ctx)); *out = git_buf_detach(&path); @@ -160,35 +89,48 @@ static int parse_header_git_oldpath( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - return parse_header_path(&patch->old_path, ctx); + git_buf old_path = GIT_BUF_INIT; + int error; + + if ((error = parse_header_path_buf(&old_path, ctx, ctx->parse_ctx.line_len - 1)) < 0) + goto out; + + patch->old_path = git_buf_detach(&old_path); + +out: + git_buf_free(&old_path); + return error; } static int parse_header_git_newpath( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - return parse_header_path(&patch->new_path, ctx); + git_buf new_path = GIT_BUF_INIT; + int error; + + if ((error = parse_header_path_buf(&new_path, ctx, ctx->parse_ctx.line_len - 1)) < 0) + goto out; + + patch->new_path = git_buf_detach(&new_path); + +out: + git_buf_free(&new_path); + return error; } static int parse_header_mode(uint16_t *mode, git_patch_parse_ctx *ctx) { - const char *end; - int32_t m; - int ret; - - if (ctx->line_len < 1 || !git__isdigit(ctx->line[0])) - return parse_err("invalid file mode at line %"PRIuZ, ctx->line_num); + int64_t m; - if ((ret = git__strntol32(&m, ctx->line, ctx->line_len, &end, 8)) < 0) - return ret; + if ((git_parse_advance_digit(&m, &ctx->parse_ctx, 8)) < 0) + return git_parse_err("invalid file mode at line %"PRIuZ, ctx->parse_ctx.line_num); if (m > UINT16_MAX) return -1; *mode = (uint16_t)m; - parse_advance_chars(ctx, (end - ctx->line)); - - return ret; + return 0; } static int parse_header_oid( @@ -198,17 +140,17 @@ { size_t len; - for (len = 0; len < ctx->line_len && len < GIT_OID_HEXSZ; len++) { - if (!git__isxdigit(ctx->line[len])) + for (len = 0; len < ctx->parse_ctx.line_len && len < GIT_OID_HEXSZ; len++) { + if (!git__isxdigit(ctx->parse_ctx.line[len])) break; } if (len < GIT_OID_MINPREFIXLEN || len > GIT_OID_HEXSZ || - git_oid_fromstrn(oid, ctx->line, len) < 0) - return parse_err("invalid hex formatted object id at line %"PRIuZ, - ctx->line_num); + git_oid_fromstrn(oid, ctx->parse_ctx.line, len) < 0) + return git_parse_err("invalid hex formatted object id at line %"PRIuZ, + ctx->parse_ctx.line_num); - parse_advance_chars(ctx, len); + git_parse_advance_chars(&ctx->parse_ctx, len); *oid_len = (uint16_t)len; @@ -218,17 +160,19 @@ static int parse_header_git_index( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { + char c; + if (parse_header_oid(&patch->base.delta->old_file.id, &patch->base.delta->old_file.id_abbrev, ctx) < 0 || - parse_advance_expected_str(ctx, "..") < 0 || + git_parse_advance_expected_str(&ctx->parse_ctx, "..") < 0 || parse_header_oid(&patch->base.delta->new_file.id, &patch->base.delta->new_file.id_abbrev, ctx) < 0) return -1; - if (ctx->line_len > 0 && ctx->line[0] == ' ') { + if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ' ') { uint16_t mode; - parse_advance_chars(ctx, 1); + git_parse_advance_chars(&ctx->parse_ctx, 1); if (parse_header_mode(&mode, ctx) < 0) return -1; @@ -287,7 +231,7 @@ { git_buf path = GIT_BUF_INIT; - if (parse_header_path_buf(&path, ctx) < 0) + if (parse_header_path_buf(&path, ctx, header_path_len(ctx)) < 0) return -1; /* Note: the `rename from` and `rename to` lines include the literal @@ -327,19 +271,15 @@ static int parse_header_percent(uint16_t *out, git_patch_parse_ctx *ctx) { - int32_t val; - const char *end; + int64_t val; - if (ctx->line_len < 1 || !git__isdigit(ctx->line[0]) || - git__strntol32(&val, ctx->line, ctx->line_len, &end, 10) < 0) + if (git_parse_advance_digit(&val, &ctx->parse_ctx, 10) < 0) return -1; - parse_advance_chars(ctx, (end - ctx->line)); - - if (parse_advance_expected_str(ctx, "%") < 0) + if (git_parse_advance_expected_str(&ctx->parse_ctx, "%") < 0) return -1; - if (val > 100) + if (val < 0 || val > 100) return -1; *out = val; @@ -350,8 +290,8 @@ git_patch_parsed *patch, git_patch_parse_ctx *ctx) { if (parse_header_percent(&patch->base.delta->similarity, ctx) < 0) - return parse_err("invalid similarity percentage at line %"PRIuZ, - ctx->line_num); + return git_parse_err("invalid similarity percentage at line %"PRIuZ, + ctx->parse_ctx.line_num); return 0; } @@ -362,39 +302,98 @@ uint16_t dissimilarity; if (parse_header_percent(&dissimilarity, ctx) < 0) - return parse_err("invalid similarity percentage at line %"PRIuZ, - ctx->line_num); + return git_parse_err("invalid similarity percentage at line %"PRIuZ, + ctx->parse_ctx.line_num); patch->base.delta->similarity = 100 - dissimilarity; return 0; } +static int parse_header_start(git_patch_parsed *patch, git_patch_parse_ctx *ctx) +{ + if (parse_header_path(&patch->header_old_path, ctx) < 0) + return git_parse_err("corrupt old path in git diff header at line %"PRIuZ, + ctx->parse_ctx.line_num); + + if (git_parse_advance_ws(&ctx->parse_ctx) < 0 || + parse_header_path(&patch->header_new_path, ctx) < 0) + return git_parse_err("corrupt new path in git diff header at line %"PRIuZ, + ctx->parse_ctx.line_num); + + /* + * We cannot expect to be able to always parse paths correctly at this + * point. Due to the possibility of unquoted names, whitespaces in + * filenames and custom prefixes we have to allow that, though, and just + * proceeed here. We then hope for the "---" and "+++" lines to fix that + * for us. + */ + if (!git_parse_ctx_contains(&ctx->parse_ctx, "\n", 1)) { + git_parse_advance_chars(&ctx->parse_ctx, ctx->parse_ctx.line_len - 1); + + git__free(patch->header_old_path); + patch->header_old_path = NULL; + git__free(patch->header_new_path); + patch->header_new_path = NULL; + } + + return 0; +} + +typedef enum { + STATE_START, + + STATE_DIFF, + STATE_FILEMODE, + STATE_MODE, + STATE_INDEX, + STATE_PATH, + + STATE_SIMILARITY, + STATE_RENAME, + STATE_COPY, + + STATE_END, +} parse_header_state; + typedef struct { const char *str; + parse_header_state expected_state; + parse_header_state next_state; int(*fn)(git_patch_parsed *, git_patch_parse_ctx *); -} header_git_op; +} parse_header_transition; -static const header_git_op header_git_ops[] = { - { "diff --git ", NULL }, - { "@@ -", NULL }, - { "GIT binary patch", NULL }, - { "Binary files ", NULL }, - { "--- ", parse_header_git_oldpath }, - { "+++ ", parse_header_git_newpath }, - { "index ", parse_header_git_index }, - { "old mode ", parse_header_git_oldmode }, - { "new mode ", parse_header_git_newmode }, - { "deleted file mode ", parse_header_git_deletedfilemode }, - { "new file mode ", parse_header_git_newfilemode }, - { "rename from ", parse_header_renamefrom }, - { "rename to ", parse_header_renameto }, - { "rename old ", parse_header_renamefrom }, - { "rename new ", parse_header_renameto }, - { "copy from ", parse_header_copyfrom }, - { "copy to ", parse_header_copyto }, - { "similarity index ", parse_header_similarity }, - { "dissimilarity index ", parse_header_dissimilarity }, +static const parse_header_transition transitions[] = { + /* Start */ + { "diff --git " , STATE_START, STATE_DIFF, parse_header_start }, + + { "deleted file mode " , STATE_DIFF, STATE_FILEMODE, parse_header_git_deletedfilemode }, + { "new file mode " , STATE_DIFF, STATE_FILEMODE, parse_header_git_newfilemode }, + { "old mode " , STATE_DIFF, STATE_MODE, parse_header_git_oldmode }, + { "new mode " , STATE_MODE, STATE_END, parse_header_git_newmode }, + + { "index " , STATE_FILEMODE, STATE_INDEX, parse_header_git_index }, + { "index " , STATE_DIFF, STATE_INDEX, parse_header_git_index }, + { "index " , STATE_END, STATE_INDEX, parse_header_git_index }, + + { "--- " , STATE_INDEX, STATE_PATH, parse_header_git_oldpath }, + { "+++ " , STATE_PATH, STATE_END, parse_header_git_newpath }, + { "GIT binary patch" , STATE_INDEX, STATE_END, NULL }, + { "Binary files " , STATE_INDEX, STATE_END, NULL }, + + { "similarity index " , STATE_DIFF, STATE_SIMILARITY, parse_header_similarity }, + { "dissimilarity index ", STATE_DIFF, STATE_SIMILARITY, parse_header_dissimilarity }, + { "rename from " , STATE_SIMILARITY, STATE_RENAME, parse_header_renamefrom }, + { "rename old " , STATE_SIMILARITY, STATE_RENAME, parse_header_renamefrom }, + { "copy from " , STATE_SIMILARITY, STATE_COPY, parse_header_copyfrom }, + { "rename to " , STATE_RENAME, STATE_END, parse_header_renameto }, + { "rename new " , STATE_RENAME, STATE_END, parse_header_renameto }, + { "copy to " , STATE_COPY, STATE_END, parse_header_copyto }, + + /* Next patch */ + { "diff --git " , STATE_END, 0, NULL }, + { "@@ -" , STATE_END, 0, NULL }, + { "-- " , STATE_END, 0, NULL }, }; static int parse_header_git( @@ -403,65 +402,58 @@ { size_t i; int error = 0; - - /* Parse the diff --git line */ - if (parse_advance_expected_str(ctx, "diff --git ") < 0) - return parse_err("corrupt git diff header at line %"PRIuZ, ctx->line_num); - - if (parse_header_path(&patch->header_old_path, ctx) < 0) - return parse_err("corrupt old path in git diff header at line %"PRIuZ, - ctx->line_num); - - if (parse_advance_ws(ctx) < 0 || - parse_header_path(&patch->header_new_path, ctx) < 0) - return parse_err("corrupt new path in git diff header at line %"PRIuZ, - ctx->line_num); + parse_header_state state = STATE_START; /* Parse remaining header lines */ - for (parse_advance_line(ctx); - ctx->remain_len > 0; - parse_advance_line(ctx)) { - + for (; ctx->parse_ctx.remain_len > 0; git_parse_advance_line(&ctx->parse_ctx)) { bool found = false; - if (ctx->line_len == 0 || ctx->line[ctx->line_len - 1] != '\n') + if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') break; - for (i = 0; i < ARRAY_SIZE(header_git_ops); i++) { - const header_git_op *op = &header_git_ops[i]; - size_t op_len = strlen(op->str); + for (i = 0; i < ARRAY_SIZE(transitions); i++) { + const parse_header_transition *transition = &transitions[i]; + size_t op_len = strlen(transition->str); - if (memcmp(ctx->line, op->str, min(op_len, ctx->line_len)) != 0) + if (transition->expected_state != state || + git__prefixcmp(ctx->parse_ctx.line, transition->str) != 0) continue; + state = transition->next_state; + /* Do not advance if this is the patch separator */ - if (op->fn == NULL) + if (transition->fn == NULL) goto done; - parse_advance_chars(ctx, op_len); + git_parse_advance_chars(&ctx->parse_ctx, op_len); - if ((error = op->fn(patch, ctx)) < 0) + if ((error = transition->fn(patch, ctx)) < 0) goto done; - parse_advance_ws(ctx); + git_parse_advance_ws(&ctx->parse_ctx); - if (parse_advance_expected_str(ctx, "\n") < 0 || - ctx->line_len > 0) { - error = parse_err("trailing data at line %"PRIuZ, ctx->line_num); + if (git_parse_advance_expected_str(&ctx->parse_ctx, "\n") < 0 || + ctx->parse_ctx.line_len > 0) { + error = git_parse_err("trailing data at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } found = true; break; } - + if (!found) { - error = parse_err("invalid patch header at line %"PRIuZ, - ctx->line_num); + error = git_parse_err("invalid patch header at line %"PRIuZ, + ctx->parse_ctx.line_num); goto done; } } + if (state != STATE_END) { + error = git_parse_err("unexpected header line %"PRIuZ, ctx->parse_ctx.line_num); + goto done; + } + done: return error; } @@ -471,17 +463,17 @@ const char *end; int64_t num; - if (!git__isdigit(ctx->line[0])) + if (!git__isdigit(ctx->parse_ctx.line[0])) return -1; - if (git__strntol64(&num, ctx->line, ctx->line_len, &end, 10) < 0) + if (git__strntol64(&num, ctx->parse_ctx.line, ctx->parse_ctx.line_len, &end, 10) < 0) return -1; if (num < 0) return -1; *out = num; - parse_advance_chars(ctx, (end - ctx->line)); + git_parse_advance_chars(&ctx->parse_ctx, (end - ctx->parse_ctx.line)); return 0; } @@ -490,7 +482,7 @@ { git_off_t num; - if (parse_number(&num, ctx) < 0 || !git__is_int(num)) + if (git_parse_advance_digit(&num, &ctx->parse_ctx, 10) < 0 || !git__is_int(num)) return -1; *out = (int)num; @@ -501,43 +493,44 @@ git_patch_hunk *hunk, git_patch_parse_ctx *ctx) { - const char *header_start = ctx->line; + const char *header_start = ctx->parse_ctx.line; + char c; hunk->hunk.old_lines = 1; hunk->hunk.new_lines = 1; - if (parse_advance_expected_str(ctx, "@@ -") < 0 || + if (git_parse_advance_expected_str(&ctx->parse_ctx, "@@ -") < 0 || parse_int(&hunk->hunk.old_start, ctx) < 0) goto fail; - if (ctx->line_len > 0 && ctx->line[0] == ',') { - if (parse_advance_expected_str(ctx, ",") < 0 || + if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ',') { + if (git_parse_advance_expected_str(&ctx->parse_ctx, ",") < 0 || parse_int(&hunk->hunk.old_lines, ctx) < 0) goto fail; } - if (parse_advance_expected_str(ctx, " +") < 0 || + if (git_parse_advance_expected_str(&ctx->parse_ctx, " +") < 0 || parse_int(&hunk->hunk.new_start, ctx) < 0) goto fail; - if (ctx->line_len > 0 && ctx->line[0] == ',') { - if (parse_advance_expected_str(ctx, ",") < 0 || + if (git_parse_peek(&c, &ctx->parse_ctx, 0) == 0 && c == ',') { + if (git_parse_advance_expected_str(&ctx->parse_ctx, ",") < 0 || parse_int(&hunk->hunk.new_lines, ctx) < 0) goto fail; } - if (parse_advance_expected_str(ctx, " @@") < 0) + if (git_parse_advance_expected_str(&ctx->parse_ctx, " @@") < 0) goto fail; - parse_advance_line(ctx); + git_parse_advance_line(&ctx->parse_ctx); if (!hunk->hunk.old_lines && !hunk->hunk.new_lines) goto fail; - hunk->hunk.header_len = ctx->line - header_start; + hunk->hunk.header_len = ctx->parse_ctx.line - header_start; if (hunk->hunk.header_len > (GIT_DIFF_HUNK_HEADER_SIZE - 1)) - return parse_err("oversized patch hunk header at line %"PRIuZ, - ctx->line_num); + return git_parse_err("oversized patch hunk header at line %"PRIuZ, + ctx->parse_ctx.line_num); memcpy(hunk->hunk.header, header_start, hunk->hunk.header_len); hunk->hunk.header[hunk->hunk.header_len] = '\0'; @@ -546,7 +539,7 @@ fail: giterr_set(GITERR_PATCH, "invalid patch hunk header at line %"PRIuZ, - ctx->line_num); + ctx->parse_ctx.line_num); return -1; } @@ -562,23 +555,27 @@ int newlines = hunk->hunk.new_lines; for (; - ctx->remain_len > 1 && + ctx->parse_ctx.remain_len > 1 && (oldlines || newlines) && - (ctx->remain_len <= 4 || memcmp(ctx->line, "@@ -", 4) != 0); - parse_advance_line(ctx)) { + !git_parse_ctx_contains_s(&ctx->parse_ctx, "@@ -"); + git_parse_advance_line(&ctx->parse_ctx)) { + char c; int origin; int prefix = 1; - if (ctx->line_len == 0 || ctx->line[ctx->line_len - 1] != '\n') { - error = parse_err("invalid patch instruction at line %"PRIuZ, - ctx->line_num); + if (ctx->parse_ctx.line_len == 0 || ctx->parse_ctx.line[ctx->parse_ctx.line_len - 1] != '\n') { + error = git_parse_err("invalid patch instruction at line %"PRIuZ, + ctx->parse_ctx.line_num); goto done; } - switch (ctx->line[0]) { + git_parse_peek(&c, &ctx->parse_ctx, 0); + + switch (c) { case '\n': prefix = 0; + /* fall through */ case ' ': origin = GIT_DIFF_LINE_CONTEXT; @@ -597,7 +594,7 @@ break; default: - error = parse_err("invalid patch hunk at line %"PRIuZ, ctx->line_num); + error = git_parse_err("invalid patch hunk at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } @@ -606,16 +603,16 @@ memset(line, 0x0, sizeof(git_diff_line)); - line->content = ctx->line + prefix; - line->content_len = ctx->line_len - prefix; - line->content_offset = ctx->content_len - ctx->remain_len; + line->content = ctx->parse_ctx.line + prefix; + line->content_len = ctx->parse_ctx.line_len - prefix; + line->content_offset = ctx->parse_ctx.content_len - ctx->parse_ctx.remain_len; line->origin = origin; hunk->line_count++; } if (oldlines || newlines) { - error = parse_err( + error = git_parse_err( "invalid patch hunk, expected %d old lines and %d new lines", hunk->hunk.old_lines, hunk->hunk.new_lines); goto done; @@ -626,19 +623,19 @@ * localized. Because `diff` optimizes for the case where you * want to apply the patch by hand. */ - if (parse_ctx_contains_s(ctx, "\\ ") && + if (git_parse_ctx_contains_s(&ctx->parse_ctx, "\\ ") && git_array_size(patch->base.lines) > 0) { line = git_array_get(patch->base.lines, git_array_size(patch->base.lines) - 1); if (line->content_len < 1) { - error = parse_err("cannot trim trailing newline of empty line"); + error = git_parse_err("cannot trim trailing newline of empty line"); goto done; } line->content_len--; - parse_advance_line(ctx); + git_parse_advance_line(&ctx->parse_ctx); } done: @@ -651,18 +648,15 @@ { int error = 0; - for (ctx->line = ctx->remain; - ctx->remain_len > 0; - parse_advance_line(ctx)) { - + for (; ctx->parse_ctx.remain_len > 0; git_parse_advance_line(&ctx->parse_ctx)) { /* This line is too short to be a patch header. */ - if (ctx->line_len < 6) + if (ctx->parse_ctx.line_len < 6) continue; /* This might be a hunk header without a patch header, provide a * sensible error message. */ - if (parse_ctx_contains_s(ctx, "@@ -")) { - size_t line_num = ctx->line_num; + if (git_parse_ctx_contains_s(&ctx->parse_ctx, "@@ -")) { + size_t line_num = ctx->parse_ctx.line_num; git_patch_hunk hunk; /* If this cannot be parsed as a hunk header, it's just leading @@ -673,17 +667,17 @@ continue; } - error = parse_err("invalid hunk header outside patch at line %"PRIuZ, + error = git_parse_err("invalid hunk header outside patch at line %"PRIuZ, line_num); goto done; } /* This buffer is too short to contain a patch. */ - if (ctx->remain_len < ctx->line_len + 6) + if (ctx->parse_ctx.remain_len < ctx->parse_ctx.line_len + 6) break; /* A proper git patch */ - if (parse_ctx_contains_s(ctx, "diff --git ")) { + if (git_parse_ctx_contains_s(&ctx->parse_ctx, "diff --git ")) { error = parse_header_git(patch, ctx); goto done; } @@ -708,27 +702,30 @@ git_off_t len; int error = 0; - if (parse_ctx_contains_s(ctx, "literal ")) { + if (git_parse_ctx_contains_s(&ctx->parse_ctx, "literal ")) { type = GIT_DIFF_BINARY_LITERAL; - parse_advance_chars(ctx, 8); - } else if (parse_ctx_contains_s(ctx, "delta ")) { + git_parse_advance_chars(&ctx->parse_ctx, 8); + } else if (git_parse_ctx_contains_s(&ctx->parse_ctx, "delta ")) { type = GIT_DIFF_BINARY_DELTA; - parse_advance_chars(ctx, 6); + git_parse_advance_chars(&ctx->parse_ctx, 6); } else { - error = parse_err( - "unknown binary delta type at line %"PRIuZ, ctx->line_num); + error = git_parse_err( + "unknown binary delta type at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } - if (parse_number(&len, ctx) < 0 || parse_advance_nl(ctx) < 0 || len < 0) { - error = parse_err("invalid binary size at line %"PRIuZ, ctx->line_num); + if (git_parse_advance_digit(&len, &ctx->parse_ctx, 10) < 0 || + git_parse_advance_nl(&ctx->parse_ctx) < 0 || len < 0) { + error = git_parse_err("invalid binary size at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } - while (ctx->line_len) { - char c = ctx->line[0]; + while (ctx->parse_ctx.line_len) { + char c; size_t encoded_len, decoded_len = 0, decoded_orig = decoded.size; + git_parse_peek(&c, &ctx->parse_ctx, 0); + if (c == '\n') break; else if (c >= 'A' && c <= 'Z') @@ -737,32 +734,32 @@ decoded_len = c - 'a' + (('z' - 'a') + 1) + 1; if (!decoded_len) { - error = parse_err("invalid binary length at line %"PRIuZ, ctx->line_num); + error = git_parse_err("invalid binary length at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } - parse_advance_chars(ctx, 1); + git_parse_advance_chars(&ctx->parse_ctx, 1); encoded_len = ((decoded_len / 4) + !!(decoded_len % 4)) * 5; - if (encoded_len > ctx->line_len - 1) { - error = parse_err("truncated binary data at line %"PRIuZ, ctx->line_num); + if (encoded_len > ctx->parse_ctx.line_len - 1) { + error = git_parse_err("truncated binary data at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } if ((error = git_buf_decode_base85( - &decoded, ctx->line, encoded_len, decoded_len)) < 0) + &decoded, ctx->parse_ctx.line, encoded_len, decoded_len)) < 0) goto done; if (decoded.size - decoded_orig != decoded_len) { - error = parse_err("truncated binary data at line %"PRIuZ, ctx->line_num); + error = git_parse_err("truncated binary data at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } - parse_advance_chars(ctx, encoded_len); + git_parse_advance_chars(&ctx->parse_ctx, encoded_len); - if (parse_advance_nl(ctx) < 0) { - error = parse_err("trailing data at line %"PRIuZ, ctx->line_num); + if (git_parse_advance_nl(&ctx->parse_ctx) < 0) { + error = git_parse_err("trailing data at line %"PRIuZ, ctx->parse_ctx.line_num); goto done; } } @@ -784,27 +781,27 @@ { int error; - if (parse_advance_expected_str(ctx, "GIT binary patch") < 0 || - parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary header at line %"PRIuZ, ctx->line_num); + if (git_parse_advance_expected_str(&ctx->parse_ctx, "GIT binary patch") < 0 || + git_parse_advance_nl(&ctx->parse_ctx) < 0) + return git_parse_err("corrupt git binary header at line %"PRIuZ, ctx->parse_ctx.line_num); /* parse old->new binary diff */ if ((error = parse_patch_binary_side( &patch->base.binary.new_file, ctx)) < 0) return error; - if (parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary separator at line %"PRIuZ, - ctx->line_num); + if (git_parse_advance_nl(&ctx->parse_ctx) < 0) + return git_parse_err("corrupt git binary separator at line %"PRIuZ, + ctx->parse_ctx.line_num); /* parse new->old binary diff */ if ((error = parse_patch_binary_side( &patch->base.binary.old_file, ctx)) < 0) return error; - if (parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary patch separator at line %"PRIuZ, - ctx->line_num); + if (git_parse_advance_nl(&ctx->parse_ctx) < 0) + return git_parse_err("corrupt git binary patch separator at line %"PRIuZ, + ctx->parse_ctx.line_num); patch->base.binary.contains_data = 1; patch->base.delta->flags |= GIT_DIFF_FLAG_BINARY; @@ -815,13 +812,13 @@ git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - if (parse_advance_expected_str(ctx, "Binary files ") < 0 || - parse_advance_expected_str(ctx, patch->header_old_path) < 0 || - parse_advance_expected_str(ctx, " and ") < 0 || - parse_advance_expected_str(ctx, patch->header_new_path) < 0 || - parse_advance_expected_str(ctx, " differ") < 0 || - parse_advance_nl(ctx) < 0) - return parse_err("corrupt git binary header at line %"PRIuZ, ctx->line_num); + if (git_parse_advance_expected_str(&ctx->parse_ctx, "Binary files ") < 0 || + git_parse_advance_expected_str(&ctx->parse_ctx, patch->header_old_path) < 0 || + git_parse_advance_expected_str(&ctx->parse_ctx, " and ") < 0 || + git_parse_advance_expected_str(&ctx->parse_ctx, patch->header_new_path) < 0 || + git_parse_advance_expected_str(&ctx->parse_ctx, " differ") < 0 || + git_parse_advance_nl(&ctx->parse_ctx) < 0) + return git_parse_err("corrupt git binary header at line %"PRIuZ, ctx->parse_ctx.line_num); patch->base.binary.contains_data = 0; patch->base.delta->flags |= GIT_DIFF_FLAG_BINARY; @@ -835,7 +832,7 @@ git_patch_hunk *hunk; int error = 0; - while (parse_ctx_contains_s(ctx, "@@ -")) { + while (git_parse_ctx_contains_s(&ctx->parse_ctx, "@@ -")) { hunk = git_array_alloc(patch->base.hunks); GITERR_CHECK_ALLOC(hunk); @@ -858,9 +855,9 @@ static int parse_patch_body( git_patch_parsed *patch, git_patch_parse_ctx *ctx) { - if (parse_ctx_contains_s(ctx, "GIT binary patch")) + if (git_parse_ctx_contains_s(&ctx->parse_ctx, "GIT binary patch")) return parse_patch_binary(patch, ctx); - else if (parse_ctx_contains_s(ctx, "Binary files ")) + else if (git_parse_ctx_contains_s(&ctx->parse_ctx, "Binary files ")) return parse_patch_binary_nodata(patch, ctx); else return parse_patch_hunks(patch, ctx); @@ -876,10 +873,10 @@ return 0; if (two_null && strcmp(two, "/dev/null") != 0) - return parse_err("expected %s path of '/dev/null'", old_or_new); + return git_parse_err("expected %s path of '/dev/null'", old_or_new); else if (!two_null && strcmp(one, two) != 0) - return parse_err("mismatched %s path names", old_or_new); + return git_parse_err("mismatched %s path names", old_or_new); return 0; } @@ -912,7 +909,7 @@ } if (remain_len || !*path) - return parse_err( + return git_parse_err( "header filename does not contain %"PRIuZ" path components", prefix_len); @@ -931,10 +928,10 @@ bool deleted = (patch->base.delta->status == GIT_DELTA_DELETED); if (patch->old_path && !patch->new_path) - return parse_err("missing new path"); + return git_parse_err("missing new path"); if (!patch->old_path && patch->new_path) - return parse_err("missing old path"); + return git_parse_err("missing old path"); /* Ensure (non-renamed) paths match */ if (check_header_names( @@ -967,7 +964,7 @@ if (!patch->base.delta->old_file.path && !patch->base.delta->new_file.path) - return parse_err("git diff header lacks old / new paths"); + return git_parse_err("git diff header lacks old / new paths"); return 0; } @@ -988,7 +985,7 @@ !(delta->flags & GIT_DIFF_FLAG_BINARY) && delta->new_file.mode == delta->old_file.mode && git_array_size(patch->base.hunks) == 0) - return parse_err("patch with no hunks"); + return git_parse_err("patch with no hunks"); if (delta->status == GIT_DELTA_ADDED) { memset(&delta->old_file.id, 0x0, sizeof(git_oid)); @@ -1014,19 +1011,11 @@ if ((ctx = git__calloc(1, sizeof(git_patch_parse_ctx))) == NULL) return NULL; - if (content_len) { - if ((ctx->content = git__malloc(content_len)) == NULL) { - git__free(ctx); - return NULL; - } - - memcpy((char *)ctx->content, content, content_len); + if ((git_parse_ctx_init(&ctx->parse_ctx, content, content_len)) < 0) { + git__free(ctx); + return NULL; } - ctx->content_len = content_len; - ctx->remain = ctx->content; - ctx->remain_len = ctx->content_len; - if (opts) memcpy(&ctx->opts, opts, sizeof(git_patch_options)); else @@ -1041,7 +1030,7 @@ if (!ctx) return; - git__free((char *)ctx->content); + git_parse_ctx_clear(&ctx->parse_ctx); git__free(ctx); } @@ -1116,21 +1105,21 @@ patch->base.delta->status = GIT_DELTA_MODIFIED; patch->base.delta->nfiles = 2; - start = ctx->remain_len; + start = ctx->parse_ctx.remain_len; if ((error = parse_patch_header(patch, ctx)) < 0 || (error = parse_patch_body(patch, ctx)) < 0 || (error = check_patch(patch)) < 0) goto done; - used = start - ctx->remain_len; - ctx->remain += used; + used = start - ctx->parse_ctx.remain_len; + ctx->parse_ctx.remain += used; patch->base.diff_opts.old_prefix = patch->old_prefix; patch->base.diff_opts.new_prefix = patch->new_prefix; patch->base.diff_opts.flags |= GIT_DIFF_SHOW_BINARY; - GIT_REFCOUNT_INC(patch); + GIT_REFCOUNT_INC(&patch->base); *out = &patch->base; done: diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/patch_parse.h r-cran-git2r-0.22.1/src/libgit2/src/patch_parse.h --- r-cran-git2r-0.21.0/src/libgit2/src/patch_parse.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/patch_parse.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,22 +7,17 @@ #ifndef INCLUDE_patch_parse_h__ #define INCLUDE_patch_parse_h__ +#include "common.h" + +#include "parse.h" +#include "patch.h" + typedef struct { git_refcount rc; - /* Original content buffer */ - const char *content; - size_t content_len; - git_patch_options opts; - /* The remaining (unparsed) buffer */ - const char *remain; - size_t remain_len; - - const char *line; - size_t line_len; - size_t line_num; + git_parse_ctx parse_ctx; } git_patch_parse_ctx; extern git_patch_parse_ctx *git_patch_parse_ctx_init( diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/path.c r-cran-git2r-0.22.1/src/libgit2/src/path.c --- r-cran-git2r-0.21.0/src/libgit2/src/path.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/path.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + #include "path.h" + #include "posix.h" #include "repository.h" #ifdef GIT_WIN32 @@ -1560,18 +1561,31 @@ return 0; /* NULL byte -- end of string */ } -static bool verify_dotgit_hfs(const char *path, size_t len) +static bool verify_dotgit_hfs_generic(const char *path, size_t len, const char *needle, size_t needle_len) { - if (next_hfs_char(&path, &len) != '.' || - next_hfs_char(&path, &len) != 'g' || - next_hfs_char(&path, &len) != 'i' || - next_hfs_char(&path, &len) != 't' || - next_hfs_char(&path, &len) != 0) + size_t i; + char c; + + if (next_hfs_char(&path, &len) != '.') + return true; + + for (i = 0; i < needle_len; i++) { + c = next_hfs_char(&path, &len); + if (c != needle[i]) + return true; + } + + if (next_hfs_char(&path, &len) != '\0') return true; return false; } +static bool verify_dotgit_hfs(const char *path, size_t len) +{ + return verify_dotgit_hfs_generic(path, len, "git", CONST_STRLEN("git")); +} + GIT_INLINE(bool) verify_dotgit_ntfs(git_repository *repo, const char *path, size_t len) { git_buf *reserved = git_repository__reserved_names_win32; @@ -1607,6 +1621,57 @@ return false; } +GIT_INLINE(bool) only_spaces_and_dots(const char *path) +{ + const char *c = path; + + for (;; c++) { + if (*c == '\0') + return true; + if (*c != ' ' && *c != '.') + return false; + } + + return true; +} + +GIT_INLINE(bool) verify_dotgit_ntfs_generic(const char *name, size_t len, const char *dotgit_name, size_t dotgit_len, const char *shortname_pfix) +{ + int i, saw_tilde; + + if (name[0] == '.' && len >= dotgit_len && + !strncasecmp(name + 1, dotgit_name, dotgit_len)) { + return !only_spaces_and_dots(name + dotgit_len + 1); + } + + /* Detect the basic NTFS shortname with the first six chars */ + if (!strncasecmp(name, dotgit_name, 6) && name[6] == '~' && + name[7] >= '1' && name[7] <= '4') + return !only_spaces_and_dots(name + 8); + + /* Catch fallback names */ + for (i = 0, saw_tilde = 0; i < 8; i++) { + if (name[i] == '\0') { + return true; + } else if (saw_tilde) { + if (name[i] < '0' || name[i] > '9') + return true; + } else if (name[i] == '~') { + if (name[i+1] < '1' || name[i+1] > '9') + return true; + saw_tilde = 1; + } else if (i >= 6) { + return true; + } else if (name[i] < 0) { + return true; + } else if (git__tolower(name[i]) != shortname_pfix[i]) { + return true; + } + } + + return !only_spaces_and_dots(name + i); +} + GIT_INLINE(bool) verify_char(unsigned char c, unsigned int flags) { if ((flags & GIT_PATH_REJECT_BACKSLASH) && c == '\\') @@ -1635,6 +1700,24 @@ } /* + * Return the length of the common prefix between str and prefix, comparing them + * case-insensitively (must be ASCII to match). + */ +GIT_INLINE(size_t) common_prefix_icase(const char *str, size_t len, const char *prefix) +{ + size_t count = 0; + + while (len >0 && tolower(*str) == tolower(*prefix)) { + count++; + str++; + prefix++; + len--; + } + + return count; +} + +/* * We fundamentally don't like some paths when dealing with user-inputted * strings (in checkout or ref names): we don't want dot or dot-dot * anywhere, we want to avoid writing weird paths on Windows that can't @@ -1647,6 +1730,7 @@ git_repository *repo, const char *component, size_t len, + uint16_t mode, unsigned int flags) { if (len == 0) @@ -1679,26 +1763,38 @@ return false; } - if (flags & GIT_PATH_REJECT_DOT_GIT_HFS && - !verify_dotgit_hfs(component, len)) - return false; + if (flags & GIT_PATH_REJECT_DOT_GIT_HFS) { + if (!verify_dotgit_hfs(component, len)) + return false; + if (S_ISLNK(mode) && git_path_is_hfs_dotgit_modules(component, len)) + return false; + } - if (flags & GIT_PATH_REJECT_DOT_GIT_NTFS && - !verify_dotgit_ntfs(repo, component, len)) - return false; + if (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) { + if (!verify_dotgit_ntfs(repo, component, len)) + return false; + if (S_ISLNK(mode) && git_path_is_ntfs_dotgit_modules(component, len)) + return false; + } /* don't bother rerunning the `.git` test if we ran the HFS or NTFS * specific tests, they would have already rejected `.git`. */ if ((flags & GIT_PATH_REJECT_DOT_GIT_HFS) == 0 && - (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) == 0 && - (flags & GIT_PATH_REJECT_DOT_GIT_LITERAL) && - len == 4 && - component[0] == '.' && - (component[1] == 'g' || component[1] == 'G') && - (component[2] == 'i' || component[2] == 'I') && - (component[3] == 't' || component[3] == 'T')) - return false; + (flags & GIT_PATH_REJECT_DOT_GIT_NTFS) == 0 && + (flags & GIT_PATH_REJECT_DOT_GIT_LITERAL)) { + if (len >= 4 && + component[0] == '.' && + (component[1] == 'g' || component[1] == 'G') && + (component[2] == 'i' || component[2] == 'I') && + (component[3] == 't' || component[3] == 'T')) { + if (len == 4) + return false; + + if (S_ISLNK(mode) && common_prefix_icase(component, len, ".gitmodules") == len) + return false; + } + } return true; } @@ -1736,6 +1832,7 @@ bool git_path_isvalid( git_repository *repo, const char *path, + uint16_t mode, unsigned int flags) { const char *start, *c; @@ -1749,14 +1846,14 @@ return false; if (*c == '/') { - if (!verify_component(repo, start, (c - start), flags)) + if (!verify_component(repo, start, (c - start), mode, flags)) return false; start = c+1; } } - return verify_component(repo, start, (c - start), flags); + return verify_component(repo, start, (c - start), mode, flags); } int git_path_normalize_slashes(git_buf *out, const char *path) @@ -1774,3 +1871,65 @@ return 0; } + +static int verify_dotgit_generic(const char *name, size_t len, const char *dotgit_name, size_t dotgit_len, const char *shortname_pfix) +{ + if (!verify_dotgit_ntfs_generic(name, len, dotgit_name, dotgit_len, shortname_pfix)) + return false; + + return verify_dotgit_hfs_generic(name, len, dotgit_name, dotgit_len); +} + +int git_path_is_ntfs_dotgit_modules(const char *name, size_t len) +{ + return !verify_dotgit_ntfs_generic(name, len, "gitmodules", CONST_STRLEN("gitmodules"), "gi7eba"); +} + +int git_path_is_hfs_dotgit_modules(const char *name, size_t len) +{ + return !verify_dotgit_hfs_generic(name, len, "gitmodules", CONST_STRLEN("gitmodules")); +} + +int git_path_is_dotgit_modules(const char *name, size_t len) +{ + if (git_path_is_hfs_dotgit_modules(name, len)) + return 1; + + return git_path_is_ntfs_dotgit_modules(name, len); +} + +int git_path_is_ntfs_dotgit_ignore(const char *name, size_t len) +{ + return !verify_dotgit_ntfs_generic(name, len, "gitignore", CONST_STRLEN("gitignore"), "gi250a"); +} + +int git_path_is_hfs_dotgit_ignore(const char *name, size_t len) +{ + return !verify_dotgit_hfs_generic(name, len, "gitignore", CONST_STRLEN("gitignore")); +} + +int git_path_is_dotgit_ignore(const char *name, size_t len) +{ + if (git_path_is_hfs_dotgit_ignore(name, len)) + return 1; + + return git_path_is_ntfs_dotgit_ignore(name, len); +} + +int git_path_is_hfs_dotgit_attributes(const char *name, size_t len) +{ + return !verify_dotgit_hfs_generic(name, len, "gitattributes", CONST_STRLEN("gitattributes")); +} + +int git_path_is_ntfs_dotgit_attributes(const char *name, size_t len) +{ + return !verify_dotgit_ntfs_generic(name, len, "gitattributes", CONST_STRLEN("gitattributes"), "gi7d29"); +} + +int git_path_is_dotgit_attributes(const char *name, size_t len) +{ + if (git_path_is_hfs_dotgit_attributes(name, len)) + return 1; + + return git_path_is_ntfs_dotgit_attributes(name, len); +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/path.h r-cran-git2r-0.22.1/src/libgit2/src/path.h --- r-cran-git2r-0.21.0/src/libgit2/src/path.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/path.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_path_h__ #include "common.h" + #include "posix.h" #include "buffer.h" #include "vector.h" @@ -104,6 +105,12 @@ (name[1] == L'.' && name[2] == L'\0'))); } +#define git_path_is_absolute(p) \ + (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/')) + +#define git_path_is_dirsep(p) \ + ((p) == '/' || (p) == '\\') + /** * Convert backslashes in path to forward slashes. */ @@ -118,6 +125,13 @@ } #else # define git_path_mkposix(p) /* blank */ + +#define git_path_is_absolute(p) \ + ((p)[0] == '/') + +#define git_path_is_dirsep(p) \ + ((p) == '/') + #endif /** @@ -623,6 +637,7 @@ extern bool git_path_isvalid( git_repository *repo, const char *path, + uint16_t mode, unsigned int flags); /** @@ -630,4 +645,76 @@ */ int git_path_normalize_slashes(git_buf *out, const char *path); +/** + * Check whether a path component corresponds to a .gitmodules file + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_dotgit_modules(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitmodules file in NTFS + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_ntfs_dotgit_modules(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitmodules file in HFS+ + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_hfs_dotgit_modules(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitignore file + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_dotgit_ignore(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitignore file in NTFS + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_ntfs_dotgit_ignore(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitignore file in HFS+ + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_hfs_dotgit_ignore(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitignore file + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_dotgit_attributes(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitattributes file in NTFS + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_ntfs_dotgit_attributes(const char *name, size_t len); + +/** + * Check whether a path component corresponds to a .gitattributes file in HFS+ + * + * @param name the path component to check + * @param len the length of `name` + */ +extern int git_path_is_hfs_dotgit_attributes(const char *name, size_t len); + #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pathspec.c r-cran-git2r-0.22.1/src/libgit2/src/pathspec.c --- r-cran-git2r-0.21.0/src/libgit2/src/pathspec.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pathspec.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "pathspec.h" + #include "git2/pathspec.h" #include "git2/diff.h" -#include "pathspec.h" #include "buf_text.h" #include "attr_file.h" #include "iterator.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pathspec.h r-cran-git2r-0.22.1/src/libgit2/src/pathspec.h --- r-cran-git2r-0.21.0/src/libgit2/src/pathspec.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pathspec.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,7 +8,8 @@ #define INCLUDE_pathspec_h__ #include "common.h" -#include + +#include "git2/pathspec.h" #include "buffer.h" #include "vector.h" #include "pool.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pool.c r-cran-git2r-0.22.1/src/libgit2/src/pool.c --- r-cran-git2r-0.21.0/src/libgit2/src/pool.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pool.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,4 +1,12 @@ +/* + * 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. + */ + #include "pool.h" + #include "posix.h" #ifndef GIT_WIN32 #include diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pool.h r-cran-git2r-0.22.1/src/libgit2/src/pool.h --- r-cran-git2r-0.21.0/src/libgit2/src/pool.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pool.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_pool_h__ #include "common.h" + #include "vector.h" typedef struct git_pool_page git_pool_page; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/posix.c r-cran-git2r-0.22.1/src/libgit2/src/posix.c --- r-cran-git2r-0.21.0/src/libgit2/src/posix.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/posix.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" + #include "posix.h" + #include "path.h" #include #include @@ -40,7 +41,7 @@ if (ainfo->ai_servent) ainfo->ai_port = ainfo->ai_servent->s_port; else - ainfo->ai_port = atol(port); + ainfo->ai_port = htons(atol(port)); memcpy(&ainfo->ai_addr_in.sin_addr, ainfo->ai_hostent->h_addr_list[0], diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/posix.h r-cran-git2r-0.22.1/src/libgit2/src/posix.h --- r-cran-git2r-0.21.0/src/libgit2/src/posix.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/posix.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_posix_h__ #include "common.h" + #include #include #include "fnmatch.h" @@ -59,6 +60,9 @@ #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif +#ifndef SOCK_CLOEXEC +#define SOCK_CLOEXEC 0 +#endif /* access() mode parameter #defines */ #ifndef F_OK diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pqueue.c r-cran-git2r-0.22.1/src/libgit2/src/pqueue.c --- r-cran-git2r-0.21.0/src/libgit2/src/pqueue.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pqueue.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "pqueue.h" + #include "util.h" #define PQUEUE_LCHILD_OF(I) (((I)<<1)+1) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/pqueue.h r-cran-git2r-0.22.1/src/libgit2/src/pqueue.h --- r-cran-git2r-0.21.0/src/libgit2/src/pqueue.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/pqueue.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_pqueue_h__ #define INCLUDE_pqueue_h__ +#include "common.h" + #include "vector.h" typedef git_vector git_pqueue; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/proxy.c r-cran-git2r-0.22.1/src/libgit2/src/proxy.c --- r-cran-git2r-0.21.0/src/libgit2/src/proxy.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/proxy.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "proxy.h" + #include "git2/proxy.h" int git_proxy_init_options(git_proxy_options *opts, unsigned int version) @@ -30,3 +31,9 @@ return 0; } + +void git_proxy_options_clear(git_proxy_options *opts) +{ + git__free((char *) opts->url); + opts->url = NULL; +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/proxy.h r-cran-git2r-0.22.1/src/libgit2/src/proxy.h --- r-cran-git2r-0.21.0/src/libgit2/src/proxy.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/proxy.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,8 +7,11 @@ #ifndef INCLUDE_proxy_h__ #define INCLUDE_proxy_h__ +#include "common.h" + #include "git2/proxy.h" extern int git_proxy_options_dup(git_proxy_options *tgt, const git_proxy_options *src); +extern void git_proxy_options_clear(git_proxy_options *opts); #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/push.c r-cran-git2r-0.22.1/src/libgit2/src/push.c --- r-cran-git2r-0.21.0/src/libgit2/src/push.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/push.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,14 +5,14 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "push.h" + #include "git2.h" -#include "common.h" #include "pack.h" #include "pack-objects.h" #include "remote.h" #include "vector.h" -#include "push.h" #include "tree.h" static int push_spec_rref_cmp(const void *a, const void *b) @@ -178,6 +178,9 @@ if (!fetch_spec) continue; + /* Clear the buffer which can be dirty from previous iteration */ + git_buf_clear(&remote_ref_name); + if ((error = git_refspec_transform(&remote_ref_name, fetch_spec, status->ref)) < 0) goto on_error; @@ -260,12 +263,11 @@ return error; } -static int revwalk(git_vector *commits, git_push *push) +static int queue_objects(git_push *push) { git_remote_head *head; push_spec *spec; git_revwalk *rw; - git_oid oid; unsigned int i; int error = -1; @@ -350,176 +352,10 @@ git_revwalk_hide(rw, &head->oid); } - while ((error = git_revwalk_next(&oid, rw)) == 0) { - git_oid *o = git__malloc(GIT_OID_RAWSZ); - if (!o) { - error = -1; - goto on_error; - } - git_oid_cpy(o, &oid); - if ((error = git_vector_insert(commits, o)) < 0) - goto on_error; - } + error = git_packbuilder_insert_walk(push->pb, rw); on_error: git_revwalk_free(rw); - return error == GIT_ITEROVER ? 0 : error; -} - -static int enqueue_object( - const git_tree_entry *entry, - git_packbuilder *pb) -{ - switch (git_tree_entry_type(entry)) { - case GIT_OBJ_COMMIT: - return 0; - case GIT_OBJ_TREE: - return git_packbuilder_insert_tree(pb, entry->oid); - default: - return git_packbuilder_insert(pb, entry->oid, entry->filename); - } -} - -static int queue_differences( - git_tree *base, - git_tree *delta, - git_packbuilder *pb) -{ - git_tree *b_child = NULL, *d_child = NULL; - size_t b_length = git_tree_entrycount(base); - size_t d_length = git_tree_entrycount(delta); - size_t i = 0, j = 0; - int error; - - while (i < b_length && j < d_length) { - const git_tree_entry *b_entry = git_tree_entry_byindex(base, i); - const git_tree_entry *d_entry = git_tree_entry_byindex(delta, j); - int cmp = 0; - - if (!git_oid__cmp(b_entry->oid, d_entry->oid)) - goto loop; - - cmp = strcmp(b_entry->filename, d_entry->filename); - - /* If the entries are both trees and they have the same name but are - * different, then we'll recurse after adding the right-hand entry */ - if (!cmp && - git_tree_entry__is_tree(b_entry) && - git_tree_entry__is_tree(d_entry)) { - /* Add the right-hand entry */ - if ((error = git_packbuilder_insert(pb, d_entry->oid, - d_entry->filename)) < 0) - goto on_error; - - /* Acquire the subtrees and recurse */ - if ((error = git_tree_lookup(&b_child, - git_tree_owner(base), b_entry->oid)) < 0 || - (error = git_tree_lookup(&d_child, - git_tree_owner(delta), d_entry->oid)) < 0 || - (error = queue_differences(b_child, d_child, pb)) < 0) - goto on_error; - - git_tree_free(b_child); b_child = NULL; - git_tree_free(d_child); d_child = NULL; - } - /* If the object is new or different in the right-hand tree, - * then enumerate it */ - else if (cmp >= 0 && - (error = enqueue_object(d_entry, pb)) < 0) - goto on_error; - - loop: - if (cmp <= 0) i++; - if (cmp >= 0) j++; - } - - /* Drain the right-hand tree of entries */ - for (; j < d_length; j++) - if ((error = enqueue_object(git_tree_entry_byindex(delta, j), pb)) < 0) - goto on_error; - - error = 0; - -on_error: - if (b_child) - git_tree_free(b_child); - - if (d_child) - git_tree_free(d_child); - - return error; -} - -static int queue_objects(git_push *push) -{ - git_vector commits = GIT_VECTOR_INIT; - git_oid *oid; - size_t i; - unsigned j; - int error; - - if ((error = revwalk(&commits, push)) < 0) - goto on_error; - - git_vector_foreach(&commits, i, oid) { - git_commit *parent = NULL, *commit; - git_tree *tree = NULL, *ptree = NULL; - size_t parentcount; - - if ((error = git_commit_lookup(&commit, push->repo, oid)) < 0) - goto on_error; - - /* Insert the commit */ - if ((error = git_packbuilder_insert(push->pb, oid, NULL)) < 0) - goto loop_error; - - parentcount = git_commit_parentcount(commit); - - if (!parentcount) { - if ((error = git_packbuilder_insert_tree(push->pb, - git_commit_tree_id(commit))) < 0) - goto loop_error; - } else { - if ((error = git_tree_lookup(&tree, push->repo, - git_commit_tree_id(commit))) < 0 || - (error = git_packbuilder_insert(push->pb, - git_commit_tree_id(commit), NULL)) < 0) - goto loop_error; - - /* For each parent, add the items which are different */ - for (j = 0; j < parentcount; j++) { - if ((error = git_commit_parent(&parent, commit, j)) < 0 || - (error = git_commit_tree(&ptree, parent)) < 0 || - (error = queue_differences(ptree, tree, push->pb)) < 0) - goto loop_error; - - git_tree_free(ptree); ptree = NULL; - git_commit_free(parent); parent = NULL; - } - } - - error = 0; - - loop_error: - if (tree) - git_tree_free(tree); - - if (ptree) - git_tree_free(ptree); - - if (parent) - git_commit_free(parent); - - git_commit_free(commit); - - if (error < 0) - goto on_error; - } - - error = 0; - -on_error: - git_vector_free_deep(&commits); return error; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/push.h r-cran-git2r-0.22.1/src/libgit2/src/push.h --- r-cran-git2r-0.21.0/src/libgit2/src/push.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/push.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_push_h__ #define INCLUDE_push_h__ +#include "common.h" + #include "git2.h" #include "refspec.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/rebase.c r-cran-git2r-0.22.1/src/libgit2/src/rebase.c --- r-cran-git2r-0.21.0/src/libgit2/src/rebase.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/rebase.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "buffer.h" #include "repository.h" #include "posix.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refdb.c r-cran-git2r-0.22.1/src/libgit2/src/refdb.c --- r-cran-git2r-0.21.0/src/libgit2/src/refdb.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refdb.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,7 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "posix.h" +#include "refdb.h" #include "git2/object.h" #include "git2/refs.h" @@ -14,9 +13,9 @@ #include "git2/sys/refdb_backend.h" #include "hash.h" -#include "refdb.h" #include "refs.h" #include "reflog.h" +#include "posix.h" int git_refdb_new(git_refdb **out, git_repository *repo) { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refdb_fs.c r-cran-git2r-0.22.1/src/libgit2/src/refdb_fs.c --- r-cran-git2r-0.21.0/src/libgit2/src/refdb_fs.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refdb_fs.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "refdb_fs.h" + #include "refs.h" #include "hash.h" #include "repository.h" @@ -13,7 +15,6 @@ #include "pack.h" #include "reflog.h" #include "refdb.h" -#include "refdb_fs.h" #include "iterator.h" #include "sortedcache.h" #include "signature.h" @@ -743,7 +744,7 @@ assert(file && backend && name); - if (!git_path_isvalid(backend->repo, name, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) { + if (!git_path_isvalid(backend->repo, name, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) { giterr_set(GITERR_INVALID, "invalid reference name '%s'", name); return GIT_EINVALIDSPEC; } @@ -1602,6 +1603,8 @@ GIT_INLINE(int) retrieve_reflog_path(git_buf *path, git_repository *repo, const char *name) { + if (strcmp(name, GIT_HEAD_FILE) == 0) + return git_buf_join3(path, '/', repo->gitdir, GIT_REFLOG_DIR, name); return git_buf_join3(path, '/', repo->commondir, GIT_REFLOG_DIR, name); } @@ -1739,7 +1742,7 @@ repo = backend->repo; - if (!git_path_isvalid(backend->repo, refname, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) { + if (!git_path_isvalid(backend->repo, refname, 0, GIT_PATH_REJECT_FILESYSTEM_DEFAULTS)) { giterr_set(GITERR_INVALID, "invalid reference name '%s'", refname); return GIT_EINVALIDSPEC; } @@ -2034,6 +2037,7 @@ if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) || git_repository__fsync_gitdir) backend->fsync = 1; + backend->iterator_flags |= GIT_ITERATOR_DESCEND_SYMLINKS; backend->parent.exists = &refdb_fs_backend__exists; backend->parent.lookup = &refdb_fs_backend__lookup; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refdb_fs.h r-cran-git2r-0.22.1/src/libgit2/src/refdb_fs.h --- r-cran-git2r-0.21.0/src/libgit2/src/refdb_fs.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refdb_fs.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,10 @@ #ifndef INCLUDE_refdb_fs_h__ #define INCLUDE_refdb_fs_h__ +#include "common.h" + +#include "strmap.h" + typedef struct { git_strmap *packfile; time_t packfile_time; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refdb.h r-cran-git2r-0.22.1/src/libgit2/src/refdb.h --- r-cran-git2r-0.21.0/src/libgit2/src/refdb.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refdb.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_refdb_h__ #define INCLUDE_refdb_h__ +#include "common.h" + #include "git2/refdb.h" #include "repository.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/reflog.c r-cran-git2r-0.22.1/src/libgit2/src/reflog.c --- r-cran-git2r-0.21.0/src/libgit2/src/reflog.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/reflog.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "reflog.h" + #include "repository.h" #include "filebuf.h" #include "signature.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/reflog.h r-cran-git2r-0.22.1/src/libgit2/src/reflog.h --- r-cran-git2r-0.21.0/src/libgit2/src/reflog.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/reflog.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_reflog_h__ #include "common.h" + #include "git2/reflog.h" #include "vector.h" @@ -37,4 +38,4 @@ return (total - 1) - idx; } -#endif /* INCLUDE_reflog_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refs.c r-cran-git2r-0.22.1/src/libgit2/src/refs.c --- r-cran-git2r-0.21.0/src/libgit2/src/refs.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refs.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "refs.h" + #include "hash.h" #include "repository.h" #include "fileops.h" @@ -114,6 +115,9 @@ GITERR_CHECK_ALLOC(*dest); + (*dest)->db = source->db; + GIT_REFCOUNT_INC((*dest)->db); + return 0; } @@ -1359,7 +1363,13 @@ return peel_error(error, ref, "Cannot resolve reference"); } - if (!git_oid_iszero(&resolved->peel)) { + /* + * If we try to peel an object to a tag, we cannot use + * the fully peeled object, as that will always resolve + * to a commit. So we only want to use the peeled value + * if it is not zero and the target is not a tag. + */ + if (target_type != GIT_OBJ_TAG && !git_oid_iszero(&resolved->peel)) { error = git_object_lookup(&target, git_reference_owner(ref), &resolved->peel, GIT_OBJ_ANY); } else { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refs.h r-cran-git2r-0.22.1/src/libgit2/src/refs.h --- r-cran-git2r-0.21.0/src/libgit2/src/refs.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refs.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_refs_h__ #include "common.h" + #include "git2/oid.h" #include "git2/refs.h" #include "git2/refdb.h" @@ -29,7 +30,7 @@ #define GIT_SYMREF "ref: " #define GIT_PACKEDREFS_FILE "packed-refs" -#define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled fully-peeled " +#define GIT_PACKEDREFS_HEADER "# pack-refs with: peeled fully-peeled sorted " #define GIT_PACKEDREFS_FILE_MODE 0666 #define GIT_HEAD_FILE "HEAD" @@ -115,6 +116,10 @@ * with the given name pointing to the reference pointed to by * the file. If it is not a symbolic reference, it will return * the resolved reference. + * + * Note that because the refdb is not involved for symbolic references, they + * won't be owned, hence you should either not make the returned reference + * 'externally visible', or perform the lookup before returning it to the user. */ int git_reference__read_head( git_reference **out, diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refspec.c r-cran-git2r-0.22.1/src/libgit2/src/refspec.c --- r-cran-git2r-0.21.0/src/libgit2/src/refspec.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refspec.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,10 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "refspec.h" + #include "git2/errors.h" -#include "common.h" -#include "refspec.h" #include "util.h" #include "posix.h" #include "refs.h" @@ -304,6 +304,7 @@ git_buf buf = GIT_BUF_INIT; size_t j, pos; git_remote_head key; + git_refspec *cur; const char* formatters[] = { GIT_REFS_DIR "%s", @@ -312,7 +313,9 @@ NULL }; - git_refspec *cur = git__calloc(1, sizeof(git_refspec)); + assert(out && spec && refs); + + cur = git__calloc(1, sizeof(git_refspec)); GITERR_CHECK_ALLOC(cur); cur->force = spec->force; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/refspec.h r-cran-git2r-0.22.1/src/libgit2/src/refspec.h --- r-cran-git2r-0.21.0/src/libgit2/src/refspec.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/refspec.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_refspec_h__ #define INCLUDE_refspec_h__ +#include "common.h" + #include "git2/refspec.h" #include "buffer.h" #include "vector.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/remote.c r-cran-git2r-0.22.1/src/libgit2/src/remote.c --- r-cran-git2r-0.21.0/src/libgit2/src/remote.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/remote.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,15 +5,15 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "remote.h" + #include "git2/config.h" #include "git2/types.h" #include "git2/oid.h" #include "git2/net.h" -#include "common.h" #include "config.h" #include "repository.h" -#include "remote.h" #include "fetch.h" #include "refs.h" #include "refspec.h" @@ -197,10 +197,10 @@ git_buf var = GIT_BUF_INIT; int error = -1; - /* name is optional */ - assert(out && repo && url); + /* repo, name, and fetch are optional */ + assert(out && url); - if ((error = git_repository_config_snapshot(&config_ro, repo)) < 0) + if (repo && (error = git_repository_config_snapshot(&config_ro, repo)) < 0) return error; remote = git__calloc(1, sizeof(git_remote)); @@ -212,7 +212,11 @@ (error = canonicalize_url(&canonical_url, url)) < 0) goto on_error; - remote->url = apply_insteadof(config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH); + if (repo) { + remote->url = apply_insteadof(config_ro, canonical_url.ptr, GIT_DIRECTION_FETCH); + } else { + remote->url = git__strdup(canonical_url.ptr); + } GITERR_CHECK_ALLOC(remote->url); if (name != NULL) { @@ -222,8 +226,9 @@ if ((error = git_buf_printf(&var, CONFIG_URL_FMT, name)) < 0) goto on_error; - if ((error = git_repository_config__weakptr(&config_rw, repo)) < 0 || - (error = git_config_set_string(config_rw, var.ptr, canonical_url.ptr)) < 0) + if (repo && + ((error = git_repository_config__weakptr(&config_rw, repo)) < 0 || + (error = git_config_set_string(config_rw, var.ptr, canonical_url.ptr)) < 0)) goto on_error; } @@ -232,10 +237,10 @@ goto on_error; /* only write for non-anonymous remotes */ - if (name && (error = write_add_refspec(repo, name, fetch, true)) < 0) + if (repo && name && (error = write_add_refspec(repo, name, fetch, true)) < 0) goto on_error; - if ((error = lookup_remote_prune_config(remote, config_ro, name)) < 0) + if (repo && (error = lookup_remote_prune_config(remote, config_ro, name)) < 0) goto on_error; /* Move the data over to where the matching functions can find them */ @@ -330,6 +335,11 @@ return create_internal(out, repo, NULL, url, NULL); } +int git_remote_create_detached(git_remote **out, const char *url) +{ + return create_internal(out, NULL, NULL, url, NULL); +} + int git_remote_dup(git_remote **dest, git_remote *source) { size_t i; @@ -674,7 +684,9 @@ url = git_remote__urlfordirection(remote, direction); if (url == NULL) { giterr_set(GITERR_INVALID, - "Malformed remote '%s' - missing URL", remote->name); + "Malformed remote '%s' - missing %s URL", + remote->name ? remote->name : "(anonymous)", + direction == GIT_DIRECTION_FETCH ? "fetch" : "push"); return -1; } @@ -859,6 +871,11 @@ assert(remote); + if (!remote->repo) { + giterr_set(GITERR_INVALID, "cannot download detached remote"); + return -1; + } + if (opts) { GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); cbs = &opts->callbacks; @@ -1524,6 +1541,20 @@ return error; } +static int truncate_fetch_head(const char *gitdir) +{ + git_buf path = GIT_BUF_INIT; + int error; + + if ((error = git_buf_joinpath(&path, gitdir, GIT_FETCH_HEAD_FILE)) < 0) + return error; + + error = git_futils_truncate(path.ptr, GIT_REFS_FILE_MODE); + git_buf_free(&path); + + return error; +} + int git_remote_update_tips( git_remote *remote, const git_remote_callbacks *callbacks, @@ -1554,6 +1585,9 @@ else tagopt = download_tags; + if ((error = truncate_fetch_head(git_repository_path(remote->repo))) < 0) + goto out; + if (tagopt == GIT_REMOTE_DOWNLOAD_TAGS_ALL) { if ((error = update_tips_for_spec(remote, callbacks, update_fetchhead, tagopt, &tagspec, &refs, reflog_message)) < 0) goto out; @@ -2344,6 +2378,11 @@ assert(remote); + if (!remote->repo) { + giterr_set(GITERR_INVALID, "cannot download detached remote"); + return -1; + } + if (opts) { cbs = &opts->callbacks; custom_headers = &opts->custom_headers; @@ -2403,6 +2442,13 @@ const git_strarray *custom_headers = NULL; const git_proxy_options *proxy = NULL; + assert(remote); + + if (!remote->repo) { + giterr_set(GITERR_INVALID, "cannot download detached remote"); + return -1; + } + if (opts) { GITERR_CHECK_VERSION(&opts->callbacks, GIT_REMOTE_CALLBACKS_VERSION, "git_remote_callbacks"); cbs = &opts->callbacks; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/remote.h r-cran-git2r-0.22.1/src/libgit2/src/remote.h --- r-cran-git2r-0.21.0/src/libgit2/src/remote.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/remote.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_remote_h__ #define INCLUDE_remote_h__ +#include "common.h" + #include "git2/remote.h" #include "git2/transport.h" #include "git2/sys/transport.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/repository.c r-cran-git2r-0.22.1/src/libgit2/src/repository.c --- r-cran-git2r-0.21.0/src/libgit2/src/repository.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/repository.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,14 +4,15 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "repository.h" + #include #include "git2/object.h" -#include "git2/refdb.h" #include "git2/sys/repository.h" #include "common.h" -#include "repository.h" #include "commit.h" #include "tag.h" #include "blob.h" @@ -23,6 +24,7 @@ #include "refs.h" #include "filter.h" #include "odb.h" +#include "refdb.h" #include "remote.h" #include "merge.h" #include "diff_driver.h" @@ -944,7 +946,7 @@ return error; if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0) - error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, 0); + error = git_config_add_file_ondisk(cfg, config_path.ptr, GIT_CONFIG_LEVEL_LOCAL, repo, 0); if (error && error != GIT_ENOTFOUND) goto on_error; @@ -953,25 +955,25 @@ if (global_config_path != NULL && (error = git_config_add_file_ondisk( - cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, 0)) < 0 && + cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, repo, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; if (xdg_config_path != NULL && (error = git_config_add_file_ondisk( - cfg, xdg_config_path, GIT_CONFIG_LEVEL_XDG, 0)) < 0 && + cfg, xdg_config_path, GIT_CONFIG_LEVEL_XDG, repo, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; if (system_config_path != NULL && (error = git_config_add_file_ondisk( - cfg, system_config_path, GIT_CONFIG_LEVEL_SYSTEM, 0)) < 0 && + cfg, system_config_path, GIT_CONFIG_LEVEL_SYSTEM, repo, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; if (programdata_path != NULL && (error = git_config_add_file_ondisk( - cfg, programdata_path, GIT_CONFIG_LEVEL_PROGRAMDATA, 0)) < 0 && + cfg, programdata_path, GIT_CONFIG_LEVEL_PROGRAMDATA, repo, 0)) < 0 && error != GIT_ENOTFOUND) goto on_error; @@ -1235,7 +1237,7 @@ name_len = strlen(name); - if ((name_len == def_len && memcmp(name, def, def_len) == 0) || + if ((name_len == def_len && memcmp(name, def, def_len) == 0) || (name_len == def_dot_git_len && memcmp(name, def_dot_git, def_dot_git_len) == 0)) { git__free(name); return 0; @@ -1473,7 +1475,7 @@ giterr_clear(); if (!(error = git_config_add_file_ondisk( - parent, cfg_path, GIT_CONFIG_LEVEL_LOCAL, false))) + parent, cfg_path, GIT_CONFIG_LEVEL_LOCAL, repo, false))) error = git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL); } @@ -1784,7 +1786,13 @@ default_template = true; } - if (tdir) { + /* + * If tdir was the empty string, treat it like tdir was a path to an + * empty directory (so, don't do any copying). This is the behavior + * that git(1) exhibits, although it doesn't seem to be officially + * documented. + */ + if (tdir && git__strcmp(tdir, "") != 0) { uint32_t cpflags = GIT_CPDIR_COPY_SYMLINKS | GIT_CPDIR_SIMPLE_TO_MODE | GIT_CPDIR_COPY_DOTFILES; @@ -2248,7 +2256,7 @@ return is_empty; } -int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item) +int git_repository_item_path(git_buf *out, const git_repository *repo, git_repository_item_t item) { const char *parent; @@ -2288,13 +2296,13 @@ return 0; } -const char *git_repository_path(git_repository *repo) +const char *git_repository_path(const git_repository *repo) { assert(repo); return repo->gitdir; } -const char *git_repository_workdir(git_repository *repo) +const char *git_repository_workdir(const git_repository *repo) { assert(repo); @@ -2304,7 +2312,7 @@ return repo->workdir; } -const char *git_repository_commondir(git_repository *repo) +const char *git_repository_commondir(const git_repository *repo) { assert(repo); return repo->commondir; @@ -2354,13 +2362,13 @@ return error; } -int git_repository_is_bare(git_repository *repo) +int git_repository_is_bare(const git_repository *repo) { assert(repo); return repo->is_bare; } -int git_repository_is_worktree(git_repository *repo) +int git_repository_is_worktree(const git_repository *repo) { assert(repo); return repo->is_worktree; @@ -2762,7 +2770,7 @@ error = git_futils_rmdir_r(path, NULL, GIT_RMDIR_REMOVE_FILES | GIT_RMDIR_REMOVE_BLOCKERS); } - + git_buf_clear(&buf); } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/repository.h r-cran-git2r-0.22.1/src/libgit2/src/repository.h --- r-cran-git2r-0.21.0/src/libgit2/src/repository.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/repository.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_repository_h__ #define INCLUDE_repository_h__ +#include "common.h" + #include "git2/common.h" #include "git2/oid.h" #include "git2/odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/reset.c r-cran-git2r-0.22.1/src/libgit2/src/reset.c --- r-cran-git2r-0.21.0/src/libgit2/src/reset.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/reset.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "commit.h" #include "tag.h" #include "merge.h" @@ -20,8 +21,8 @@ int git_reset_default( git_repository *repo, - git_object *target, - git_strarray* pathspecs) + const git_object *target, + const git_strarray* pathspecs) { git_object *commit = NULL; git_tree *tree = NULL; @@ -100,7 +101,7 @@ static int reset( git_repository *repo, - git_object *target, + const git_object *target, const char *to, git_reset_t reset_type, const git_checkout_options *checkout_opts) @@ -182,7 +183,7 @@ int git_reset( git_repository *repo, - git_object *target, + const git_object *target, git_reset_t reset_type, const git_checkout_options *checkout_opts) { @@ -191,7 +192,7 @@ int git_reset_from_annotated( git_repository *repo, - git_annotated_commit *commit, + const git_annotated_commit *commit, git_reset_t reset_type, const git_checkout_options *checkout_opts) { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/revert.c r-cran-git2r-0.22.1/src/libgit2/src/revert.c --- r-cran-git2r-0.21.0/src/libgit2/src/revert.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/revert.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "repository.h" #include "filebuf.h" #include "merge.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/revparse.c r-cran-git2r-0.22.1/src/libgit2/src/revparse.c --- r-cran-git2r-0.21.0/src/libgit2/src/revparse.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/revparse.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #include -#include "common.h" #include "buffer.h" #include "tree.h" #include "refdb.h" @@ -769,7 +770,6 @@ } case '@': - { if (spec[pos+1] == '{') { git_object *temp_object = NULL; @@ -785,10 +785,8 @@ if (temp_object != NULL) base_rev = temp_object; break; - } else { - /* Fall through */ } - } + /* fall through */ default: if ((error = ensure_left_hand_identifier_is_not_known_yet(base_rev, reference)) < 0) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/revwalk.c r-cran-git2r-0.22.1/src/libgit2/src/revwalk.c --- r-cran-git2r-0.21.0/src/libgit2/src/revwalk.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/revwalk.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,12 +5,12 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "revwalk.h" + #include "commit.h" #include "odb.h" #include "pool.h" -#include "revwalk.h" #include "git2/revparse.h" #include "merge.h" #include "vector.h" @@ -375,20 +375,6 @@ return 0; } -static int everybody_uninteresting(git_commit_list *orig) -{ - git_commit_list *list = orig; - - while (list) { - git_commit_list_node *commit = list->item; - list = list->next; - if (!commit->uninteresting) - return 0; - } - - return 1; -} - /* How many unintersting commits we want to look at after we run out of interesting ones */ #define SLOP 5 @@ -398,16 +384,15 @@ if (!list) return 0; - /* - * If the destination list has commits with an earlier date - * than our source we want to continue looking. - */ - if (time <= list->item->time) - return SLOP; - - /* If we find interesting commits, we reset the slop count */ - if (!everybody_uninteresting(list)) - return SLOP; + for (; list; list = list->next) { + /* + * If the destination list has commits with an earlier date than + * our source or if it still contains interesting commits we + * want to continue looking. + */ + if (!list->item->uninteresting || list->item->time > time) + return SLOP; + } /* Everything's uninteresting, reduce the count */ return slop - 1; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/revwalk.h r-cran-git2r-0.22.1/src/libgit2/src/revwalk.h --- r-cran-git2r-0.21.0/src/libgit2/src/revwalk.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/revwalk.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_revwalk_h__ #define INCLUDE_revwalk_h__ +#include "common.h" + #include "git2/revwalk.h" #include "oidmap.h" #include "commit_list.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/settings.c r-cran-git2r-0.22.1/src/libgit2/src/settings.c --- r-cran-git2r-0.21.0/src/libgit2/src/settings.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/settings.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,12 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #ifdef GIT_OPENSSL # include #endif #include -#include "common.h" #include "sysdir.h" #include "cache.h" #include "global.h" @@ -18,6 +19,7 @@ #include "odb.h" #include "refs.h" #include "transports/smart.h" +#include "streams/openssl.h" void git_libgit2_version(int *major, int *minor, int *rev) { @@ -171,14 +173,10 @@ { const char *file = va_arg(ap, const char *); const char *path = va_arg(ap, const char *); - if (!SSL_CTX_load_verify_locations(git__ssl_ctx, file, path)) { - giterr_set(GITERR_NET, "SSL error: %s", - ERR_error_string(ERR_get_error(), NULL)); - error = -1; - } + error = git_openssl__set_cert_location(file, path); } #else - giterr_set(GITERR_NET, "cannot set certificate locations: OpenSSL is not enabled"); + giterr_set(GITERR_SSL, "TLS backend doesn't support certificate locations"); error = -1; #endif break; @@ -211,7 +209,7 @@ } } #else - giterr_set(GITERR_NET, "cannot set custom ciphers: OpenSSL is not enabled"); + giterr_set(GITERR_SSL, "TLS backend doesn't support custom ciphers"); error = -1; #endif break; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/sha1_lookup.c r-cran-git2r-0.22.1/src/libgit2/src/sha1_lookup.c --- r-cran-git2r-0.21.0/src/libgit2/src/sha1_lookup.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/sha1_lookup.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,225 +5,11 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include - #include "sha1_lookup.h" -#include "common.h" -#include "oid.h" -/* - * Conventional binary search loop looks like this: - * - * unsigned lo, hi; - * do { - * unsigned mi = (lo + hi) / 2; - * int cmp = "entry pointed at by mi" minus "target"; - * if (!cmp) - * return (mi is the wanted one) - * if (cmp > 0) - * hi = mi; "mi is larger than target" - * else - * lo = mi+1; "mi is smaller than target" - * } while (lo < hi); - * - * The invariants are: - * - * - When entering the loop, lo points at a slot that is never - * above the target (it could be at the target), hi points at a - * slot that is guaranteed to be above the target (it can never - * be at the target). - * - * - We find a point 'mi' between lo and hi (mi could be the same - * as lo, but never can be as same as hi), and check if it hits - * the target. There are three cases: - * - * - if it is a hit, we are happy. - * - * - if it is strictly higher than the target, we set it to hi, - * and repeat the search. - * - * - if it is strictly lower than the target, we update lo to - * one slot after it, because we allow lo to be at the target. - * - * If the loop exits, there is no matching entry. - * - * When choosing 'mi', we do not have to take the "middle" but - * anywhere in between lo and hi, as long as lo <= mi < hi is - * satisfied. When we somehow know that the distance between the - * target and lo is much shorter than the target and hi, we could - * pick mi that is much closer to lo than the midway. - * - * Now, we can take advantage of the fact that SHA-1 is a good hash - * function, and as long as there are enough entries in the table, we - * can expect uniform distribution. An entry that begins with for - * example "deadbeef..." is much likely to appear much later than in - * the midway of the table. It can reasonably be expected to be near - * 87% (222/256) from the top of the table. - * - * However, we do not want to pick "mi" too precisely. If the entry at - * the 87% in the above example turns out to be higher than the target - * we are looking for, we would end up narrowing the search space down - * only by 13%, instead of 50% we would get if we did a simple binary - * search. So we would want to hedge our bets by being less aggressive. - * - * The table at "table" holds at least "nr" entries of "elem_size" - * bytes each. Each entry has the SHA-1 key at "key_offset". The - * table is sorted by the SHA-1 key of the entries. The caller wants - * to find the entry with "key", and knows that the entry at "lo" is - * not higher than the entry it is looking for, and that the entry at - * "hi" is higher than the entry it is looking for. - */ -int sha1_entry_pos(const void *table, - size_t elem_size, - size_t key_offset, - unsigned lo, unsigned hi, unsigned nr, - const unsigned char *key) -{ - const unsigned char *base = (const unsigned char*)table; - const unsigned char *hi_key, *lo_key; - unsigned ofs_0; - - if (!nr || lo >= hi) - return -1; - - if (nr == hi) - hi_key = NULL; - else - hi_key = base + elem_size * hi + key_offset; - lo_key = base + elem_size * lo + key_offset; - - ofs_0 = 0; - do { - int cmp; - unsigned ofs, mi, range; - unsigned lov, hiv, kyv; - const unsigned char *mi_key; - - range = hi - lo; - if (hi_key) { - for (ofs = ofs_0; ofs < 20; ofs++) - if (lo_key[ofs] != hi_key[ofs]) - break; - ofs_0 = ofs; - /* - * byte 0 thru (ofs-1) are the same between - * lo and hi; ofs is the first byte that is - * different. - * - * If ofs==20, then no bytes are different, - * meaning we have entries with duplicate - * keys. We know that we are in a solid run - * of this entry (because the entries are - * sorted, and our lo and hi are the same, - * there can be nothing but this single key - * in between). So we can stop the search. - * Either one of these entries is it (and - * we do not care which), or we do not have - * it. - * - * Furthermore, we know that one of our - * endpoints must be the edge of the run of - * duplicates. For example, given this - * sequence: - * - * idx 0 1 2 3 4 5 - * key A C C C C D - * - * If we are searching for "B", we might - * hit the duplicate run at lo=1, hi=3 - * (e.g., by first mi=3, then mi=0). But we - * can never have lo > 1, because B < C. - * That is, if our key is less than the - * run, we know that "lo" is the edge, but - * we can say nothing of "hi". Similarly, - * if our key is greater than the run, we - * know that "hi" is the edge, but we can - * say nothing of "lo". - * - * Therefore if we do not find it, we also - * know where it would go if it did exist: - * just on the far side of the edge that we - * know about. - */ - if (ofs == 20) { - mi = lo; - mi_key = base + elem_size * mi + key_offset; - cmp = memcmp(mi_key, key, 20); - if (!cmp) - return mi; - if (cmp < 0) - return -1 - hi; - else - return -1 - lo; - } - - hiv = hi_key[ofs_0]; - if (ofs_0 < 19) - hiv = (hiv << 8) | hi_key[ofs_0+1]; - } else { - hiv = 256; - if (ofs_0 < 19) - hiv <<= 8; - } - lov = lo_key[ofs_0]; - kyv = key[ofs_0]; - if (ofs_0 < 19) { - lov = (lov << 8) | lo_key[ofs_0+1]; - kyv = (kyv << 8) | key[ofs_0+1]; - } - assert(lov < hiv); - - if (kyv < lov) - return -1 - lo; - if (hiv < kyv) - return -1 - hi; - - /* - * Even if we know the target is much closer to 'hi' - * than 'lo', if we pick too precisely and overshoot - * (e.g. when we know 'mi' is closer to 'hi' than to - * 'lo', pick 'mi' that is higher than the target), we - * end up narrowing the search space by a smaller - * amount (i.e. the distance between 'mi' and 'hi') - * than what we would have (i.e. about half of 'lo' - * and 'hi'). Hedge our bets to pick 'mi' less - * aggressively, i.e. make 'mi' a bit closer to the - * middle than we would otherwise pick. - */ - kyv = (kyv * 6 + lov + hiv) / 8; - if (lov < hiv - 1) { - if (kyv == lov) - kyv++; - else if (kyv == hiv) - kyv--; - } - mi = (range - 1) * (kyv - lov) / (hiv - lov) + lo; - -#ifdef INDEX_DEBUG_LOOKUP - printf("lo %u hi %u rg %u mi %u ", lo, hi, range, mi); - printf("ofs %u lov %x, hiv %x, kyv %x\n", - ofs_0, lov, hiv, kyv); -#endif - - if (!(lo <= mi && mi < hi)) { - giterr_set(GITERR_INVALID, "assertion failure: binary search invariant is false"); - return -1; - } +#include - mi_key = base + elem_size * mi + key_offset; - cmp = memcmp(mi_key + ofs_0, key + ofs_0, 20 - ofs_0); - if (!cmp) - return mi; - if (cmp > 0) { - hi = mi; - hi_key = mi_key; - } else { - lo = mi + 1; - lo_key = mi_key + elem_size; - } - } while (lo < hi); - return -((int)lo)-1; -} +#include "oid.h" int sha1_position(const void *table, size_t stride, @@ -232,7 +18,7 @@ { const unsigned char *base = table; - do { + while (lo < hi) { unsigned mi = (lo + hi) / 2; int cmp = git_oid__hashcmp(base + mi * stride, key); @@ -243,7 +29,7 @@ hi = mi; else lo = mi+1; - } while (lo < hi); + } return -((int)lo)-1; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/sha1_lookup.h r-cran-git2r-0.22.1/src/libgit2/src/sha1_lookup.h --- r-cran-git2r-0.21.0/src/libgit2/src/sha1_lookup.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/sha1_lookup.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,13 +7,9 @@ #ifndef INCLUDE_sha1_lookup_h__ #define INCLUDE_sha1_lookup_h__ -#include +#include "common.h" -int sha1_entry_pos(const void *table, - size_t elem_size, - size_t key_offset, - unsigned lo, unsigned hi, unsigned nr, - const unsigned char *key); +#include int sha1_position(const void *table, size_t stride, diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/signature.c r-cran-git2r-0.22.1/src/libgit2/src/signature.c --- r-cran-git2r-0.21.0/src/libgit2/src/signature.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/signature.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "signature.h" + #include "repository.h" #include "git2/common.h" #include "posix.h" @@ -90,6 +90,7 @@ p->when.time = time; p->when.offset = offset; + p->when.sign = (offset < 0) ? '-' : '+'; *sig_out = p; return 0; @@ -113,6 +114,7 @@ signature->when.time = source->when.time; signature->when.offset = source->when.offset; + signature->when.sign = source->when.sign; *dest = signature; @@ -137,6 +139,7 @@ signature->when.time = source->when.time; signature->when.offset = source->when.offset; + signature->when.sign = source->when.sign; *dest = signature; @@ -231,6 +234,7 @@ if (git__strtol64(&sig->when.time, time_start, &time_end, 10) < 0) { git__free(sig->name); git__free(sig->email); + sig->name = sig->email = NULL; return signature_error("invalid Unix timestamp"); } @@ -256,6 +260,7 @@ */ if (hours <= 14 && mins <= 59) { sig->when.offset = (hours * 60) + mins; + sig->when.sign = tz_start[0]; if (tz_start[0] == '-') sig->when.offset = -sig->when.offset; } @@ -298,7 +303,7 @@ assert(buf && sig); offset = sig->when.offset; - sign = (sig->when.offset < 0) ? '-' : '+'; + sign = (sig->when.offset < 0 || sig->when.sign == '-') ? '-' : '+'; if (offset < 0) offset = -offset; @@ -319,6 +324,7 @@ git__strcmp(one->name, two->name) == 0 && git__strcmp(one->email, two->email) == 0 && one->when.time == two->when.time && - one->when.offset == two->when.offset; + one->when.offset == two->when.offset && + one->when.sign == two->when.sign; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/signature.h r-cran-git2r-0.22.1/src/libgit2/src/signature.h --- r-cran-git2r-0.21.0/src/libgit2/src/signature.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/signature.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_signature_h__ #define INCLUDE_signature_h__ +#include "common.h" + #include "git2/common.h" #include "git2/signature.h" #include "repository.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/socket_stream.c r-cran-git2r-0.22.1/src/libgit2/src/socket_stream.c --- r-cran-git2r-0.21.0/src/libgit2/src/socket_stream.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/socket_stream.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,210 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "posix.h" -#include "netops.h" -#include "stream.h" -#include "socket_stream.h" - -#ifndef _WIN32 -# include -# include -# include -# include -# include -# include -# include -#else -# include -# include -# ifdef _MSC_VER -# pragma comment(lib, "ws2_32") -# endif -#endif - -#ifdef GIT_WIN32 -static void net_set_error(const char *str) -{ - int error = WSAGetLastError(); - char * win32_error = git_win32_get_error_message(error); - - if (win32_error) { - giterr_set(GITERR_NET, "%s: %s", str, win32_error); - git__free(win32_error); - } else { - giterr_set(GITERR_NET, str); - } -} -#else -static void net_set_error(const char *str) -{ - giterr_set(GITERR_NET, "%s: %s", str, strerror(errno)); -} -#endif - -static int close_socket(GIT_SOCKET s) -{ - if (s == INVALID_SOCKET) - return 0; - -#ifdef GIT_WIN32 - if (SOCKET_ERROR == closesocket(s)) - return -1; - - if (0 != WSACleanup()) { - giterr_set(GITERR_OS, "winsock cleanup failed"); - return -1; - } - - return 0; -#else - return close(s); -#endif - -} - -int socket_connect(git_stream *stream) -{ - struct addrinfo *info = NULL, *p; - struct addrinfo hints; - git_socket_stream *st = (git_socket_stream *) stream; - GIT_SOCKET s = INVALID_SOCKET; - int ret; - -#ifdef GIT_WIN32 - /* on win32, the WSA context needs to be initialized - * before any socket calls can be performed */ - WSADATA wsd; - - if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { - giterr_set(GITERR_OS, "winsock init failed"); - return -1; - } - - if (LOBYTE(wsd.wVersion) != 2 || HIBYTE(wsd.wVersion) != 2) { - WSACleanup(); - giterr_set(GITERR_OS, "winsock init failed"); - return -1; - } -#endif - - memset(&hints, 0x0, sizeof(struct addrinfo)); - hints.ai_socktype = SOCK_STREAM; - hints.ai_family = AF_UNSPEC; - - if ((ret = p_getaddrinfo(st->host, st->port, &hints, &info)) != 0) { - giterr_set(GITERR_NET, - "failed to resolve address for %s: %s", st->host, p_gai_strerror(ret)); - return -1; - } - - for (p = info; p != NULL; p = p->ai_next) { - s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); - - if (s == INVALID_SOCKET) - continue; - - if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0) - break; - - /* If we can't connect, try the next one */ - close_socket(s); - s = INVALID_SOCKET; - } - - /* Oops, we couldn't connect to any address */ - if (s == INVALID_SOCKET && p == NULL) { - giterr_set(GITERR_OS, "failed to connect to %s", st->host); - p_freeaddrinfo(info); - return -1; - } - - st->s = s; - p_freeaddrinfo(info); - return 0; -} - -ssize_t socket_write(git_stream *stream, const char *data, size_t len, int flags) -{ - ssize_t ret; - size_t off = 0; - git_socket_stream *st = (git_socket_stream *) stream; - - while (off < len) { - errno = 0; - ret = p_send(st->s, data + off, len - off, flags); - if (ret < 0) { - net_set_error("Error sending data"); - return -1; - } - - off += ret; - } - - return off; -} - -ssize_t socket_read(git_stream *stream, void *data, size_t len) -{ - ssize_t ret; - git_socket_stream *st = (git_socket_stream *) stream; - - if ((ret = p_recv(st->s, data, len, 0)) < 0) - net_set_error("Error receiving socket data"); - - return ret; -} - -int socket_close(git_stream *stream) -{ - git_socket_stream *st = (git_socket_stream *) stream; - int error; - - error = close_socket(st->s); - st->s = INVALID_SOCKET; - - return error; -} - -void socket_free(git_stream *stream) -{ - git_socket_stream *st = (git_socket_stream *) stream; - - git__free(st->host); - git__free(st->port); - git__free(st); -} - -int git_socket_stream_new(git_stream **out, const char *host, const char *port) -{ - git_socket_stream *st; - - assert(out && host); - - st = git__calloc(1, sizeof(git_socket_stream)); - GITERR_CHECK_ALLOC(st); - - st->host = git__strdup(host); - GITERR_CHECK_ALLOC(st->host); - - if (port) { - st->port = git__strdup(port); - GITERR_CHECK_ALLOC(st->port); - } - - st->parent.version = GIT_STREAM_VERSION; - st->parent.connect = socket_connect; - st->parent.write = socket_write; - st->parent.read = socket_read; - st->parent.close = socket_close; - st->parent.free = socket_free; - st->s = INVALID_SOCKET; - - *out = (git_stream *) st; - return 0; -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/socket_stream.h r-cran-git2r-0.22.1/src/libgit2/src/socket_stream.h --- r-cran-git2r-0.21.0/src/libgit2/src/socket_stream.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/socket_stream.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* - * 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_socket_stream_h__ -#define INCLUDE_socket_stream_h__ - -#include "netops.h" - -typedef struct { - git_stream parent; - char *host; - char *port; - GIT_SOCKET s; -} git_socket_stream; - -extern int git_socket_stream_new(git_stream **out, const char *host, const char *port); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/sortedcache.c r-cran-git2r-0.22.1/src/libgit2/src/sortedcache.c --- r-cran-git2r-0.21.0/src/libgit2/src/sortedcache.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/sortedcache.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,3 +1,10 @@ +/* + * 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. + */ + #include "sortedcache.h" int git_sortedcache_new( diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/sortedcache.h r-cran-git2r-0.22.1/src/libgit2/src/sortedcache.h --- r-cran-git2r-0.21.0/src/libgit2/src/sortedcache.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/sortedcache.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_sorted_cache_h__ #define INCLUDE_sorted_cache_h__ +#include "common.h" + #include "util.h" #include "fileops.h" #include "vector.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/stash.c r-cran-git2r-0.22.1/src/libgit2/src/stash.c --- r-cran-git2r-0.21.0/src/libgit2/src/stash.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/stash.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "repository.h" #include "commit.h" #include "message.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/status.c r-cran-git2r-0.22.1/src/libgit2/src/status.c --- r-cran-git2r-0.21.0/src/libgit2/src/status.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/status.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,13 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "status.h" + #include "git2.h" #include "fileops.h" #include "hash.h" #include "vector.h" #include "tree.h" -#include "status.h" #include "git2/status.h" #include "repository.h" #include "ignore.h" @@ -280,12 +280,16 @@ if ((error = git_repository__ensure_not_bare(repo, "status")) < 0 || (error = git_repository_index(&index, repo)) < 0) return error; - - /* if there is no HEAD, that's okay - we'll make an empty iterator */ - if ((error = git_repository_head_tree(&head, repo)) < 0) { - if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) - goto done; - giterr_clear(); + + if (opts != NULL && opts->baseline != NULL) { + head = opts->baseline; + } else { + /* if there is no HEAD, that's okay - we'll make an empty iterator */ + if ((error = git_repository_head_tree(&head, repo)) < 0) { + if (error != GIT_ENOTFOUND && error != GIT_EUNBORNBRANCH) + goto done; + giterr_clear(); + } } /* refresh index from disk unless prevented */ @@ -377,7 +381,8 @@ *out = status; - git_tree_free(head); + if (opts == NULL || opts->baseline != head) + git_tree_free(head); git_index_free(index); return error; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/status.h r-cran-git2r-0.22.1/src/libgit2/src/status.h --- r-cran-git2r-0.21.0/src/libgit2/src/status.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/status.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_status_h__ #define INCLUDE_status_h__ +#include "common.h" + #include "diff.h" #include "git2/status.h" #include "git2/diff.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/stransport_stream.h r-cran-git2r-0.22.1/src/libgit2/src/stransport_stream.h --- r-cran-git2r-0.21.0/src/libgit2/src/stransport_stream.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/stransport_stream.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* - * 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_stransport_stream_h__ -#define INCLUDE_stransport_stream_h__ - -#include "git2/sys/stream.h" - -extern int git_stransport_stream_new(git_stream **out, const char *host, const char *port); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/curl.c r-cran-git2r-0.22.1/src/libgit2/src/streams/curl.c --- r-cran-git2r-0.21.0/src/libgit2/src/streams/curl.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/curl.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,385 @@ +/* + * 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. + */ + +#include "streams/curl.h" + +#ifdef GIT_CURL + +#include + +#include "stream.h" +#include "git2/transport.h" +#include "buffer.h" +#include "global.h" +#include "vector.h" +#include "proxy.h" + +/* This is for backwards compatibility with curl<7.45.0. */ +#ifndef CURLINFO_ACTIVESOCKET +# define CURLINFO_ACTIVESOCKET CURLINFO_LASTSOCKET +# define GIT_CURL_BADSOCKET -1 +# define git_activesocket_t long +#else +# define GIT_CURL_BADSOCKET CURL_SOCKET_BAD +# define git_activesocket_t curl_socket_t +#endif + +typedef struct { + git_stream parent; + CURL *handle; + curl_socket_t socket; + char curl_error[CURL_ERROR_SIZE + 1]; + git_cert_x509 cert_info; + git_strarray cert_info_strings; + git_proxy_options proxy; + git_cred *proxy_cred; +} curl_stream; + +int git_curl_stream_global_init(void) +{ + if (curl_global_init(CURL_GLOBAL_ALL) != 0) { + giterr_set(GITERR_NET, "could not initialize curl"); + return -1; + } + + /* `curl_global_cleanup` is provided by libcurl */ + git__on_shutdown(curl_global_cleanup); + return 0; +} + +static int seterr_curl(curl_stream *s) +{ + giterr_set(GITERR_NET, "curl error: %s\n", s->curl_error); + return -1; +} + +GIT_INLINE(int) error_no_credentials(void) +{ + giterr_set(GITERR_NET, "proxy authentication required, but no callback provided"); + return GIT_EAUTH; +} + +static int apply_proxy_creds(curl_stream *s) +{ + CURLcode res; + git_cred_userpass_plaintext *userpass; + + if (!s->proxy_cred) + return GIT_ENOTFOUND; + + userpass = (git_cred_userpass_plaintext *) s->proxy_cred; + if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXYUSERNAME, userpass->username)) != CURLE_OK) + return seterr_curl(s); + if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXYPASSWORD, userpass->password)) != CURLE_OK) + return seterr_curl(s); + + return 0; +} + +static int ask_and_apply_proxy_creds(curl_stream *s) +{ + int error; + git_proxy_options *opts = &s->proxy; + + if (!opts->credentials) + return error_no_credentials(); + + /* TODO: see if PROXYAUTH_AVAIL helps us here */ + git_cred_free(s->proxy_cred); + s->proxy_cred = NULL; + giterr_clear(); + error = opts->credentials(&s->proxy_cred, opts->url, NULL, GIT_CREDTYPE_USERPASS_PLAINTEXT, opts->payload); + if (error == GIT_PASSTHROUGH) + return error_no_credentials(); + if (error < 0) { + if (!giterr_last()) + giterr_set(GITERR_NET, "proxy authentication was aborted by the user"); + return error; + } + + if (s->proxy_cred->credtype != GIT_CREDTYPE_USERPASS_PLAINTEXT) { + giterr_set(GITERR_NET, "credentials callback returned invalid credential type"); + return -1; + } + + return apply_proxy_creds(s); +} + +static int curls_connect(git_stream *stream) +{ + curl_stream *s = (curl_stream *) stream; + git_activesocket_t sockextr; + long connect_last = 0; + int failed_cert = 0, error; + bool retry_connect; + CURLcode res; + + /* Apply any credentials we've already established */ + error = apply_proxy_creds(s); + if (error < 0 && error != GIT_ENOTFOUND) + return seterr_curl(s); + + do { + retry_connect = 0; + res = curl_easy_perform(s->handle); + + curl_easy_getinfo(s->handle, CURLINFO_HTTP_CONNECTCODE, &connect_last); + + /* HTTP 407 Proxy Authentication Required */ + if (connect_last == 407) { + if ((error = ask_and_apply_proxy_creds(s)) < 0) + return error; + + retry_connect = true; + } + } while (retry_connect); + + if (res != CURLE_OK && res != CURLE_PEER_FAILED_VERIFICATION) + return seterr_curl(s); + if (res == CURLE_PEER_FAILED_VERIFICATION) + failed_cert = 1; + + if ((res = curl_easy_getinfo(s->handle, CURLINFO_ACTIVESOCKET, &sockextr)) != CURLE_OK) { + return seterr_curl(s); + } + + if (sockextr == GIT_CURL_BADSOCKET) { + giterr_set(GITERR_NET, "curl socket is no longer valid"); + return -1; + } + + s->socket = sockextr; + + if (s->parent.encrypted && failed_cert) + return GIT_ECERTIFICATE; + + return 0; +} + +static int curls_certificate(git_cert **out, git_stream *stream) +{ + int error; + CURLcode res; + struct curl_slist *slist; + struct curl_certinfo *certinfo; + git_vector strings = GIT_VECTOR_INIT; + curl_stream *s = (curl_stream *) stream; + + if ((res = curl_easy_getinfo(s->handle, CURLINFO_CERTINFO, &certinfo)) != CURLE_OK) + return seterr_curl(s); + + /* No information is available, can happen with SecureTransport */ + if (certinfo->num_of_certs == 0) { + s->cert_info.parent.cert_type = GIT_CERT_NONE; + s->cert_info.data = NULL; + s->cert_info.len = 0; + return 0; + } + + if ((error = git_vector_init(&strings, 8, NULL)) < 0) + return error; + + for (slist = certinfo->certinfo[0]; slist; slist = slist->next) { + char *str = git__strdup(slist->data); + GITERR_CHECK_ALLOC(str); + git_vector_insert(&strings, str); + } + + /* Copy the contents of the vector into a strarray so we can expose them */ + s->cert_info_strings.strings = (char **) strings.contents; + s->cert_info_strings.count = strings.length; + + s->cert_info.parent.cert_type = GIT_CERT_STRARRAY; + s->cert_info.data = &s->cert_info_strings; + s->cert_info.len = strings.length; + + *out = &s->cert_info.parent; + + return 0; +} + +static int curls_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts) +{ + int error; + CURLcode res; + curl_stream *s = (curl_stream *) stream; + + git_proxy_options_clear(&s->proxy); + if ((error = git_proxy_options_dup(&s->proxy, proxy_opts)) < 0) + return error; + + if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXY, s->proxy.url)) != CURLE_OK) + return seterr_curl(s); + + if ((res = curl_easy_setopt(s->handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY)) != CURLE_OK) + return seterr_curl(s); + + return 0; +} + +static int wait_for(curl_socket_t fd, bool reading) +{ + int ret; + fd_set infd, outfd, errfd; + + FD_ZERO(&infd); + FD_ZERO(&outfd); + FD_ZERO(&errfd); + + assert(fd >= 0); + FD_SET(fd, &errfd); + if (reading) + FD_SET(fd, &infd); + else + FD_SET(fd, &outfd); + + if ((ret = select(fd + 1, &infd, &outfd, &errfd, NULL)) < 0) { + giterr_set(GITERR_OS, "error in select"); + return -1; + } + + return 0; +} + +static ssize_t curls_write(git_stream *stream, const char *data, size_t len, int flags) +{ + int error; + size_t off = 0, sent; + CURLcode res; + curl_stream *s = (curl_stream *) stream; + + GIT_UNUSED(flags); + + do { + if ((error = wait_for(s->socket, false)) < 0) + return error; + + res = curl_easy_send(s->handle, data + off, len - off, &sent); + if (res == CURLE_OK) + off += sent; + } while ((res == CURLE_OK || res == CURLE_AGAIN) && off < len); + + if (res != CURLE_OK) + return seterr_curl(s); + + return len; +} + +static ssize_t curls_read(git_stream *stream, void *data, size_t len) +{ + int error; + size_t read; + CURLcode res; + curl_stream *s = (curl_stream *) stream; + + do { + if ((error = wait_for(s->socket, true)) < 0) + return error; + + res = curl_easy_recv(s->handle, data, len, &read); + } while (res == CURLE_AGAIN); + + if (res != CURLE_OK) + return seterr_curl(s); + + return read; +} + +static int curls_close(git_stream *stream) +{ + curl_stream *s = (curl_stream *) stream; + + if (!s->handle) + return 0; + + curl_easy_cleanup(s->handle); + s->handle = NULL; + s->socket = 0; + + return 0; +} + +static void curls_free(git_stream *stream) +{ + curl_stream *s = (curl_stream *) stream; + + curls_close(stream); + git_strarray_free(&s->cert_info_strings); + git_proxy_options_clear(&s->proxy); + git_cred_free(s->proxy_cred); + git__free(s); +} + +int git_curl_stream_new(git_stream **out, const char *host, const char *port) +{ + curl_stream *st; + CURL *handle; + int iport = 0, error; + + st = git__calloc(1, sizeof(curl_stream)); + GITERR_CHECK_ALLOC(st); + + handle = curl_easy_init(); + if (handle == NULL) { + giterr_set(GITERR_NET, "failed to create curl handle"); + git__free(st); + return -1; + } + + if ((error = git__strtol32(&iport, port, NULL, 10)) < 0) { + git__free(st); + return error; + } + + curl_easy_setopt(handle, CURLOPT_URL, host); + curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, st->curl_error); + curl_easy_setopt(handle, CURLOPT_PORT, iport); + curl_easy_setopt(handle, CURLOPT_CONNECT_ONLY, 1); + curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 1); + curl_easy_setopt(handle, CURLOPT_CERTINFO, 1); + curl_easy_setopt(handle, CURLOPT_HTTPPROXYTUNNEL, 1); + curl_easy_setopt(handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY); + + /* curl_easy_setopt(handle, CURLOPT_VERBOSE, 1); */ + + st->parent.version = GIT_STREAM_VERSION; + st->parent.encrypted = 0; /* we don't encrypt ourselves */ + st->parent.proxy_support = 1; + st->parent.connect = curls_connect; + st->parent.certificate = curls_certificate; + st->parent.set_proxy = curls_set_proxy; + st->parent.read = curls_read; + st->parent.write = curls_write; + st->parent.close = curls_close; + st->parent.free = curls_free; + st->handle = handle; + + *out = (git_stream *) st; + return 0; +} + +#else + +#include "stream.h" + +int git_curl_stream_global_init(void) +{ + return 0; +} + +int git_curl_stream_new(git_stream **out, const char *host, const char *port) +{ + GIT_UNUSED(out); + GIT_UNUSED(host); + GIT_UNUSED(port); + + giterr_set(GITERR_NET, "curl is not supported in this version"); + return -1; +} + + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/curl.h r-cran-git2r-0.22.1/src/libgit2/src/streams/curl.h --- r-cran-git2r-0.21.0/src/libgit2/src/streams/curl.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/curl.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,17 @@ +/* + * 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_streams_curl_h__ +#define INCLUDE_streams_curl_h__ + +#include "common.h" + +#include "git2/sys/stream.h" + +extern int git_curl_stream_global_init(void); +extern int git_curl_stream_new(git_stream **out, const char *host, const char *port); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/openssl.c r-cran-git2r-0.22.1/src/libgit2/src/streams/openssl.c --- r-cran-git2r-0.21.0/src/libgit2/src/streams/openssl.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/openssl.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,699 @@ +/* + * 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. + */ + +#include "streams/openssl.h" + +#ifdef GIT_OPENSSL + +#include + +#include "global.h" +#include "posix.h" +#include "stream.h" +#include "streams/socket.h" +#include "netops.h" +#include "git2/transport.h" +#include "git2/sys/openssl.h" + +#ifdef GIT_CURL +# include "streams/curl.h" +#endif + +#ifndef GIT_WIN32 +# include +# include +# include +#endif + +#include +#include +#include +#include + +SSL_CTX *git__ssl_ctx; + +#define GIT_SSL_DEFAULT_CIPHERS "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES128-SHA256:DHE-DSS-AES256-SHA256:DHE-DSS-AES128-SHA:DHE-DSS-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA" + +#if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L + +static git_mutex *openssl_locks; + +static void openssl_locking_function( + int mode, int n, const char *file, int line) +{ + int lock; + + GIT_UNUSED(file); + GIT_UNUSED(line); + + lock = mode & CRYPTO_LOCK; + + if (lock) { + git_mutex_lock(&openssl_locks[n]); + } else { + git_mutex_unlock(&openssl_locks[n]); + } +} + +static void shutdown_ssl_locking(void) +{ + int num_locks, i; + + num_locks = CRYPTO_num_locks(); + CRYPTO_set_locking_callback(NULL); + + for (i = 0; i < num_locks; ++i) + git_mutex_free(&openssl_locks[i]); + git__free(openssl_locks); +} + +#endif /* GIT_THREADS && OPENSSL_VERSION_NUMBER < 0x10100000L */ + +static BIO_METHOD *git_stream_bio_method; +static int init_bio_method(void); + +/** + * This function aims to clean-up the SSL context which + * we allocated. + */ +static void shutdown_ssl(void) +{ + if (git_stream_bio_method) { + BIO_meth_free(git_stream_bio_method); + git_stream_bio_method = NULL; + } + + if (git__ssl_ctx) { + SSL_CTX_free(git__ssl_ctx); + git__ssl_ctx = NULL; + } +} + +int git_openssl_stream_global_init(void) +{ +#ifdef GIT_OPENSSL + long ssl_opts = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3; + const char *ciphers = git_libgit2__ssl_ciphers(); + + /* Older OpenSSL and MacOS OpenSSL doesn't have this */ +#ifdef SSL_OP_NO_COMPRESSION + ssl_opts |= SSL_OP_NO_COMPRESSION; +#endif + +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \ + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + SSL_load_error_strings(); + OpenSSL_add_ssl_algorithms(); +#else + OPENSSL_init_ssl(0, NULL); +#endif + + /* + * Load SSLv{2,3} and TLSv1 so that we can talk with servers + * which use the SSL hellos, which are often used for + * compatibility. We then disable SSL so we only allow OpenSSL + * to speak TLSv1 to perform the encryption itself. + */ + git__ssl_ctx = SSL_CTX_new(SSLv23_method()); + SSL_CTX_set_options(git__ssl_ctx, ssl_opts); + SSL_CTX_set_mode(git__ssl_ctx, SSL_MODE_AUTO_RETRY); + SSL_CTX_set_verify(git__ssl_ctx, SSL_VERIFY_NONE, NULL); + if (!SSL_CTX_set_default_verify_paths(git__ssl_ctx)) { + SSL_CTX_free(git__ssl_ctx); + git__ssl_ctx = NULL; + return -1; + } + + if (!ciphers) { + ciphers = GIT_SSL_DEFAULT_CIPHERS; + } + + if(!SSL_CTX_set_cipher_list(git__ssl_ctx, ciphers)) { + SSL_CTX_free(git__ssl_ctx); + git__ssl_ctx = NULL; + return -1; + } + + if (init_bio_method() < 0) { + SSL_CTX_free(git__ssl_ctx); + git__ssl_ctx = NULL; + return -1; + } + +#endif + + git__on_shutdown(shutdown_ssl); + + return 0; +} + +#if defined(GIT_THREADS) +static void threadid_cb(CRYPTO_THREADID *threadid) +{ + CRYPTO_THREADID_set_numeric(threadid, git_thread_currentid()); +} +#endif + +int git_openssl_set_locking(void) +{ +#if defined(GIT_THREADS) && OPENSSL_VERSION_NUMBER < 0x10100000L + int num_locks, i; + + CRYPTO_THREADID_set_callback(threadid_cb); + + num_locks = CRYPTO_num_locks(); + openssl_locks = git__calloc(num_locks, sizeof(git_mutex)); + GITERR_CHECK_ALLOC(openssl_locks); + + for (i = 0; i < num_locks; i++) { + if (git_mutex_init(&openssl_locks[i]) != 0) { + giterr_set(GITERR_SSL, "failed to initialize openssl locks"); + return -1; + } + } + + CRYPTO_set_locking_callback(openssl_locking_function); + git__on_shutdown(shutdown_ssl_locking); + return 0; +#elif OPENSSL_VERSION_NUMBER >= 0x10100000L + return 0; +#else + giterr_set(GITERR_THREAD, "libgit2 was not built with threads"); + return -1; +#endif +} + + +static int bio_create(BIO *b) +{ + BIO_set_init(b, 1); + BIO_set_data(b, NULL); + + return 1; +} + +static int bio_destroy(BIO *b) +{ + if (!b) + return 0; + + BIO_set_data(b, NULL); + + return 1; +} + +static int bio_read(BIO *b, char *buf, int len) +{ + git_stream *io = (git_stream *) BIO_get_data(b); + + return (int) git_stream_read(io, buf, len); +} + +static int bio_write(BIO *b, const char *buf, int len) +{ + git_stream *io = (git_stream *) BIO_get_data(b); + + return (int) git_stream_write(io, buf, len, 0); +} + +static long bio_ctrl(BIO *b, int cmd, long num, void *ptr) +{ + GIT_UNUSED(b); + GIT_UNUSED(num); + GIT_UNUSED(ptr); + + if (cmd == BIO_CTRL_FLUSH) + return 1; + + return 0; +} + +static int bio_gets(BIO *b, char *buf, int len) +{ + GIT_UNUSED(b); + GIT_UNUSED(buf); + GIT_UNUSED(len); + return -1; +} + +static int bio_puts(BIO *b, const char *str) +{ + return bio_write(b, str, strlen(str)); +} + +static int init_bio_method(void) +{ + /* Set up the BIO_METHOD we use for wrapping our own stream implementations */ + git_stream_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK | BIO_get_new_index(), "git_stream"); + GITERR_CHECK_ALLOC(git_stream_bio_method); + + BIO_meth_set_write(git_stream_bio_method, bio_write); + BIO_meth_set_read(git_stream_bio_method, bio_read); + BIO_meth_set_puts(git_stream_bio_method, bio_puts); + BIO_meth_set_gets(git_stream_bio_method, bio_gets); + BIO_meth_set_ctrl(git_stream_bio_method, bio_ctrl); + BIO_meth_set_create(git_stream_bio_method, bio_create); + BIO_meth_set_destroy(git_stream_bio_method, bio_destroy); + + return 0; +} + +static int ssl_set_error(SSL *ssl, int error) +{ + int err; + unsigned long e; + + err = SSL_get_error(ssl, error); + + assert(err != SSL_ERROR_WANT_READ); + assert(err != SSL_ERROR_WANT_WRITE); + + switch (err) { + case SSL_ERROR_WANT_CONNECT: + case SSL_ERROR_WANT_ACCEPT: + giterr_set(GITERR_NET, "SSL error: connection failure"); + break; + case SSL_ERROR_WANT_X509_LOOKUP: + giterr_set(GITERR_NET, "SSL error: x509 error"); + break; + case SSL_ERROR_SYSCALL: + e = ERR_get_error(); + if (e > 0) { + char errmsg[256]; + ERR_error_string_n(e, errmsg, sizeof(errmsg)); + giterr_set(GITERR_NET, "SSL error: %s", errmsg); + break; + } else if (error < 0) { + giterr_set(GITERR_OS, "SSL error: syscall failure"); + break; + } + giterr_set(GITERR_NET, "SSL error: received early EOF"); + return GIT_EEOF; + break; + case SSL_ERROR_SSL: + { + char errmsg[256]; + e = ERR_get_error(); + ERR_error_string_n(e, errmsg, sizeof(errmsg)); + giterr_set(GITERR_NET, "SSL error: %s", errmsg); + break; + } + case SSL_ERROR_NONE: + case SSL_ERROR_ZERO_RETURN: + default: + giterr_set(GITERR_NET, "SSL error: unknown error"); + break; + } + return -1; +} + +static int ssl_teardown(SSL *ssl) +{ + int ret; + + ret = SSL_shutdown(ssl); + if (ret < 0) + ret = ssl_set_error(ssl, ret); + else + ret = 0; + + return ret; +} + +static int check_host_name(const char *name, const char *host) +{ + if (!strcasecmp(name, host)) + return 0; + + if (gitno__match_host(name, host) < 0) + return -1; + + return 0; +} + +static int verify_server_cert(SSL *ssl, const char *host) +{ + X509 *cert = NULL; + X509_NAME *peer_name; + ASN1_STRING *str; + unsigned char *peer_cn = NULL; + int matched = -1, type = GEN_DNS; + GENERAL_NAMES *alts; + struct in6_addr addr6; + struct in_addr addr4; + void *addr = NULL; + int i = -1, j, error = 0; + + if (SSL_get_verify_result(ssl) != X509_V_OK) { + giterr_set(GITERR_SSL, "the SSL certificate is invalid"); + return GIT_ECERTIFICATE; + } + + /* Try to parse the host as an IP address to see if it is */ + if (p_inet_pton(AF_INET, host, &addr4)) { + type = GEN_IPADD; + addr = &addr4; + } else { + if (p_inet_pton(AF_INET6, host, &addr6)) { + type = GEN_IPADD; + addr = &addr6; + } + } + + + cert = SSL_get_peer_certificate(ssl); + if (!cert) { + error = -1; + giterr_set(GITERR_SSL, "the server did not provide a certificate"); + goto cleanup; + } + + /* Check the alternative names */ + alts = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); + if (alts) { + int num; + + num = sk_GENERAL_NAME_num(alts); + for (i = 0; i < num && matched != 1; i++) { + const GENERAL_NAME *gn = sk_GENERAL_NAME_value(alts, i); + const char *name = (char *) ASN1_STRING_get0_data(gn->d.ia5); + size_t namelen = (size_t) ASN1_STRING_length(gn->d.ia5); + + /* Skip any names of a type we're not looking for */ + if (gn->type != type) + continue; + + if (type == GEN_DNS) { + /* If it contains embedded NULs, don't even try */ + if (memchr(name, '\0', namelen)) + continue; + + if (check_host_name(name, host) < 0) + matched = 0; + else + matched = 1; + } else if (type == GEN_IPADD) { + /* Here name isn't so much a name but a binary representation of the IP */ + matched = addr && !!memcmp(name, addr, namelen); + } + } + } + GENERAL_NAMES_free(alts); + + if (matched == 0) + goto cert_fail_name; + + if (matched == 1) { + goto cleanup; + } + + /* If no alternative names are available, check the common name */ + peer_name = X509_get_subject_name(cert); + if (peer_name == NULL) + goto on_error; + + if (peer_name) { + /* Get the index of the last CN entry */ + while ((j = X509_NAME_get_index_by_NID(peer_name, NID_commonName, i)) >= 0) + i = j; + } + + if (i < 0) + goto on_error; + + str = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(peer_name, i)); + if (str == NULL) + goto on_error; + + /* Work around a bug in OpenSSL whereby ASN1_STRING_to_UTF8 fails if it's already in utf-8 */ + if (ASN1_STRING_type(str) == V_ASN1_UTF8STRING) { + int size = ASN1_STRING_length(str); + + if (size > 0) { + peer_cn = OPENSSL_malloc(size + 1); + GITERR_CHECK_ALLOC(peer_cn); + memcpy(peer_cn, ASN1_STRING_get0_data(str), size); + peer_cn[size] = '\0'; + } else { + goto cert_fail_name; + } + } else { + int size = ASN1_STRING_to_UTF8(&peer_cn, str); + GITERR_CHECK_ALLOC(peer_cn); + if (memchr(peer_cn, '\0', size)) + goto cert_fail_name; + } + + if (check_host_name((char *)peer_cn, host) < 0) + goto cert_fail_name; + + goto cleanup; + +cert_fail_name: + error = GIT_ECERTIFICATE; + giterr_set(GITERR_SSL, "hostname does not match certificate"); + goto cleanup; + +on_error: + error = ssl_set_error(ssl, 0); + goto cleanup; + +cleanup: + X509_free(cert); + OPENSSL_free(peer_cn); + return error; +} + +typedef struct { + git_stream parent; + git_stream *io; + bool connected; + char *host; + SSL *ssl; + git_cert_x509 cert_info; +} openssl_stream; + +int openssl_close(git_stream *stream); + +int openssl_connect(git_stream *stream) +{ + int ret; + BIO *bio; + openssl_stream *st = (openssl_stream *) stream; + + if ((ret = git_stream_connect(st->io)) < 0) + return ret; + + st->connected = true; + + bio = BIO_new(git_stream_bio_method); + GITERR_CHECK_ALLOC(bio); + + BIO_set_data(bio, st->io); + SSL_set_bio(st->ssl, bio, bio); + + /* specify the host in case SNI is needed */ +#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME + SSL_set_tlsext_host_name(st->ssl, st->host); +#endif + + if ((ret = SSL_connect(st->ssl)) <= 0) + return ssl_set_error(st->ssl, ret); + + return verify_server_cert(st->ssl, st->host); +} + +int openssl_certificate(git_cert **out, git_stream *stream) +{ + openssl_stream *st = (openssl_stream *) stream; + int len; + X509 *cert = SSL_get_peer_certificate(st->ssl); + unsigned char *guard, *encoded_cert; + + /* Retrieve the length of the certificate first */ + len = i2d_X509(cert, NULL); + if (len < 0) { + giterr_set(GITERR_NET, "failed to retrieve certificate information"); + return -1; + } + + encoded_cert = git__malloc(len); + GITERR_CHECK_ALLOC(encoded_cert); + /* i2d_X509 makes 'guard' point to just after the data */ + guard = encoded_cert; + + len = i2d_X509(cert, &guard); + if (len < 0) { + git__free(encoded_cert); + giterr_set(GITERR_NET, "failed to retrieve certificate information"); + return -1; + } + + st->cert_info.parent.cert_type = GIT_CERT_X509; + st->cert_info.data = encoded_cert; + st->cert_info.len = len; + + *out = &st->cert_info.parent; + + return 0; +} + +static int openssl_set_proxy(git_stream *stream, const git_proxy_options *proxy_opts) +{ + openssl_stream *st = (openssl_stream *) stream; + + return git_stream_set_proxy(st->io, proxy_opts); +} + +ssize_t openssl_write(git_stream *stream, const char *data, size_t len, int flags) +{ + openssl_stream *st = (openssl_stream *) stream; + int ret; + + GIT_UNUSED(flags); + + if ((ret = SSL_write(st->ssl, data, len)) <= 0) { + return ssl_set_error(st->ssl, ret); + } + + return ret; +} + +ssize_t openssl_read(git_stream *stream, void *data, size_t len) +{ + openssl_stream *st = (openssl_stream *) stream; + int ret; + + if ((ret = SSL_read(st->ssl, data, len)) <= 0) + return ssl_set_error(st->ssl, ret); + + return ret; +} + +int openssl_close(git_stream *stream) +{ + openssl_stream *st = (openssl_stream *) stream; + int ret; + + if (st->connected && (ret = ssl_teardown(st->ssl)) < 0) + return -1; + + st->connected = false; + + return git_stream_close(st->io); +} + +void openssl_free(git_stream *stream) +{ + openssl_stream *st = (openssl_stream *) stream; + + SSL_free(st->ssl); + git__free(st->host); + git__free(st->cert_info.data); + git_stream_free(st->io); + git__free(st); +} + +int git_openssl_stream_new(git_stream **out, const char *host, const char *port) +{ + int error; + openssl_stream *st; + + st = git__calloc(1, sizeof(openssl_stream)); + GITERR_CHECK_ALLOC(st); + + st->io = NULL; +#ifdef GIT_CURL + error = git_curl_stream_new(&st->io, host, port); +#else + error = git_socket_stream_new(&st->io, host, port); +#endif + + if (error < 0) + goto out_err; + + st->ssl = SSL_new(git__ssl_ctx); + if (st->ssl == NULL) { + giterr_set(GITERR_SSL, "failed to create ssl object"); + error = -1; + goto out_err; + } + + st->host = git__strdup(host); + GITERR_CHECK_ALLOC(st->host); + + st->parent.version = GIT_STREAM_VERSION; + st->parent.encrypted = 1; + st->parent.proxy_support = git_stream_supports_proxy(st->io); + st->parent.connect = openssl_connect; + st->parent.certificate = openssl_certificate; + st->parent.set_proxy = openssl_set_proxy; + st->parent.read = openssl_read; + st->parent.write = openssl_write; + st->parent.close = openssl_close; + st->parent.free = openssl_free; + + *out = (git_stream *) st; + return 0; + +out_err: + git_stream_free(st->io); + git__free(st); + + return error; +} + +int git_openssl__set_cert_location(const char *file, const char *path) +{ + if (SSL_CTX_load_verify_locations(git__ssl_ctx, file, path) == 0) { + char errmsg[256]; + + ERR_error_string_n(ERR_get_error(), errmsg, sizeof(errmsg)); + giterr_set(GITERR_SSL, "OpenSSL error: failed to load certificates: %s", + errmsg); + + return -1; + } + return 0; +} + +#else + +#include "stream.h" +#include "git2/sys/openssl.h" + +int git_openssl_stream_global_init(void) +{ + return 0; +} + +int git_openssl_set_locking(void) +{ + giterr_set(GITERR_SSL, "libgit2 was not built with OpenSSL support"); + return -1; +} + +int git_openssl_stream_new(git_stream **out, const char *host, const char *port) +{ + GIT_UNUSED(out); + GIT_UNUSED(host); + GIT_UNUSED(port); + + giterr_set(GITERR_SSL, "openssl is not supported in this version"); + return -1; +} + +int git_openssl__set_cert_location(const char *file, const char *path) +{ + GIT_UNUSED(file); + GIT_UNUSED(path); + + giterr_set(GITERR_SSL, "openssl is not supported in this version"); + return -1; +} + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/openssl.h r-cran-git2r-0.22.1/src/libgit2/src/streams/openssl.h --- r-cran-git2r-0.21.0/src/libgit2/src/streams/openssl.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/openssl.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,127 @@ +/* + * 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_streams_openssl_h__ +#define INCLUDE_streams_openssl_h__ + +#include "common.h" + +#include "git2/sys/stream.h" + +extern int git_openssl_stream_global_init(void); + +extern int git_openssl_stream_new(git_stream **out, const char *host, const char *port); + +extern int git_openssl__set_cert_location(const char *file, const char *path); + +/* + * OpenSSL 1.1 made BIO opaque so we have to use functions to interact with it + * which do not exist in previous versions. We define these inline functions so + * we can program against the interface instead of littering the implementation + * with ifdefs. + */ +#ifdef GIT_OPENSSL +# include +# include +# include +# include + + + +# if OPENSSL_VERSION_NUMBER < 0x10100000L || \ + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + +GIT_INLINE(BIO_METHOD*) BIO_meth_new(int type, const char *name) +{ + BIO_METHOD *meth = git__calloc(1, sizeof(BIO_METHOD)); + if (!meth) { + return NULL; + } + + meth->type = type; + meth->name = name; + + return meth; +} + +GIT_INLINE(void) BIO_meth_free(BIO_METHOD *biom) +{ + git__free(biom); +} + +GIT_INLINE(int) BIO_meth_set_write(BIO_METHOD *biom, int (*write) (BIO *, const char *, int)) +{ + biom->bwrite = write; + return 1; +} + +GIT_INLINE(int) BIO_meth_set_read(BIO_METHOD *biom, int (*read) (BIO *, char *, int)) +{ + biom->bread = read; + return 1; +} + +GIT_INLINE(int) BIO_meth_set_puts(BIO_METHOD *biom, int (*puts) (BIO *, const char *)) +{ + biom->bputs = puts; + return 1; +} + +GIT_INLINE(int) BIO_meth_set_gets(BIO_METHOD *biom, int (*gets) (BIO *, char *, int)) + +{ + biom->bgets = gets; + return 1; +} + +GIT_INLINE(int) BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl) (BIO *, int, long, void *)) +{ + biom->ctrl = ctrl; + return 1; +} + +GIT_INLINE(int) BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *)) +{ + biom->create = create; + return 1; +} + +GIT_INLINE(int) BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *)) +{ + biom->destroy = destroy; + return 1; +} + +GIT_INLINE(int) BIO_get_new_index(void) +{ + /* This exists as of 1.1 so before we'd just have 0 */ + return 0; +} + +GIT_INLINE(void) BIO_set_init(BIO *b, int init) +{ + b->init = init; +} + +GIT_INLINE(void) BIO_set_data(BIO *a, void *ptr) +{ + a->ptr = ptr; +} + +GIT_INLINE(void*) BIO_get_data(BIO *a) +{ + return a->ptr; +} + +GIT_INLINE(const unsigned char *) ASN1_STRING_get0_data(const ASN1_STRING *x) +{ + return ASN1_STRING_data((ASN1_STRING *)x); +} + +# endif // OpenSSL < 1.1 +#endif // GIT_OPENSSL + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/socket.c r-cran-git2r-0.22.1/src/libgit2/src/streams/socket.c --- r-cran-git2r-0.21.0/src/libgit2/src/streams/socket.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/socket.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,210 @@ +/* + * 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. + */ + +#include "streams/socket.h" + +#include "posix.h" +#include "netops.h" +#include "stream.h" + +#ifndef _WIN32 +# include +# include +# include +# include +# include +# include +# include +#else +# include +# include +# ifdef _MSC_VER +# pragma comment(lib, "ws2_32") +# endif +#endif + +#ifdef GIT_WIN32 +static void net_set_error(const char *str) +{ + int error = WSAGetLastError(); + char * win32_error = git_win32_get_error_message(error); + + if (win32_error) { + giterr_set(GITERR_NET, "%s: %s", str, win32_error); + git__free(win32_error); + } else { + giterr_set(GITERR_NET, str); + } +} +#else +static void net_set_error(const char *str) +{ + giterr_set(GITERR_NET, "%s: %s", str, strerror(errno)); +} +#endif + +static int close_socket(GIT_SOCKET s) +{ + if (s == INVALID_SOCKET) + return 0; + +#ifdef GIT_WIN32 + if (SOCKET_ERROR == closesocket(s)) + return -1; + + if (0 != WSACleanup()) { + giterr_set(GITERR_OS, "winsock cleanup failed"); + return -1; + } + + return 0; +#else + return close(s); +#endif + +} + +int socket_connect(git_stream *stream) +{ + struct addrinfo *info = NULL, *p; + struct addrinfo hints; + git_socket_stream *st = (git_socket_stream *) stream; + GIT_SOCKET s = INVALID_SOCKET; + int ret; + +#ifdef GIT_WIN32 + /* on win32, the WSA context needs to be initialized + * before any socket calls can be performed */ + WSADATA wsd; + + if (WSAStartup(MAKEWORD(2,2), &wsd) != 0) { + giterr_set(GITERR_OS, "winsock init failed"); + return -1; + } + + if (LOBYTE(wsd.wVersion) != 2 || HIBYTE(wsd.wVersion) != 2) { + WSACleanup(); + giterr_set(GITERR_OS, "winsock init failed"); + return -1; + } +#endif + + memset(&hints, 0x0, sizeof(struct addrinfo)); + hints.ai_socktype = SOCK_STREAM; + hints.ai_family = AF_UNSPEC; + + if ((ret = p_getaddrinfo(st->host, st->port, &hints, &info)) != 0) { + giterr_set(GITERR_NET, + "failed to resolve address for %s: %s", st->host, p_gai_strerror(ret)); + return -1; + } + + for (p = info; p != NULL; p = p->ai_next) { + s = socket(p->ai_family, p->ai_socktype | SOCK_CLOEXEC, p->ai_protocol); + + if (s == INVALID_SOCKET) + continue; + + if (connect(s, p->ai_addr, (socklen_t)p->ai_addrlen) == 0) + break; + + /* If we can't connect, try the next one */ + close_socket(s); + s = INVALID_SOCKET; + } + + /* Oops, we couldn't connect to any address */ + if (s == INVALID_SOCKET && p == NULL) { + giterr_set(GITERR_OS, "failed to connect to %s", st->host); + p_freeaddrinfo(info); + return -1; + } + + st->s = s; + p_freeaddrinfo(info); + return 0; +} + +ssize_t socket_write(git_stream *stream, const char *data, size_t len, int flags) +{ + ssize_t ret; + size_t off = 0; + git_socket_stream *st = (git_socket_stream *) stream; + + while (off < len) { + errno = 0; + ret = p_send(st->s, data + off, len - off, flags); + if (ret < 0) { + net_set_error("Error sending data"); + return -1; + } + + off += ret; + } + + return off; +} + +ssize_t socket_read(git_stream *stream, void *data, size_t len) +{ + ssize_t ret; + git_socket_stream *st = (git_socket_stream *) stream; + + if ((ret = p_recv(st->s, data, len, 0)) < 0) + net_set_error("Error receiving socket data"); + + return ret; +} + +int socket_close(git_stream *stream) +{ + git_socket_stream *st = (git_socket_stream *) stream; + int error; + + error = close_socket(st->s); + st->s = INVALID_SOCKET; + + return error; +} + +void socket_free(git_stream *stream) +{ + git_socket_stream *st = (git_socket_stream *) stream; + + git__free(st->host); + git__free(st->port); + git__free(st); +} + +int git_socket_stream_new(git_stream **out, const char *host, const char *port) +{ + git_socket_stream *st; + + assert(out && host); + + st = git__calloc(1, sizeof(git_socket_stream)); + GITERR_CHECK_ALLOC(st); + + st->host = git__strdup(host); + GITERR_CHECK_ALLOC(st->host); + + if (port) { + st->port = git__strdup(port); + GITERR_CHECK_ALLOC(st->port); + } + + st->parent.version = GIT_STREAM_VERSION; + st->parent.connect = socket_connect; + st->parent.write = socket_write; + st->parent.read = socket_read; + st->parent.close = socket_close; + st->parent.free = socket_free; + st->s = INVALID_SOCKET; + + *out = (git_stream *) st; + return 0; +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/socket.h r-cran-git2r-0.22.1/src/libgit2/src/streams/socket.h --- r-cran-git2r-0.21.0/src/libgit2/src/streams/socket.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/socket.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,23 @@ +/* + * 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_streams_socket_h__ +#define INCLUDE_streams_socket_h__ + +#include "common.h" + +#include "netops.h" + +typedef struct { + git_stream parent; + char *host; + char *port; + GIT_SOCKET s; +} git_socket_stream; + +extern int git_socket_stream_new(git_stream **out, const char *host, const char *port); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/stransport.c r-cran-git2r-0.22.1/src/libgit2/src/streams/stransport.c --- r-cran-git2r-0.21.0/src/libgit2/src/streams/stransport.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/stransport.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,298 @@ +/* + * 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. + */ + +#include "streams/stransport.h" + +#ifdef GIT_SECURE_TRANSPORT + +#include +#include +#include + +#include "git2/transport.h" + +#include "streams/socket.h" +#include "streams/curl.h" + +static int stransport_error(OSStatus ret) +{ + CFStringRef message; + + if (ret == noErr || ret == errSSLClosedGraceful) { + giterr_clear(); + return 0; + } + +#if !TARGET_OS_IPHONE + message = SecCopyErrorMessageString(ret, NULL); + GITERR_CHECK_ALLOC(message); + + giterr_set(GITERR_NET, "SecureTransport error: %s", CFStringGetCStringPtr(message, kCFStringEncodingUTF8)); + CFRelease(message); +#else + giterr_set(GITERR_NET, "SecureTransport error: OSStatus %d", (unsigned int)ret); + GIT_UNUSED(message); +#endif + + return -1; +} + +typedef struct { + git_stream parent; + git_stream *io; + SSLContextRef ctx; + CFDataRef der_data; + git_cert_x509 cert_info; +} stransport_stream; + +static int stransport_connect(git_stream *stream) +{ + stransport_stream *st = (stransport_stream *) stream; + int error; + SecTrustRef trust = NULL; + SecTrustResultType sec_res; + OSStatus ret; + + if ((error = git_stream_connect(st->io)) < 0) + return error; + + ret = SSLHandshake(st->ctx); + if (ret != errSSLServerAuthCompleted) { + giterr_set(GITERR_SSL, "unexpected return value from ssl handshake %d", ret); + return -1; + } + + if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr) + goto on_error; + + if (!trust) + return GIT_ECERTIFICATE; + + if ((ret = SecTrustEvaluate(trust, &sec_res)) != noErr) + goto on_error; + + CFRelease(trust); + + if (sec_res == kSecTrustResultInvalid || sec_res == kSecTrustResultOtherError) { + giterr_set(GITERR_SSL, "internal security trust error"); + return -1; + } + + if (sec_res == kSecTrustResultDeny || sec_res == kSecTrustResultRecoverableTrustFailure || + sec_res == kSecTrustResultFatalTrustFailure) { + giterr_set(GITERR_SSL, "untrusted connection error"); + return GIT_ECERTIFICATE; + } + + return 0; + +on_error: + if (trust) + CFRelease(trust); + + return stransport_error(ret); +} + +static int stransport_certificate(git_cert **out, git_stream *stream) +{ + stransport_stream *st = (stransport_stream *) stream; + SecTrustRef trust = NULL; + SecCertificateRef sec_cert; + OSStatus ret; + + if ((ret = SSLCopyPeerTrust(st->ctx, &trust)) != noErr) + return stransport_error(ret); + + sec_cert = SecTrustGetCertificateAtIndex(trust, 0); + st->der_data = SecCertificateCopyData(sec_cert); + CFRelease(trust); + + if (st->der_data == NULL) { + giterr_set(GITERR_SSL, "retrieved invalid certificate data"); + return -1; + } + + st->cert_info.parent.cert_type = GIT_CERT_X509; + st->cert_info.data = (void *) CFDataGetBytePtr(st->der_data); + st->cert_info.len = CFDataGetLength(st->der_data); + + *out = (git_cert *)&st->cert_info; + return 0; +} + +static int stransport_set_proxy( + git_stream *stream, + const git_proxy_options *proxy_opts) +{ + stransport_stream *st = (stransport_stream *) stream; + + return git_stream_set_proxy(st->io, proxy_opts); +} + +/* + * Contrary to typical network IO callbacks, Secure Transport write callback is + * expected to write *all* passed data, not just as much as it can, and any + * other case would be considered a failure. + * + * This behavior is actually not specified in the Apple documentation, but is + * required for things to work correctly (and incidentally, that's also how + * Apple implements it in its projects at opensource.apple.com). + * + * Libgit2 streams happen to already have this very behavior so this is just + * passthrough. + */ +static OSStatus write_cb(SSLConnectionRef conn, const void *data, size_t *len) +{ + git_stream *io = (git_stream *) conn; + + if (git_stream_write(io, data, *len, 0) < 0) { + return -36; /* "ioErr" from MacErrors.h which is not available on iOS */ + } + + return noErr; +} + +static ssize_t stransport_write(git_stream *stream, const char *data, size_t len, int flags) +{ + stransport_stream *st = (stransport_stream *) stream; + size_t data_len, processed; + OSStatus ret; + + GIT_UNUSED(flags); + + data_len = len; + if ((ret = SSLWrite(st->ctx, data, data_len, &processed)) != noErr) + return stransport_error(ret); + + return processed; +} + +/* + * Contrary to typical network IO callbacks, Secure Transport read callback is + * expected to read *exactly* the requested number of bytes, not just as much + * as it can, and any other case would be considered a failure. + * + * This behavior is actually not specified in the Apple documentation, but is + * required for things to work correctly (and incidentally, that's also how + * Apple implements it in its projects at opensource.apple.com). + */ +static OSStatus read_cb(SSLConnectionRef conn, void *data, size_t *len) +{ + git_stream *io = (git_stream *) conn; + OSStatus error = noErr; + size_t off = 0; + ssize_t ret; + + do { + ret = git_stream_read(io, data + off, *len - off); + if (ret < 0) { + error = -36; /* "ioErr" from MacErrors.h which is not available on iOS */ + break; + } + if (ret == 0) { + error = errSSLClosedGraceful; + break; + } + + off += ret; + } while (off < *len); + + *len = off; + return error; +} + +static ssize_t stransport_read(git_stream *stream, void *data, size_t len) +{ + stransport_stream *st = (stransport_stream *) stream; + size_t processed; + OSStatus ret; + + if ((ret = SSLRead(st->ctx, data, len, &processed)) != noErr) + return stransport_error(ret); + + return processed; +} + +static int stransport_close(git_stream *stream) +{ + stransport_stream *st = (stransport_stream *) stream; + OSStatus ret; + + ret = SSLClose(st->ctx); + if (ret != noErr && ret != errSSLClosedGraceful) + return stransport_error(ret); + + return git_stream_close(st->io); +} + +static void stransport_free(git_stream *stream) +{ + stransport_stream *st = (stransport_stream *) stream; + + git_stream_free(st->io); + CFRelease(st->ctx); + if (st->der_data) + CFRelease(st->der_data); + git__free(st); +} + +int git_stransport_stream_new(git_stream **out, const char *host, const char *port) +{ + stransport_stream *st; + int error; + OSStatus ret; + + assert(out && host); + + st = git__calloc(1, sizeof(stransport_stream)); + GITERR_CHECK_ALLOC(st); + +#ifdef GIT_CURL + error = git_curl_stream_new(&st->io, host, port); +#else + error = git_socket_stream_new(&st->io, host, port); +#endif + + if (error < 0){ + git__free(st); + return error; + } + + st->ctx = SSLCreateContext(NULL, kSSLClientSide, kSSLStreamType); + if (!st->ctx) { + giterr_set(GITERR_NET, "failed to create SSL context"); + git__free(st); + return -1; + } + + if ((ret = SSLSetIOFuncs(st->ctx, read_cb, write_cb)) != noErr || + (ret = SSLSetConnection(st->ctx, st->io)) != noErr || + (ret = SSLSetSessionOption(st->ctx, kSSLSessionOptionBreakOnServerAuth, true)) != noErr || + (ret = SSLSetProtocolVersionMin(st->ctx, kTLSProtocol1)) != noErr || + (ret = SSLSetProtocolVersionMax(st->ctx, kTLSProtocol12)) != noErr || + (ret = SSLSetPeerDomainName(st->ctx, host, strlen(host))) != noErr) { + CFRelease(st->ctx); + git__free(st); + return stransport_error(ret); + } + + st->parent.version = GIT_STREAM_VERSION; + st->parent.encrypted = 1; + st->parent.proxy_support = git_stream_supports_proxy(st->io); + st->parent.connect = stransport_connect; + st->parent.certificate = stransport_certificate; + st->parent.set_proxy = stransport_set_proxy; + st->parent.read = stransport_read; + st->parent.write = stransport_write; + st->parent.close = stransport_close; + st->parent.free = stransport_free; + + *out = (git_stream *) st; + return 0; +} + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/stransport.h r-cran-git2r-0.22.1/src/libgit2/src/streams/stransport.h --- r-cran-git2r-0.21.0/src/libgit2/src/streams/stransport.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/stransport.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,16 @@ +/* + * 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_streams_stransport_h__ +#define INCLUDE_streams_stransport_h__ + +#include "common.h" + +#include "git2/sys/stream.h" + +extern int git_stransport_stream_new(git_stream **out, const char *host, const char *port); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/tls.c r-cran-git2r-0.22.1/src/libgit2/src/streams/tls.c --- r-cran-git2r-0.21.0/src/libgit2/src/streams/tls.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/tls.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * 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. + */ + +#include "streams/tls.h" + +#include "git2/errors.h" + +#include "streams/openssl.h" +#include "streams/stransport.h" + +static git_stream_cb tls_ctor; + +int git_stream_register_tls(git_stream_cb ctor) +{ + tls_ctor = ctor; + + return 0; +} + +int git_tls_stream_new(git_stream **out, const char *host, const char *port) +{ + + if (tls_ctor) + return tls_ctor(out, host, port); + +#ifdef GIT_SECURE_TRANSPORT + return git_stransport_stream_new(out, host, port); +#elif defined(GIT_OPENSSL) + return git_openssl_stream_new(out, host, port); +#else + GIT_UNUSED(out); + GIT_UNUSED(host); + GIT_UNUSED(port); + + giterr_set(GITERR_SSL, "there is no TLS stream available"); + return -1; +#endif +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/streams/tls.h r-cran-git2r-0.22.1/src/libgit2/src/streams/tls.h --- r-cran-git2r-0.21.0/src/libgit2/src/streams/tls.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/streams/tls.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,23 @@ +/* + * 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_streams_tls_h__ +#define INCLUDE_streams_tls_h__ + +#include "common.h" + +#include "git2/sys/stream.h" + +/** + * Create a TLS stream with the most appropriate backend available for + * the current platform. + * + * This allows us to ask for a SecureTransport or OpenSSL stream + * according to being on general Unix vs OS X. + */ +extern int git_tls_stream_new(git_stream **out, const char *host, const char *port); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/submodule.c r-cran-git2r-0.22.1/src/libgit2/src/submodule.c --- r-cran-git2r-0.21.0/src/libgit2/src/submodule.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/submodule.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "submodule.h" + #include "git2/config.h" #include "git2/sys/config.h" #include "git2/types.h" @@ -17,7 +18,6 @@ #include "config_file.h" #include "config.h" #include "repository.h" -#include "submodule.h" #include "tree.h" #include "iterator.h" #include "path.h" @@ -91,7 +91,7 @@ static int submodule_alloc(git_submodule **out, git_repository *repo, const char *name); static git_config_backend *open_gitmodules(git_repository *repo, int gitmod); -static git_config *gitmodules_snapshot(git_repository *repo); +static int gitmodules_snapshot(git_config **snap, git_repository *repo); static int get_url_base(git_buf *url, git_repository *repo); static int lookup_head_remote_key(git_buf *remote_key, git_repository *repo); static int lookup_default_remote(git_remote **remote, git_repository *repo); @@ -169,13 +169,13 @@ * TODO: for some use-cases, this might need case-folding on a * case-insensitive filesystem */ -static int load_submodule_names(git_strmap *out, git_config *cfg) +static int load_submodule_names(git_strmap *out, git_repository *repo, git_config *cfg) { const char *key = "submodule\\..*\\.path"; git_config_iterator *iter; git_config_entry *entry; git_buf buf = GIT_BUF_INIT; - int rval; + int rval, isvalid; int error = 0; if ((error = git_config_iterator_glob_new(&iter, cfg, key)) < 0) @@ -186,16 +186,36 @@ fdot = strchr(entry->name, '.'); ldot = strrchr(entry->name, '.'); + if (git_strmap_exists(out, entry->value)) { + giterr_set(GITERR_SUBMODULE, + "duplicated submodule path '%s'", entry->value); + error = -1; + goto out; + } + + git_buf_clear(&buf); git_buf_put(&buf, fdot + 1, ldot - fdot - 1); + isvalid = git_submodule_name_is_valid(repo, buf.ptr, 0); + if (isvalid < 0) { + error = isvalid; + goto out; + } + if (!isvalid) + continue; + git_strmap_insert(out, entry->value, git_buf_detach(&buf), &rval); if (rval < 0) { giterr_set(GITERR_NOMEMORY, "error inserting submodule into hash table"); return -1; } } + if (error == GIT_ITEROVER) + error = 0; +out: + git_buf_free(&buf); git_config_iterator_free(iter); - return 0; + return error; } int git_submodule_lookup( @@ -209,6 +229,11 @@ assert(repo && name); + if (repo->is_bare) { + giterr_set(GITERR_SUBMODULE, "cannot get submodules without a working tree"); + return -1; + } + if (repo->submodule_cache != NULL) { khiter_t pos = git_strmap_lookup_index(repo->submodule_cache, name); if (git_strmap_valid_index(repo->submodule_cache, pos)) { @@ -309,6 +334,28 @@ return 0; } +int git_submodule_name_is_valid(git_repository *repo, const char *name, int flags) +{ + git_buf buf = GIT_BUF_INIT; + int error, isvalid; + + if (flags == 0) + flags = GIT_PATH_REJECT_FILESYSTEM_DEFAULTS; + + /* Avoid allocating a new string if we can avoid it */ + if (strchr(name, '\\') != NULL) { + if ((error = git_path_normalize_slashes(&buf, name)) < 0) + return error; + } else { + git_buf_attach_notowned(&buf, name, strlen(name)); + } + + isvalid = git_path_isvalid(repo, buf.ptr, 0, flags); + git_buf_free(&buf); + + return isvalid; +} + static void submodule_free_dup(void *sm) { git_submodule_free(sm); @@ -354,7 +401,7 @@ git_strmap *names = 0; git_strmap_alloc(&names); - if ((error = load_submodule_names(names, cfg))) + if ((error = load_submodule_names(names, git_index_owner(idx), cfg))) goto done; if ((error = git_iterator_for_index(&i, git_index_owner(idx), idx, NULL)) < 0) @@ -406,7 +453,7 @@ const git_index_entry *entry; git_strmap *names = 0; git_strmap_alloc(&names); - if ((error = load_submodule_names(names, cfg))) + if ((error = load_submodule_names(names, git_tree_owner(head), cfg))) goto done; if ((error = git_iterator_for_tree(&i, head, NULL)) < 0) @@ -504,8 +551,11 @@ data.map = map; data.repo = repo; - if ((mods = gitmodules_snapshot(repo)) == NULL) + if ((error = gitmodules_snapshot(&mods, repo)) < 0) { + if (error == GIT_ENOTFOUND) + error = 0; goto cleanup; + } data.mods = mods; if ((error = git_config_foreach( @@ -549,6 +599,11 @@ int error; size_t i; + if (repo->is_bare) { + giterr_set(GITERR_SUBMODULE, "cannot get submodules without a working tree"); + return -1; + } + if ((error = git_strmap_alloc(&submodules)) < 0) return error; @@ -1492,16 +1547,23 @@ int git_submodule_reload(git_submodule *sm, int force) { - int error = 0; + int error = 0, isvalid; git_config *mods; GIT_UNUSED(force); assert(sm); + isvalid = git_submodule_name_is_valid(sm->repo, sm->name, 0); + if (isvalid <= 0) { + /* This should come with a warning, but we've no API for that */ + return isvalid; + } + if (!git_repository_is_bare(sm->repo)) { /* refresh config data */ - mods = gitmodules_snapshot(sm->repo); + if ((error = gitmodules_snapshot(&mods, sm->repo)) < 0 && error != GIT_ENOTFOUND) + return error; if (mods != NULL) { error = submodule_read_config(sm, mods); git_config_free(mods); @@ -1839,7 +1901,7 @@ git_strmap *map = data->map; git_buf name = GIT_BUF_INIT; git_submodule *sm; - int error; + int error, isvalid; if (git__prefixcmp(entry->name, "submodule.") != 0) return 0; @@ -1855,6 +1917,12 @@ if ((error = git_buf_set(&name, namestart, property - namestart -1)) < 0) return error; + isvalid = git_submodule_name_is_valid(data->repo, name.ptr, 0); + if (isvalid <= 0) { + error = isvalid; + goto done; + } + /* * Now that we have the submodule's name, we can use that to * figure out whether it's in the map. If it's not, we create @@ -1905,32 +1973,37 @@ } /** - * Returns a snapshot of $WORK_TREE/.gitmodules. + * Requests a snapshot of $WORK_TREE/.gitmodules. * - * We ignore any errors and just pretend the file isn't there. + * Returns GIT_ENOTFOUND in case no .gitmodules file exist */ -static git_config *gitmodules_snapshot(git_repository *repo) +static int gitmodules_snapshot(git_config **snap, git_repository *repo) { const char *workdir = git_repository_workdir(repo); - git_config *mods = NULL, *snap = NULL; + git_config *mods = NULL; git_buf path = GIT_BUF_INIT; + int error; - if (workdir != NULL) { - if (git_buf_joinpath(&path, workdir, GIT_MODULES_FILE) != 0) - return NULL; + if (!workdir) + return GIT_ENOTFOUND; - if (git_config_open_ondisk(&mods, path.ptr) < 0) - mods = NULL; - } + if ((error = git_buf_joinpath(&path, workdir, GIT_MODULES_FILE)) < 0) + return error; - git_buf_free(&path); + if ((error = git_config_open_ondisk(&mods, path.ptr)) < 0) + goto cleanup; + + if ((error = git_config_snapshot(snap, mods)) < 0) + goto cleanup; + + error = 0; - if (mods) { - git_config_snapshot(&snap, mods); +cleanup: + if (mods) git_config_free(mods); - } + git_buf_free(&path); - return snap; + return error; } static git_config_backend *open_gitmodules( @@ -1950,7 +2023,7 @@ if (git_config_file__ondisk(&mods, path.ptr) < 0) mods = NULL; /* open should only fail here if the file is malformed */ - else if (git_config_file_open(mods, GIT_CONFIG_LEVEL_LOCAL) < 0) { + else if (git_config_file_open(mods, GIT_CONFIG_LEVEL_LOCAL, repo) < 0) { git_config_file_free(mods); mods = NULL; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/submodule.h r-cran-git2r-0.22.1/src/libgit2/src/submodule.h --- r-cran-git2r-0.21.0/src/libgit2/src/submodule.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/submodule.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_submodule_h__ #define INCLUDE_submodule_h__ +#include "common.h" + #include "git2/submodule.h" #include "git2/repository.h" #include "fileops.h" @@ -146,4 +148,17 @@ extern int git_submodule__map( git_repository *repo, git_strmap *map); + +/** + * Check whether a submodule's name is valid. + * + * Check the path against the path validity rules, either the filesystem + * defaults (like checkout does) or whichever you want to compare against. + * + * @param repo the repository which contains the submodule + * @param name the name to check + * @param flags the `GIT_PATH` flags to use for the check (0 to use filesystem defaults) + */ +extern int git_submodule_name_is_valid(git_repository *repo, const char *name, int flags); + #endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/sysdir.c r-cran-git2r-0.22.1/src/libgit2/src/sysdir.c --- r-cran-git2r-0.21.0/src/libgit2/src/sysdir.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/sysdir.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,14 +5,17 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "sysdir.h" + #include "global.h" #include "buffer.h" #include "path.h" #include #if GIT_WIN32 #include "win32/findfile.h" +#else +#include +#include #endif static int git_sysdir_guess_programdata_dirs(git_buf *out) @@ -34,12 +37,63 @@ #endif } +#ifndef GIT_WIN32 +static int get_passwd_home(git_buf *out, uid_t uid) +{ + struct passwd pwd, *pwdptr; + char *buf = NULL; + long buflen; + int error; + + assert(out); + + if ((buflen = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1) + buflen = 1024; + + do { + buf = git__realloc(buf, buflen); + error = getpwuid_r(uid, &pwd, buf, buflen, &pwdptr); + buflen *= 2; + } while (error == ERANGE && buflen <= 8192); + + if (error) { + giterr_set(GITERR_OS, "failed to get passwd entry"); + goto out; + } + + if (!pwdptr) { + giterr_set(GITERR_OS, "no passwd entry found for user"); + goto out; + } + + if ((error = git_buf_puts(out, pwdptr->pw_dir)) < 0) + goto out; + +out: + git__free(buf); + return error; +} +#endif + static int git_sysdir_guess_global_dirs(git_buf *out) { #ifdef GIT_WIN32 return git_win32__find_global_dirs(out); #else - int error = git__getenv(out, "HOME"); + int error; + uid_t uid, euid; + + uid = getuid(); + euid = geteuid(); + + /* + * In case we are running setuid, use the configuration + * of the effective user. + */ + if (uid == euid) + error = git__getenv(out, "HOME"); + else + error = get_passwd_home(out, euid); if (error == GIT_ENOTFOUND) { giterr_clear(); @@ -57,12 +111,25 @@ #else git_buf env = GIT_BUF_INIT; int error; + uid_t uid, euid; - if ((error = git__getenv(&env, "XDG_CONFIG_HOME")) == 0) - error = git_buf_joinpath(out, env.ptr, "git"); + uid = getuid(); + euid = geteuid(); - if (error == GIT_ENOTFOUND && (error = git__getenv(&env, "HOME")) == 0) - error = git_buf_joinpath(out, env.ptr, ".config/git"); + /* + * In case we are running setuid, only look up passwd + * directory of the effective user. + */ + if (uid == euid) { + if ((error = git__getenv(&env, "XDG_CONFIG_HOME")) == 0) + error = git_buf_joinpath(out, env.ptr, "git"); + + if (error == GIT_ENOTFOUND && (error = git__getenv(&env, "HOME")) == 0) + error = git_buf_joinpath(out, env.ptr, ".config/git"); + } else { + if ((error = get_passwd_home(&env, euid)) == 0) + error = git_buf_joinpath(out, env.ptr, ".config/git"); + } if (error == GIT_ENOTFOUND) { giterr_clear(); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/sysdir.h r-cran-git2r-0.22.1/src/libgit2/src/sysdir.h --- r-cran-git2r-0.21.0/src/libgit2/src/sysdir.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/sysdir.h 2018-07-10 13:23:34.000000000 +0000 @@ -8,6 +8,7 @@ #define INCLUDE_sysdir_h__ #include "common.h" + #include "posix.h" #include "buffer.h" @@ -115,4 +116,4 @@ */ extern int git_sysdir_set(git_sysdir_t which, const char *paths); -#endif /* INCLUDE_sysdir_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tag.c r-cran-git2r-0.22.1/src/libgit2/src/tag.c --- r-cran-git2r-0.21.0/src/libgit2/src/tag.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tag.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "commit.h" #include "tag.h" + +#include "commit.h" #include "signature.h" #include "message.h" #include "git2/object.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tag.h r-cran-git2r-0.22.1/src/libgit2/src/tag.h --- r-cran-git2r-0.21.0/src/libgit2/src/tag.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tag.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_tag_h__ #define INCLUDE_tag_h__ +#include "common.h" + #include "git2/tag.h" #include "repository.h" #include "odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/thread-utils.c r-cran-git2r-0.22.1/src/libgit2/src/thread-utils.c --- r-cran-git2r-0.21.0/src/libgit2/src/thread-utils.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/thread-utils.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,6 +4,7 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "common.h" #include "thread-utils.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/thread-utils.h r-cran-git2r-0.22.1/src/libgit2/src/thread-utils.h --- r-cran-git2r-0.21.0/src/libgit2/src/thread-utils.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/thread-utils.h 2018-07-10 13:23:34.000000000 +0000 @@ -243,4 +243,4 @@ # define GIT_MEMORY_BARRIER /* noop */ #endif -#endif /* INCLUDE_thread_utils_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tls_stream.c r-cran-git2r-0.22.1/src/libgit2/src/tls_stream.c --- r-cran-git2r-0.21.0/src/libgit2/src/tls_stream.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tls_stream.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* - * 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. - */ - -#include "git2/errors.h" -#include "common.h" - -#include "openssl_stream.h" -#include "stransport_stream.h" - -static git_stream_cb tls_ctor; - -int git_stream_register_tls(git_stream_cb ctor) -{ - tls_ctor = ctor; - - return 0; -} - -int git_tls_stream_new(git_stream **out, const char *host, const char *port) -{ - - if (tls_ctor) - return tls_ctor(out, host, port); - -#ifdef GIT_SECURE_TRANSPORT - return git_stransport_stream_new(out, host, port); -#elif defined(GIT_OPENSSL) - return git_openssl_stream_new(out, host, port); -#else - GIT_UNUSED(out); - GIT_UNUSED(host); - GIT_UNUSED(port); - - giterr_set(GITERR_SSL, "there is no TLS stream available"); - return -1; -#endif -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tls_stream.h r-cran-git2r-0.22.1/src/libgit2/src/tls_stream.h --- r-cran-git2r-0.21.0/src/libgit2/src/tls_stream.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tls_stream.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* - * 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_tls_stream_h__ -#define INCLUDE_tls_stream_h__ - -#include "git2/sys/stream.h" - -/** - * Create a TLS stream with the most appropriate backend available for - * the current platform. - * - * This allows us to ask for a SecureTransport or OpenSSL stream - * according to being on general Unix vs OS X. - */ -extern int git_tls_stream_new(git_stream **out, const char *host, const char *port); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/trace.c r-cran-git2r-0.22.1/src/libgit2/src/trace.c --- r-cran-git2r-0.21.0/src/libgit2/src/trace.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/trace.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,10 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "trace.h" + #include "buffer.h" -#include "common.h" #include "global.h" -#include "trace.h" #include "git2/trace.h" #ifdef GIT_TRACE diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/trace.h r-cran-git2r-0.22.1/src/libgit2/src/trace.h --- r-cran-git2r-0.21.0/src/libgit2/src/trace.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/trace.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_trace_h__ #define INCLUDE_trace_h__ +#include "common.h" + #include #include "buffer.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/trailer.c r-cran-git2r-0.22.1/src/libgit2/src/trailer.c --- r-cran-git2r-0.21.0/src/libgit2/src/trailer.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/trailer.c 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,416 @@ +/* + * 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. + */ +#include "array.h" +#include "common.h" +#include "git2/message.h" + +#include +#include +#include + +#define COMMENT_LINE_CHAR '#' +#define TRAILER_SEPARATORS ":" + +static const char *const git_generated_prefixes[] = { + "Signed-off-by: ", + "(cherry picked from commit ", + NULL +}; + +static int is_blank_line(const char *str) +{ + const char *s = str; + while (*s && *s != '\n' && isspace(*s)) + s++; + return !*s || *s == '\n'; +} + +static const char *next_line(const char *str) +{ + const char *nl = strchr(str, '\n'); + + if (nl) { + return nl + 1; + } else { + // return pointer to the NUL terminator: + return str + strlen(str); + } +} + +/* + * Return the position of the start of the last line. If len is 0, return -1. + */ +static int last_line(const char *buf, size_t len) +{ + int i; + if (len == 0) + return -1; + if (len == 1) + return 0; + /* + * Skip the last character (in addition to the null terminator), + * because if the last character is a newline, it is considered as part + * of the last line anyway. + */ + i = len - 2; + + for (; i >= 0; i--) { + if (buf[i] == '\n') + return i + 1; + } + return 0; +} + +/* + * If the given line is of the form + * "..." or "...", return the + * location of the separator. Otherwise, return -1. The optional whitespace + * is allowed there primarily to allow things like "Bug #43" where is + * "Bug" and is "#". + * + * The separator-starts-line case (in which this function returns 0) is + * distinguished from the non-well-formed-line case (in which this function + * returns -1) because some callers of this function need such a distinction. + */ +static int find_separator(const char *line, const char *separators) +{ + int whitespace_found = 0; + const char *c; + for (c = line; *c; c++) { + if (strchr(separators, *c)) + return c - line; + if (!whitespace_found && (isalnum(*c) || *c == '-')) + continue; + if (c != line && (*c == ' ' || *c == '\t')) { + whitespace_found = 1; + continue; + } + break; + } + return -1; +} + +/* + * Inspect the given string and determine the true "end" of the log message, in + * order to find where to put a new Signed-off-by: line. Ignored are + * trailing comment lines and blank lines. To support "git commit -s + * --amend" on an existing commit, we also ignore "Conflicts:". To + * support "git commit -v", we truncate at cut lines. + * + * Returns the number of bytes from the tail to ignore, to be fed as + * the second parameter to append_signoff(). + */ +static int ignore_non_trailer(const char *buf, size_t len) +{ + int boc = 0; + size_t bol = 0; + int in_old_conflicts_block = 0; + size_t cutoff = len; + + while (bol < cutoff) { + const char *next_line = memchr(buf + bol, '\n', len - bol); + + if (!next_line) + next_line = buf + len; + else + next_line++; + + if (buf[bol] == COMMENT_LINE_CHAR || buf[bol] == '\n') { + /* is this the first of the run of comments? */ + if (!boc) + boc = bol; + /* otherwise, it is just continuing */ + } else if (git__prefixcmp(buf + bol, "Conflicts:\n") == 0) { + in_old_conflicts_block = 1; + if (!boc) + boc = bol; + } else if (in_old_conflicts_block && buf[bol] == '\t') { + ; /* a pathname in the conflicts block */ + } else if (boc) { + /* the previous was not trailing comment */ + boc = 0; + in_old_conflicts_block = 0; + } + bol = next_line - buf; + } + return boc ? len - boc : len - cutoff; +} + +/* + * Return the position of the start of the patch or the length of str if there + * is no patch in the message. + */ +static int find_patch_start(const char *str) +{ + const char *s; + + for (s = str; *s; s = next_line(s)) { + if (git__prefixcmp(s, "---") == 0) + return s - str; + } + + return s - str; +} + +/* + * Return the position of the first trailer line or len if there are no + * trailers. + */ +static int find_trailer_start(const char *buf, size_t len) +{ + const char *s; + int end_of_title, l, only_spaces = 1; + int recognized_prefix = 0, trailer_lines = 0, non_trailer_lines = 0; + /* + * Number of possible continuation lines encountered. This will be + * reset to 0 if we encounter a trailer (since those lines are to be + * considered continuations of that trailer), and added to + * non_trailer_lines if we encounter a non-trailer (since those lines + * are to be considered non-trailers). + */ + int possible_continuation_lines = 0; + + /* The first paragraph is the title and cannot be trailers */ + for (s = buf; s < buf + len; s = next_line(s)) { + if (s[0] == COMMENT_LINE_CHAR) + continue; + if (is_blank_line(s)) + break; + } + end_of_title = s - buf; + + /* + * Get the start of the trailers by looking starting from the end for a + * blank line before a set of non-blank lines that (i) are all + * trailers, or (ii) contains at least one Git-generated trailer and + * consists of at least 25% trailers. + */ + for (l = last_line(buf, len); + l >= end_of_title; + l = last_line(buf, l)) { + const char *bol = buf + l; + const char *const *p; + int separator_pos; + + if (bol[0] == COMMENT_LINE_CHAR) { + non_trailer_lines += possible_continuation_lines; + possible_continuation_lines = 0; + continue; + } + if (is_blank_line(bol)) { + if (only_spaces) + continue; + non_trailer_lines += possible_continuation_lines; + if (recognized_prefix && + trailer_lines * 3 >= non_trailer_lines) + return next_line(bol) - buf; + else if (trailer_lines && !non_trailer_lines) + return next_line(bol) - buf; + return len; + } + only_spaces = 0; + + for (p = git_generated_prefixes; *p; p++) { + if (git__prefixcmp(bol, *p) == 0) { + trailer_lines++; + possible_continuation_lines = 0; + recognized_prefix = 1; + goto continue_outer_loop; + } + } + + separator_pos = find_separator(bol, TRAILER_SEPARATORS); + if (separator_pos >= 1 && !isspace(bol[0])) { + trailer_lines++; + possible_continuation_lines = 0; + if (recognized_prefix) + continue; + } else if (isspace(bol[0])) + possible_continuation_lines++; + else { + non_trailer_lines++; + non_trailer_lines += possible_continuation_lines; + possible_continuation_lines = 0; + } +continue_outer_loop: + ; + } + + return len; +} + +/* Return the position of the end of the trailers. */ +static int find_trailer_end(const char *buf, size_t len) +{ + return len - ignore_non_trailer(buf, len); +} + +static char *extract_trailer_block(const char *message, size_t* len) +{ + size_t patch_start = find_patch_start(message); + size_t trailer_end = find_trailer_end(message, patch_start); + size_t trailer_start = find_trailer_start(message, trailer_end); + + size_t trailer_len = trailer_end - trailer_start; + + char *buffer = git__malloc(trailer_len + 1); + memcpy(buffer, message + trailer_start, trailer_len); + buffer[trailer_len] = 0; + + *len = trailer_len; + + return buffer; +} + +enum trailer_state { + S_START = 0, + S_KEY = 1, + S_KEY_WS = 2, + S_SEP_WS = 3, + S_VALUE = 4, + S_VALUE_NL = 5, + S_VALUE_END = 6, + S_IGNORE = 7, +}; + +#define NEXT(st) { state = (st); ptr++; continue; } +#define GOTO(st) { state = (st); continue; } + +typedef git_array_t(git_message_trailer) git_array_trailer_t; + +int git_message_trailers(git_message_trailer_array *trailer_arr, const char *message) +{ + enum trailer_state state = S_START; + int rc = 0; + char *ptr; + char *key = NULL; + char *value = NULL; + git_array_trailer_t arr = GIT_ARRAY_INIT; + + size_t trailer_len; + char *trailer = extract_trailer_block(message, &trailer_len); + + for (ptr = trailer;;) { + switch (state) { + case S_START: { + if (*ptr == 0) { + goto ret; + } + + key = ptr; + GOTO(S_KEY); + } + case S_KEY: { + if (*ptr == 0) { + goto ret; + } + + if (isalnum(*ptr) || *ptr == '-') { + // legal key character + NEXT(S_KEY); + } + + if (*ptr == ' ' || *ptr == '\t') { + // optional whitespace before separator + *ptr = 0; + NEXT(S_KEY_WS); + } + + if (strchr(TRAILER_SEPARATORS, *ptr)) { + *ptr = 0; + NEXT(S_SEP_WS); + } + + // illegal character + GOTO(S_IGNORE); + } + case S_KEY_WS: { + if (*ptr == 0) { + goto ret; + } + + if (*ptr == ' ' || *ptr == '\t') { + NEXT(S_KEY_WS); + } + + if (strchr(TRAILER_SEPARATORS, *ptr)) { + NEXT(S_SEP_WS); + } + + // illegal character + GOTO(S_IGNORE); + } + case S_SEP_WS: { + if (*ptr == 0) { + goto ret; + } + + if (*ptr == ' ' || *ptr == '\t') { + NEXT(S_SEP_WS); + } + + value = ptr; + NEXT(S_VALUE); + } + case S_VALUE: { + if (*ptr == 0) { + GOTO(S_VALUE_END); + } + + if (*ptr == '\n') { + NEXT(S_VALUE_NL); + } + + NEXT(S_VALUE); + } + case S_VALUE_NL: { + if (*ptr == ' ') { + // continuation; + NEXT(S_VALUE); + } + + ptr[-1] = 0; + GOTO(S_VALUE_END); + } + case S_VALUE_END: { + git_message_trailer *t = git_array_alloc(arr); + + t->key = key; + t->value = value; + + key = NULL; + value = NULL; + + GOTO(S_START); + } + case S_IGNORE: { + if (*ptr == 0) { + goto ret; + } + + if (*ptr == '\n') { + NEXT(S_START); + } + + NEXT(S_IGNORE); + } + } + } + +ret: + trailer_arr->_trailer_block = trailer; + trailer_arr->trailers = arr.ptr; + trailer_arr->count = arr.size; + + return rc; +} + +void git_message_trailer_array_free(git_message_trailer_array *arr) +{ + git__free(arr->_trailer_block); + git__free(arr->trailers); +} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transaction.c r-cran-git2r-0.22.1/src/libgit2/src/transaction.c --- r-cran-git2r-0.21.0/src/libgit2/src/transaction.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transaction.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "transaction.h" + #include "repository.h" #include "strmap.h" #include "refdb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transport.c r-cran-git2r-0.22.1/src/libgit2/src/transport.c --- r-cran-git2r-0.21.0/src/libgit2/src/transport.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transport.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "common.h" + #include "git2/types.h" #include "git2/remote.h" #include "git2/net.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/auth.c r-cran-git2r-0.22.1/src/libgit2/src/transports/auth.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/auth.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/auth.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "auth.h" + #include "git2.h" #include "buffer.h" -#include "auth.h" static int basic_next_token( git_buf *out, git_http_auth_context *ctx, git_cred *c) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/auth.h r-cran-git2r-0.22.1/src/libgit2/src/transports/auth.h --- r-cran-git2r-0.21.0/src/libgit2/src/transports/auth.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/auth.h 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#ifndef INCLUDE_http_auth_h__ -#define INCLUDE_http_auth_h__ +#ifndef INCLUDE_transports_auth_h__ +#define INCLUDE_transports_auth_h__ + +#include "common.h" #include "git2.h" #include "netops.h" @@ -60,4 +62,3 @@ const gitno_connection_data *connection_data); #endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/auth_negotiate.h r-cran-git2r-0.22.1/src/libgit2/src/transports/auth_negotiate.h --- r-cran-git2r-0.21.0/src/libgit2/src/transports/auth_negotiate.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/auth_negotiate.h 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,10 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#ifndef INCLUDE_auth_negotiate_h__ -#define INCLUDE_auth_negotiate_h__ +#ifndef INCLUDE_transports_auth_negotiate_h__ +#define INCLUDE_transports_auth_negotiate_h__ +#include "common.h" #include "git2.h" #include "auth.h" @@ -24,4 +25,3 @@ #endif /* GIT_GSSAPI */ #endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/cred.c r-cran-git2r-0.22.1/src/libgit2/src/transports/cred.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/cred.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/cred.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "cred.h" + #include "git2.h" #include "smart.h" #include "git2/cred_helpers.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/cred.h r-cran-git2r-0.22.1/src/libgit2/src/transports/cred.h --- r-cran-git2r-0.21.0/src/libgit2/src/transports/cred.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/cred.h 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,10 @@ * 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_cred_h__ -#define INCLUDE_git_cred_h__ +#ifndef INCLUDE_transports_cred_h__ +#define INCLUDE_transports_cred_h__ + +#include "common.h" #include "git2/transport.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/cred_helpers.c r-cran-git2r-0.22.1/src/libgit2/src/transports/cred_helpers.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/cred_helpers.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/cred_helpers.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "common.h" + #include "git2/cred_helpers.h" int git_cred_userpass( diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/git.c r-cran-git2r-0.22.1/src/libgit2/src/transports/git.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/git.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/git.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,12 +5,14 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #include "git2.h" #include "buffer.h" #include "netops.h" #include "git2/sys/transport.h" #include "stream.h" -#include "socket_stream.h" +#include "streams/socket.h" #define OWNING_SUBTRANSPORT(s) ((git_subtransport *)(s)->parent.subtransport) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/http.c r-cran-git2r-0.22.1/src/libgit2/src/transports/http.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/http.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/http.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,6 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "common.h" + #ifndef GIT_WINHTTP #include "git2.h" @@ -14,10 +17,11 @@ #include "remote.h" #include "smart.h" #include "auth.h" +#include "http.h" #include "auth_negotiate.h" -#include "tls_stream.h" -#include "socket_stream.h" -#include "curl_stream.h" +#include "streams/tls.h" +#include "streams/socket.h" +#include "streams/curl.h" git_http_auth_scheme auth_schemes[] = { { GIT_AUTHTYPE_NEGOTIATE, "Negotiate", GIT_CREDTYPE_DEFAULT, git_http_auth_negotiate }, @@ -187,16 +191,6 @@ return context->next_token(buf, context, cred); } -static const char *user_agent(void) -{ - const char *custom = git_libgit2__user_agent(); - - if (custom) - return custom; - - return "libgit2 " LIBGIT2_VERSION; -} - static int gen_request( git_buf *buf, http_stream *s, @@ -208,7 +202,9 @@ git_buf_printf(buf, "%s %s%s HTTP/1.1\r\n", s->verb, path, s->service_url); - git_buf_printf(buf, "User-Agent: git/2.0 (%s)\r\n", user_agent()); + git_buf_puts(buf, "User-Agent: "); + git_http__user_agent(buf); + git_buf_puts(buf, "\r\n"); git_buf_printf(buf, "Host: %s\r\n", t->connection_data.host); if (s->chunked || content_length > 0) { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/http.h r-cran-git2r-0.22.1/src/libgit2/src/transports/http.h --- r-cran-git2r-0.21.0/src/libgit2/src/transports/http.h 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/http.h 2018-07-10 13:23:34.000000000 +0000 @@ -0,0 +1,23 @@ +/* + * 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_transports_http_h__ +#define INCLUDE_transports_http_h__ + +#include "buffer.h" + +GIT_INLINE(int) git_http__user_agent(git_buf *buf) +{ + const char *ua = git_libgit2__user_agent(); + + if (!ua) + ua = "libgit2 " LIBGIT2_VERSION; + + return git_buf_printf(buf, "git/2.0 (%s)", ua); +} + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/local.c r-cran-git2r-0.22.1/src/libgit2/src/transports/local.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/local.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/local.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + #include "common.h" + #include "git2/types.h" #include "git2/net.h" #include "git2/repository.h" @@ -16,6 +18,7 @@ #include "git2/pack.h" #include "git2/commit.h" #include "git2/revparse.h" + #include "pack-objects.h" #include "refs.h" #include "posix.h" @@ -504,6 +507,29 @@ return error; } +static int foreach_reference_cb(git_reference *reference, void *payload) +{ + git_revwalk *walk = (git_revwalk *)payload; + int error; + + if (git_reference_type(reference) != GIT_REF_OID) { + git_reference_free(reference); + return 0; + } + + error = git_revwalk_hide(walk, git_reference_target(reference)); + /* The reference is in the local repository, so the target may not + * exist on the remote. It also may not be a commit. */ + if (error == GIT_ENOTFOUND || error == GITERR_INVALID) { + giterr_clear(); + error = 0; + } + + git_reference_free(reference); + + return error; +} + static int local_download_pack( git_transport *transport, git_repository *repo, @@ -543,11 +569,6 @@ if (git_object_type(obj) == GIT_OBJ_COMMIT) { /* Revwalker includes only wanted commits */ error = git_revwalk_push(walk, &rhead->oid); - if (!error && !git_oid_iszero(&rhead->loid)) { - error = git_revwalk_hide(walk, &rhead->loid); - if (error == GIT_ENOTFOUND) - error = 0; - } } else { /* Tag or some other wanted object. Add it on its own */ error = git_packbuilder_insert_recur(pack, &rhead->oid, rhead->name); @@ -557,6 +578,9 @@ goto cleanup; } + if ((error = git_reference_foreach(repo, foreach_reference_cb, walk))) + goto cleanup; + if ((error = git_packbuilder_insert_walk(pack, walk))) goto cleanup; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/smart.c r-cran-git2r-0.22.1/src/libgit2/src/transports/smart.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/smart.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/smart.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,10 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include "git2.h" + #include "smart.h" + +#include "git2.h" #include "refs.h" #include "refspec.h" #include "proxy.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/smart.h r-cran-git2r-0.22.1/src/libgit2/src/transports/smart.h --- r-cran-git2r-0.21.0/src/libgit2/src/transports/smart.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/smart.h 2018-07-10 13:23:34.000000000 +0000 @@ -4,6 +4,11 @@ * 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_transports_smart_h__ +#define INCLUDE_transports_smart_h__ + +#include "common.h" + #include "git2.h" #include "vector.h" #include "netops.h" @@ -191,3 +196,5 @@ int git_pkt_buffer_wants(const git_remote_head * const *refs, size_t count, transport_smart_caps *caps, git_buf *buf); int git_pkt_buffer_have(git_oid *oid, git_buf *buf); void git_pkt_free(git_pkt *pkt); + +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/smart_protocol.c r-cran-git2r-0.22.1/src/libgit2/src/transports/smart_protocol.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/smart_protocol.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/smart_protocol.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,6 +4,9 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ + +#include "common.h" + #include "git2.h" #include "git2/odb_backend.h" @@ -270,7 +273,7 @@ git_revwalk *walk = NULL; git_strarray refs; unsigned int i; - git_reference *ref; + git_reference *ref = NULL; int error; if ((error = git_reference_list(&refs, repo)) < 0) @@ -282,6 +285,9 @@ git_revwalk_sorting(walk, GIT_SORT_TIME); for (i = 0; i < refs.count; ++i) { + git_reference_free(ref); + ref = NULL; + /* No tags */ if (!git__prefixcmp(refs.strings[i], GIT_REFS_TAGS_DIR)) continue; @@ -294,16 +300,13 @@ if ((error = git_revwalk_push(walk, git_reference_target(ref))) < 0) goto on_error; - - git_reference_free(ref); } - git_strarray_free(&refs); *out = walk; - return 0; on_error: - git_revwalk_free(walk); + if (error) + git_revwalk_free(walk); git_reference_free(ref); git_strarray_free(&refs); return error; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/ssh.c r-cran-git2r-0.22.1/src/libgit2/src/transports/ssh.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/ssh.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/ssh.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "ssh.h" + #ifdef GIT_SSH #include #endif @@ -15,8 +17,7 @@ #include "netops.h" #include "smart.h" #include "cred.h" -#include "socket_stream.h" -#include "ssh.h" +#include "streams/socket.h" #ifdef GIT_SSH @@ -63,7 +64,7 @@ */ static int gen_proto(git_buf *request, const char *cmd, const char *url) { - char *repo; + const char *repo; int len; size_t i; @@ -91,8 +92,10 @@ 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); - git_buf_putc(request, '\0'); + git_buf_puts(request, cmd); + git_buf_puts(request, " '"); + git_buf_decode_percent(request, repo, strlen(repo)); + git_buf_puts(request, "'"); if (git_buf_oom(request)) return -1; @@ -209,6 +212,7 @@ } if (s->session) { + libssh2_session_disconnect(s->session, "closing transport"); libssh2_session_free(s->session); s->session = NULL; } @@ -418,8 +422,10 @@ } } while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); - if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED || rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED) - return GIT_EAUTH; + if (rc == LIBSSH2_ERROR_PASSWORD_EXPIRED || + rc == LIBSSH2_ERROR_AUTHENTICATION_FAILED || + rc == LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) + return GIT_EAUTH; if (rc != LIBSSH2_ERROR_NONE) { if (!giterr_last()) @@ -484,7 +490,7 @@ } do { - rc = libssh2_session_startup(s, socket->s); + rc = libssh2_session_handshake(s, socket->s); } while (LIBSSH2_ERROR_EAGAIN == rc || LIBSSH2_ERROR_TIMEOUT == rc); if (rc != LIBSSH2_ERROR_NONE) { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/ssh.h r-cran-git2r-0.22.1/src/libgit2/src/transports/ssh.h --- r-cran-git2r-0.21.0/src/libgit2/src/transports/ssh.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/ssh.h 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,10 @@ * 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_ssh_h__ -#define INCLUDE_ssh_h__ +#ifndef INCLUDE_transports_ssh_h__ +#define INCLUDE_transports_ssh_h__ + +#include "common.h" int git_transport_ssh_global_init(void); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/transports/winhttp.c r-cran-git2r-0.22.1/src/libgit2/src/transports/winhttp.c --- r-cran-git2r-0.21.0/src/libgit2/src/transports/winhttp.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/transports/winhttp.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,6 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "common.h" + #ifdef GIT_WINHTTP #include "git2.h" @@ -16,6 +18,7 @@ #include "remote.h" #include "repository.h" #include "global.h" +#include "http.h" #include #include @@ -37,6 +40,14 @@ #define WINHTTP_IGNORE_REQUEST_TOTAL_LENGTH 0 #endif +#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS_1_1 +# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200 +#endif + +#ifndef WINHTTP_FLAG_SECURE_PROTOCOL_TLS_1_2 +# define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800 +#endif + static const char *prefix_https = "https://"; static const char *upload_pack_service = "upload-pack"; static const char *upload_pack_ls_service_url = "/info/refs?service=git-upload-pack"; @@ -170,9 +181,15 @@ * is "medium" which applies to the intranet and sounds like it would correspond * to Internet Explorer security zones, but in fact does not. */ DWORD data = WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW; + DWORD native_scheme = 0; - if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) == 0 && - (mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) == 0) { + if ((mechanisms & GIT_WINHTTP_AUTH_NTLM) != 0) + native_scheme |= WINHTTP_AUTH_SCHEME_NTLM; + + if ((mechanisms & GIT_WINHTTP_AUTH_NEGOTIATE) != 0) + native_scheme |= WINHTTP_AUTH_SCHEME_NEGOTIATE; + + if (!native_scheme) { giterr_set(GITERR_NET, "invalid authentication scheme"); return -1; } @@ -180,6 +197,9 @@ if (!WinHttpSetOption(request, WINHTTP_OPTION_AUTOLOGON_POLICY, &data, sizeof(DWORD))) return -1; + if (!WinHttpSetCredentials(request, WINHTTP_AUTH_TARGET_SERVER, native_scheme, NULL, NULL, NULL)) + return -1; + return 0; } @@ -267,7 +287,7 @@ cert.parent.cert_type = GIT_CERT_X509; cert.data = cert_ctx->pbCertEncoded; cert.len = cert_ctx->cbCertEncoded; - error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->cred_acquire_payload); + error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->message_cb_payload); CertFreeCertificateContext(cert_ctx); if (error < 0 && !giterr_last()) @@ -604,12 +624,12 @@ if (WINHTTP_AUTH_SCHEME_NTLM & supported) { *allowed_types |= GIT_CREDTYPE_USERPASS_PLAINTEXT; *allowed_types |= GIT_CREDTYPE_DEFAULT; - *allowed_mechanisms = GIT_WINHTTP_AUTH_NEGOTIATE; + *allowed_mechanisms |= GIT_WINHTTP_AUTH_NTLM; } if (WINHTTP_AUTH_SCHEME_NEGOTIATE & supported) { *allowed_types |= GIT_CREDTYPE_DEFAULT; - *allowed_mechanisms = GIT_WINHTTP_AUTH_NEGOTIATE; + *allowed_mechanisms |= GIT_WINHTTP_AUTH_NEGOTIATE; } if (WINHTTP_AUTH_SCHEME_BASIC & supported) { @@ -690,21 +710,6 @@ return ret; } -static int user_agent(git_buf *ua) -{ - const char *custom = git_libgit2__user_agent(); - - git_buf_clear(ua); - git_buf_PUTS(ua, "git/1.0 ("); - - if (custom) - git_buf_puts(ua, custom); - else - git_buf_PUTS(ua, "libgit2 " LIBGIT2_VERSION); - - return git_buf_putc(ua, ')'); -} - static void CALLBACK winhttp_status( HINTERNET connection, DWORD_PTR ctx, @@ -747,6 +752,10 @@ int error = -1; int default_timeout = TIMEOUT_INFINITE; int default_connect_timeout = DEFAULT_CONNECT_TIMEOUT; + DWORD protocols = + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 | + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 | + WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2; t->session = NULL; t->connection = NULL; @@ -761,7 +770,8 @@ return -1; } - if ((error = user_agent(&ua)) < 0) { + + if ((error = git_http__user_agent(&ua)) < 0) { git__free(wide_host); return error; } @@ -788,6 +798,16 @@ goto on_error; } + /* + * Do a best-effort attempt to enable TLS 1.2 but allow this to + * fail; if TLS 1.2 support is not available for some reason, + * ignore the failure (it will keep the default protocols). + */ + WinHttpSetOption(t->session, + WINHTTP_OPTION_SECURE_PROTOCOLS, + &protocols, + sizeof(protocols)); + if (!WinHttpSetTimeouts(t->session, default_timeout, default_connect_timeout, default_timeout, default_timeout)) { giterr_set(GITERR_OS, "failed to set timeouts for WinHTTP"); goto on_error; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tree.c r-cran-git2r-0.22.1/src/libgit2/src/tree.c --- r-cran-git2r-0.21.0/src/libgit2/src/tree.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tree.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,9 +5,9 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" -#include "commit.h" #include "tree.h" + +#include "commit.h" #include "git2/repository.h" #include "git2/object.h" #include "fileops.h" @@ -54,7 +54,7 @@ static int valid_entry_name(git_repository *repo, const char *filename) { return *filename != '\0' && - git_path_isvalid(repo, filename, + git_path_isvalid(repo, filename, 0, GIT_PATH_REJECT_TRAVERSAL | GIT_PATH_REJECT_DOT_GIT | GIT_PATH_REJECT_SLASH); } @@ -440,16 +440,16 @@ unsigned int attr; if (parse_mode(&attr, buffer, &buffer) < 0 || !buffer) - return tree_error("Failed to parse tree. Can't parse filemode", NULL); + return tree_error("failed to parse tree: can't parse filemode", NULL); if ((nul = memchr(buffer, 0, buffer_end - buffer)) == NULL) - return tree_error("Failed to parse tree. Object is corrupted", NULL); + return tree_error("failed to parse tree: object is corrupted", NULL); if ((filename_len = nul - buffer) == 0) - return tree_error("Failed to parse tree. Can't parse filename", NULL); + return tree_error("failed to parse tree: can't parse filename", NULL); if ((buffer_end - (nul + 1)) < GIT_OID_RAWSZ) - return tree_error("Failed to parse tree. Can't parse OID", NULL); + return tree_error("failed to parse tree: can't parse OID", NULL); /* Allocate the entry */ { @@ -496,7 +496,10 @@ int error = 0; if (!valid_entry_name(bld->repo, filename)) - return tree_error("Failed to insert entry. Invalid name for a tree entry", filename); + return tree_error("failed to insert entry: invalid name for a tree entry", filename); + + if (git_oid_iszero(id)) + return tree_error("failed to insert entry: invalid null OID for a tree entry", filename); entry = alloc_entry(filename, strlen(filename), id); GITERR_CHECK_ALLOC(entry); @@ -735,14 +738,17 @@ assert(bld && id && filename); if (!valid_filemode(filemode)) - return tree_error("Failed to insert entry. Invalid filemode for file", filename); + return tree_error("failed to insert entry: invalid filemode for file", filename); if (!valid_entry_name(bld->repo, filename)) - return tree_error("Failed to insert entry. Invalid name for a tree entry", filename); + return tree_error("failed to insert entry: invalid name for a tree entry", filename); + + if (git_oid_iszero(id)) + return tree_error("failed to insert entry: invalid null OID", filename); if (filemode != GIT_FILEMODE_COMMIT && !git_object__is_valid(bld->repo, id, otype_from_mode(filemode))) - return tree_error("Failed to insert entry; invalid object specified", filename); + return tree_error("failed to insert entry: invalid object specified", filename); pos = git_strmap_lookup_index(bld->map, filename); if (git_strmap_valid_index(bld->map, pos)) { @@ -793,7 +799,7 @@ git_tree_entry *entry = treebuilder_get(bld, filename); if (entry == NULL) - return tree_error("Failed to remove entry. File isn't in the tree", filename); + return tree_error("failed to remove entry: file isn't in the tree", filename); git_strmap_delete(bld->map, filename); git_tree_entry_free(entry); @@ -946,12 +952,12 @@ return GIT_ENOTFOUND; } - /* If there's only a slash left in the path, we + /* If there's only a slash left in the path, we * return the current entry; otherwise, we keep * walking down the path */ if (path[filename_len + 1] != '\0') break; - + /* fall through */ case '\0': /* If there are no more components in the path, return * this entry */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tree-cache.c r-cran-git2r-0.22.1/src/libgit2/src/tree-cache.c --- r-cran-git2r-0.21.0/src/libgit2/src/tree-cache.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tree-cache.c 2018-07-10 13:23:34.000000000 +0000 @@ -6,6 +6,7 @@ */ #include "tree-cache.h" + #include "pool.h" #include "tree.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tree-cache.h r-cran-git2r-0.22.1/src/libgit2/src/tree-cache.h --- r-cran-git2r-0.21.0/src/libgit2/src/tree-cache.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tree-cache.h 2018-07-10 13:23:34.000000000 +0000 @@ -9,6 +9,7 @@ #define INCLUDE_tree_cache_h__ #include "common.h" + #include "pool.h" #include "buffer.h" #include "git2/oid.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tree.h r-cran-git2r-0.22.1/src/libgit2/src/tree.h --- r-cran-git2r-0.21.0/src/libgit2/src/tree.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tree.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_tree_h__ #define INCLUDE_tree_h__ +#include "common.h" + #include "git2/tree.h" #include "repository.h" #include "odb.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/tsort.c r-cran-git2r-0.22.1/src/libgit2/src/tsort.c --- r-cran-git2r-0.21.0/src/libgit2/src/tsort.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/tsort.c 2018-07-10 13:23:34.000000000 +0000 @@ -310,7 +310,6 @@ #define PUSH_NEXT() do {\ len = count_run(dst, curr, size, store);\ run = minrun;\ - if (run < minrun) run = minrun;\ if (run > (ssize_t)size - curr) run = size - curr;\ if (run > len) {\ bisort(&dst[curr], len, run, cmp, payload);\ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/unix/map.c r-cran-git2r-0.22.1/src/libgit2/src/unix/map.c --- r-cran-git2r-0.21.0/src/libgit2/src/unix/map.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/unix/map.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,10 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include + +#include "common.h" + +#include "git2/common.h" #if !defined(GIT_WIN32) && !defined(NO_MMAP) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/unix/posix.h r-cran-git2r-0.22.1/src/libgit2/src/unix/posix.h --- r-cran-git2r-0.21.0/src/libgit2/src/unix/posix.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/unix/posix.h 2018-07-10 13:23:34.000000000 +0000 @@ -4,8 +4,12 @@ * 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_posix__unix_h__ -#define INCLUDE_posix__unix_h__ +#ifndef INCLUDE_unix_posix_h__ +#define INCLUDE_unix_posix_h__ + +#ifndef LIBGIT2_NO_FEATURES_H +# include "git2/sys/features.h" +#endif #include #include @@ -71,7 +75,7 @@ #define p_timeval timeval -#ifdef HAVE_FUTIMENS +#ifdef GIT_USE_FUTIMENS GIT_INLINE(int) p_futimes(int f, const struct p_timeval t[2]) { struct timespec s[2]; @@ -85,7 +89,7 @@ # define p_futimes futimes #endif -#ifdef HAVE_REGCOMP_L +#ifdef GIT_USE_REGCOMP_L #include GIT_INLINE(int) p_regcomp(regex_t *preg, const char *pattern, int cflags) { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/unix/pthread.h r-cran-git2r-0.22.1/src/libgit2/src/unix/pthread.h --- r-cran-git2r-0.21.0/src/libgit2/src/unix/pthread.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/unix/pthread.h 2018-07-10 13:23:34.000000000 +0000 @@ -53,4 +53,4 @@ #define git_rwlock_free(a) pthread_rwlock_destroy(a) #define GIT_RWLOCK_STATIC_INIT PTHREAD_RWLOCK_INITIALIZER -#endif /* INCLUDE_unix_pthread_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/unix/realpath.c r-cran-git2r-0.22.1/src/libgit2/src/unix/realpath.c --- r-cran-git2r-0.21.0/src/libgit2/src/unix/realpath.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/unix/realpath.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,7 +4,10 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include + +#include "common.h" + +#include "git2/common.h" #ifndef GIT_WIN32 diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/util.c r-cran-git2r-0.22.1/src/libgit2/src/util.c --- r-cran-git2r-0.21.0/src/libgit2/src/util.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/util.c 2018-07-10 13:23:34.000000000 +0000 @@ -4,14 +4,18 @@ * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. */ -#include + +#include "util.h" + #include "common.h" -#include -#include -#include "posix.h" #ifdef GIT_WIN32 +# include "win32/utf-conv.h" # include "win32/w32_buffer.h" + +# ifdef HAVE_QSORT_S +# include +# endif #endif #ifdef _MSC_VER @@ -250,35 +254,47 @@ git__strntolower(str, strlen(str)); } -int git__prefixcmp(const char *str, const char *prefix) +GIT_INLINE(int) prefixcmp(const char *str, size_t str_n, const char *prefix, bool icase) { - for (;;) { - unsigned char p = *(prefix++), s; + int s, p; + + while (str_n--) { + s = (unsigned char)*str++; + p = (unsigned char)*prefix++; + + if (icase) { + s = git__tolower(s); + p = git__tolower(p); + } + if (!p) return 0; - if ((s = *(str++)) != p) + + if (s != p) return s - p; } + + return (0 - *prefix); } -int git__prefixcmp_icase(const char *str, const char *prefix) +int git__prefixcmp(const char *str, const char *prefix) { - return strncasecmp(str, prefix, strlen(prefix)); + return prefixcmp(str, SIZE_MAX, prefix, false); } -int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix) +int git__prefixncmp(const char *str, size_t str_n, const char *prefix) { - int s, p; - - while(str_n--) { - s = (unsigned char)git__tolower(*str++); - p = (unsigned char)git__tolower(*prefix++); + return prefixcmp(str, str_n, prefix, false); +} - if (s != p) - return s - p; - } +int git__prefixcmp_icase(const char *str, const char *prefix) +{ + return prefixcmp(str, SIZE_MAX, prefix, true); +} - return (0 - *prefix); +int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix) +{ + return prefixcmp(str, str_n, prefix, true); } int git__suffixcmp(const char *str, const char *suffix) @@ -464,9 +480,11 @@ switch(len & 3) { case 3: k1 ^= tail[2] << 16; + /* fall through */ case 2: k1 ^= tail[1] << 8; + /* fall through */ case 1: k1 ^= tail[0]; - MURMUR_BLOCK(); + MURMUR_BLOCK(); } h1 ^= len; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/util.h r-cran-git2r-0.22.1/src/libgit2/src/util.h --- r-cran-git2r-0.21.0/src/libgit2/src/util.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/util.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,42 +7,18 @@ #ifndef INCLUDE_util_h__ #define INCLUDE_util_h__ -#include "git2/buffer.h" -#include "buffer.h" +#include "common.h" -#if defined(GIT_MSVC_CRTDBG) -/* Enable MSVC CRTDBG memory leak reporting. - * - * We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC - * documentation because all allocs/frees in libgit2 already go through - * the "git__" routines defined in this file. Simply using the normal - * reporting mechanism causes all leaks to be attributed to a routine - * here in util.h (ie, the actual call to calloc()) rather than the - * caller of git__calloc(). - * - * Therefore, we declare a set of "git__crtdbg__" routines to replace - * the corresponding "git__" routines and re-define the "git__" symbols - * as macros. This allows us to get and report the file:line info of - * the real caller. - * - * We DO NOT replace the "git__free" routine because it needs to remain - * a function pointer because it is used as a function argument when - * setting up various structure "destructors". - * - * We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes - * "free" to be remapped to "_free_dbg" and this causes problems for - * structures which define a field named "free". - * - * Finally, CRTDBG must be explicitly enabled and configured at program - * startup. See tests/main.c for an example. - */ -#include -#include -#include "win32/w32_crtdbg_stacktrace.h" +#ifndef GIT_WIN32 +# include #endif +#include "git2/buffer.h" + +#include "buffer.h" #include "common.h" #include "strnlen.h" +#include "thread-utils.h" #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) #define bitsizeof(x) (CHAR_BIT * sizeof(x)) @@ -67,79 +43,33 @@ #if defined(GIT_MSVC_CRTDBG) -GIT_INLINE(void *) git__crtdbg__malloc(size_t len, const char *file, int line) -{ - void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); - if (!ptr) giterr_set_oom(); - return ptr; -} - -GIT_INLINE(void *) git__crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line) -{ - void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); - if (!ptr) giterr_set_oom(); - return ptr; -} - -GIT_INLINE(char *) git__crtdbg__strdup(const char *str, const char *file, int line) -{ - char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); - if (!ptr) giterr_set_oom(); - return ptr; -} - -GIT_INLINE(char *) git__crtdbg__strndup(const char *str, size_t n, const char *file, int line) -{ - size_t length = 0, alloclength; - char *ptr; - - length = p_strnlen(str, n); - - if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) || - !(ptr = git__crtdbg__malloc(alloclength, file, line))) - return NULL; - - if (length) - memcpy(ptr, str, length); - - ptr[length] = '\0'; - - return ptr; -} - -GIT_INLINE(char *) git__crtdbg__substrdup(const char *start, size_t n, const char *file, int line) -{ - char *ptr; - size_t alloclen; - - if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) || - !(ptr = git__crtdbg__malloc(alloclen, file, line))) - return NULL; - - memcpy(ptr, start, n); - ptr[n] = '\0'; - return ptr; -} - -GIT_INLINE(void *) git__crtdbg__realloc(void *ptr, size_t size, const char *file, int line) -{ - void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); - if (!new_ptr) giterr_set_oom(); - return new_ptr; -} - -GIT_INLINE(void *) git__crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line) -{ - size_t newsize; - - return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ? - NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line); -} +/* Enable MSVC CRTDBG memory leak reporting. + * + * We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC + * documentation because all allocs/frees in libgit2 already go through + * the "git__" routines defined in this file. Simply using the normal + * reporting mechanism causes all leaks to be attributed to a routine + * here in util.h (ie, the actual call to calloc()) rather than the + * caller of git__calloc(). + * + * Therefore, we declare a set of "git__crtdbg__" routines to replace + * the corresponding "git__" routines and re-define the "git__" symbols + * as macros. This allows us to get and report the file:line info of + * the real caller. + * + * We DO NOT replace the "git__free" routine because it needs to remain + * a function pointer because it is used as a function argument when + * setting up various structure "destructors". + * + * We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes + * "free" to be remapped to "_free_dbg" and this causes problems for + * structures which define a field named "free". + * + * Finally, CRTDBG must be explicitly enabled and configured at program + * startup. See tests/main.c for an example. + */ -GIT_INLINE(void *) git__crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line) -{ - return git__crtdbg__reallocarray(NULL, nelem, elsize, file, line); -} +#include "win32/w32_crtdbg_stacktrace.h" #define git__malloc(len) git__crtdbg__malloc(len, __FILE__, __LINE__) #define git__calloc(nelem, elsize) git__crtdbg__calloc(nelem, elsize, __FILE__, __LINE__) @@ -254,6 +184,7 @@ extern int git__prefixcmp(const char *str, const char *prefix); extern int git__prefixcmp_icase(const char *str, const char *prefix); +extern int git__prefixncmp(const char *str, size_t str_n, const char *prefix); extern int git__prefixncmp_icase(const char *str, size_t str_n, const char *prefix); extern int git__suffixcmp(const char *str, const char *suffix); @@ -363,8 +294,6 @@ extern int git__strcasesort_cmp(const char *a, const char *b); -#include "thread-utils.h" - typedef struct { git_atomic refcount; void *owner; @@ -373,22 +302,22 @@ typedef void (*git_refcount_freeptr)(void *r); #define GIT_REFCOUNT_INC(r) { \ - git_atomic_inc(&((git_refcount *)(r))->refcount); \ + git_atomic_inc(&(r)->rc.refcount); \ } #define GIT_REFCOUNT_DEC(_r, do_free) { \ - git_refcount *r = (git_refcount *)(_r); \ + git_refcount *r = &(_r)->rc; \ int val = git_atomic_dec(&r->refcount); \ if (val <= 0 && r->owner == NULL) { do_free(_r); } \ } #define GIT_REFCOUNT_OWN(r, o) { \ - ((git_refcount *)(r))->owner = o; \ + (r)->rc.owner = o; \ } -#define GIT_REFCOUNT_OWNER(r) (((git_refcount *)(r))->owner) +#define GIT_REFCOUNT_OWNER(r) ((r)->rc.owner) -#define GIT_REFCOUNT_VAL(r) git_atomic_get(&((git_refcount *)(r))->refcount) +#define GIT_REFCOUNT_VAL(r) git_atomic_get((r)->rc.refcount) static signed char from_hex[] = { @@ -614,4 +543,4 @@ extern int git__getenv(git_buf *out, const char *name); -#endif /* INCLUDE_util_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/varint.c r-cran-git2r-0.22.1/src/libgit2/src/varint.c --- r-cran-git2r-0.21.0/src/libgit2/src/varint.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/varint.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,7 +5,6 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "varint.h" uintmax_t git_decode_varint(const unsigned char *bufp, size_t *varint_len) diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/varint.h r-cran-git2r-0.22.1/src/libgit2/src/varint.h --- r-cran-git2r-0.21.0/src/libgit2/src/varint.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/varint.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_varint_h__ #define INCLUDE_varint_h__ +#include "common.h" + #include extern int git_encode_varint(unsigned char *, size_t, uintmax_t); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/vector.c r-cran-git2r-0.22.1/src/libgit2/src/vector.c --- r-cran-git2r-0.21.0/src/libgit2/src/vector.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/vector.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,8 +5,8 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" #include "vector.h" + #include "integer.h" /* In elements, not bytes */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/dir.c r-cran-git2r-0.22.1/src/libgit2/src/win32/dir.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/dir.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/dir.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -/* - * 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. - */ -#define GIT__WIN32_NO_WRAP_DIR -#include "posix.h" - -git__DIR *git__opendir(const char *dir) -{ - git_win32_path filter_w; - git__DIR *new = NULL; - size_t dirlen, alloclen; - - if (!dir || !git_win32__findfirstfile_filter(filter_w, dir)) - return NULL; - - dirlen = strlen(dir); - - if (GIT_ADD_SIZET_OVERFLOW(&alloclen, sizeof(*new), dirlen) || - GIT_ADD_SIZET_OVERFLOW(&alloclen, alloclen, 1) || - !(new = git__calloc(1, alloclen))) - return NULL; - - memcpy(new->dir, dir, dirlen); - - new->h = FindFirstFileW(filter_w, &new->f); - - if (new->h == INVALID_HANDLE_VALUE) { - giterr_set(GITERR_OS, "could not open directory '%s'", dir); - git__free(new); - return NULL; - } - - new->first = 1; - return new; -} - -int git__readdir_ext( - git__DIR *d, - struct git__dirent *entry, - struct git__dirent **result, - int *is_dir) -{ - if (!d || !entry || !result || d->h == INVALID_HANDLE_VALUE) - return -1; - - *result = NULL; - - if (d->first) - d->first = 0; - else if (!FindNextFileW(d->h, &d->f)) { - if (GetLastError() == ERROR_NO_MORE_FILES) - return 0; - giterr_set(GITERR_OS, "could not read from directory '%s'", d->dir); - return -1; - } - - /* Convert the path to UTF-8 */ - if (git_win32_path_to_utf8(entry->d_name, d->f.cFileName) < 0) - return -1; - - entry->d_ino = 0; - - *result = entry; - - if (is_dir != NULL) - *is_dir = ((d->f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); - - return 0; -} - -struct git__dirent *git__readdir(git__DIR *d) -{ - struct git__dirent *result; - if (git__readdir_ext(d, &d->entry, &result, NULL) < 0) - return NULL; - return result; -} - -void git__rewinddir(git__DIR *d) -{ - git_win32_path filter_w; - - if (!d) - return; - - if (d->h != INVALID_HANDLE_VALUE) { - FindClose(d->h); - d->h = INVALID_HANDLE_VALUE; - d->first = 0; - } - - if (!git_win32__findfirstfile_filter(filter_w, d->dir)) - return; - - d->h = FindFirstFileW(filter_w, &d->f); - - if (d->h == INVALID_HANDLE_VALUE) - giterr_set(GITERR_OS, "could not open directory '%s'", d->dir); - else - d->first = 1; -} - -int git__closedir(git__DIR *d) -{ - if (!d) - return 0; - - if (d->h != INVALID_HANDLE_VALUE) { - FindClose(d->h); - d->h = INVALID_HANDLE_VALUE; - } - - git__free(d); - return 0; -} - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/dir.h r-cran-git2r-0.22.1/src/libgit2/src/win32/dir.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/dir.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/dir.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * 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_dir_h__ -#define INCLUDE_dir_h__ - -#include "common.h" -#include "w32_util.h" - -struct git__dirent { - int d_ino; - git_win32_utf8_path d_name; -}; - -typedef struct { - HANDLE h; - WIN32_FIND_DATAW f; - struct git__dirent entry; - int first; - char dir[GIT_FLEX_ARRAY]; -} git__DIR; - -extern git__DIR *git__opendir(const char *); -extern struct git__dirent *git__readdir(git__DIR *); -extern int git__readdir_ext( - git__DIR *, struct git__dirent *, struct git__dirent **, int *); -extern void git__rewinddir(git__DIR *); -extern int git__closedir(git__DIR *); - -# ifndef GIT__WIN32_NO_WRAP_DIR -# define dirent git__dirent -# define DIR git__DIR -# define opendir git__opendir -# define readdir git__readdir -# define readdir_r(d,e,r) git__readdir_ext((d),(e),(r),NULL) -# define rewinddir git__rewinddir -# define closedir git__closedir -# endif - -#endif /* INCLUDE_dir_h__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/error.c r-cran-git2r-0.22.1/src/libgit2/src/win32/error.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/error.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/error.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "error.h" -#include "utf-conv.h" - -#ifdef GIT_WINHTTP -# include -#endif - -char *git_win32_get_error_message(DWORD error_code) -{ - LPWSTR lpMsgBuf = NULL; - HMODULE hModule = NULL; - char *utf8_msg = NULL; - DWORD dwFlags = - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS; - - if (!error_code) - return NULL; - -#ifdef GIT_WINHTTP - /* Errors raised by WinHTTP are not in the system resource table */ - if (error_code >= WINHTTP_ERROR_BASE && - error_code <= WINHTTP_ERROR_LAST) - hModule = GetModuleHandleW(L"winhttp"); -#endif - - GIT_UNUSED(hModule); - - if (hModule) - dwFlags |= FORMAT_MESSAGE_FROM_HMODULE; - else - dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM; - - if (FormatMessageW(dwFlags, hModule, error_code, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPWSTR)&lpMsgBuf, 0, NULL)) { - /* Convert the message to UTF-8. If this fails, we will - * return NULL, which is a condition expected by the caller */ - if (git__utf16_to_8_alloc(&utf8_msg, lpMsgBuf) < 0) - utf8_msg = NULL; - - LocalFree(lpMsgBuf); - } - - return utf8_msg; -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/error.h r-cran-git2r-0.22.1/src/libgit2/src/win32/error.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/error.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/error.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* - * 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_win32_error_h__ -#define INCLUDE_git_win32_error_h__ - -extern char *git_win32_get_error_message(DWORD error_code); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/findfile.c r-cran-git2r-0.22.1/src/libgit2/src/win32/findfile.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/findfile.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/findfile.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -/* - * 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. - */ - -#include "path_w32.h" -#include "utf-conv.h" -#include "path.h" -#include "findfile.h" - -#define REG_MSYSGIT_INSTALL_LOCAL L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" - -#ifndef _WIN64 -#define REG_MSYSGIT_INSTALL REG_MSYSGIT_INSTALL_LOCAL -#else -#define REG_MSYSGIT_INSTALL L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Git_is1" -#endif - -typedef struct { - git_win32_path path; - DWORD len; -} _findfile_path; - -static int git_win32__expand_path(_findfile_path *dest, const wchar_t *src) -{ - dest->len = ExpandEnvironmentStringsW(src, dest->path, ARRAY_SIZE(dest->path)); - - if (!dest->len || dest->len > ARRAY_SIZE(dest->path)) - return -1; - - return 0; -} - -static int win32_path_to_8(git_buf *dest, const wchar_t *src) -{ - git_win32_utf8_path utf8_path; - - if (git_win32_path_to_utf8(utf8_path, src) < 0) { - giterr_set(GITERR_OS, "unable to convert path to UTF-8"); - return -1; - } - - /* Convert backslashes to forward slashes */ - git_path_mkposix(utf8_path); - - return git_buf_sets(dest, utf8_path); -} - -static wchar_t* win32_walkpath(wchar_t *path, wchar_t *buf, size_t buflen) -{ - wchar_t term, *base = path; - - assert(path && buf && buflen); - - term = (*path == L'"') ? *path++ : L';'; - - for (buflen--; *path && *path != term && buflen; buflen--) - *buf++ = *path++; - - *buf = L'\0'; /* reserved a byte via initial subtract */ - - while (*path == term || *path == L';') - path++; - - return (path != base) ? path : NULL; -} - -static int win32_find_git_in_path(git_buf *buf, const wchar_t *gitexe, const wchar_t *subdir) -{ - wchar_t *env = _wgetenv(L"PATH"), lastch; - _findfile_path root; - size_t gitexe_len = wcslen(gitexe); - - if (!env) - return -1; - - while ((env = win32_walkpath(env, root.path, MAX_PATH-1)) && *root.path) { - root.len = (DWORD)wcslen(root.path); - lastch = root.path[root.len - 1]; - - /* ensure trailing slash (MAX_PATH-1 to walkpath guarantees space) */ - if (lastch != L'/' && lastch != L'\\') { - root.path[root.len++] = L'\\'; - root.path[root.len] = L'\0'; - } - - if (root.len + gitexe_len >= MAX_PATH) - continue; - wcscpy(&root.path[root.len], gitexe); - - if (_waccess(root.path, F_OK) == 0 && root.len > 5) { - /* replace "bin\\" or "cmd\\" with subdir */ - wcscpy(&root.path[root.len - 4], subdir); - - win32_path_to_8(buf, root.path); - return 0; - } - } - - return GIT_ENOTFOUND; -} - -static int win32_find_git_in_registry( - git_buf *buf, const HKEY hive, const wchar_t *key, const wchar_t *subdir) -{ - HKEY hKey; - int error = GIT_ENOTFOUND; - - assert(buf); - - if (!RegOpenKeyExW(hive, key, 0, KEY_READ, &hKey)) { - DWORD dwType, cbData; - git_win32_path path; - - /* Ensure that the buffer is big enough to have the suffix attached - * after we receive the result. */ - cbData = (DWORD)(sizeof(path) - wcslen(subdir) * sizeof(wchar_t)); - - /* InstallLocation points to the root of the git directory */ - if (!RegQueryValueExW(hKey, L"InstallLocation", NULL, &dwType, (LPBYTE)path, &cbData) && - dwType == REG_SZ) { - - /* Append the suffix */ - wcscat(path, subdir); - - /* Convert to UTF-8, with forward slashes, and output the path - * to the provided buffer */ - if (!win32_path_to_8(buf, path)) - error = 0; - } - - RegCloseKey(hKey); - } - - return error; -} - -static int win32_find_existing_dirs( - git_buf *out, const wchar_t *tmpl[]) -{ - _findfile_path path16; - git_buf buf = GIT_BUF_INIT; - - git_buf_clear(out); - - for (; *tmpl != NULL; tmpl++) { - if (!git_win32__expand_path(&path16, *tmpl) && - path16.path[0] != L'%' && - !_waccess(path16.path, F_OK)) - { - win32_path_to_8(&buf, path16.path); - - if (buf.size) - git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); - } - } - - git_buf_free(&buf); - - return (git_buf_oom(out) ? -1 : 0); -} - -int git_win32__find_system_dirs(git_buf *out, const wchar_t *subdir) -{ - git_buf buf = GIT_BUF_INIT; - - /* directories where git.exe & git.cmd are found */ - if (!win32_find_git_in_path(&buf, L"git.exe", subdir) && buf.size) - git_buf_set(out, buf.ptr, buf.size); - else - git_buf_clear(out); - - if (!win32_find_git_in_path(&buf, L"git.cmd", subdir) && buf.size) - git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); - - /* directories where git is installed according to registry */ - if (!win32_find_git_in_registry( - &buf, HKEY_CURRENT_USER, REG_MSYSGIT_INSTALL_LOCAL, subdir) && buf.size) - git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); - - if (!win32_find_git_in_registry( - &buf, HKEY_LOCAL_MACHINE, REG_MSYSGIT_INSTALL, subdir) && buf.size) - git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr); - - git_buf_free(&buf); - - return (git_buf_oom(out) ? -1 : 0); -} - -int git_win32__find_global_dirs(git_buf *out) -{ - static const wchar_t *global_tmpls[4] = { - L"%HOME%\\", - L"%HOMEDRIVE%%HOMEPATH%\\", - L"%USERPROFILE%\\", - NULL, - }; - - return win32_find_existing_dirs(out, global_tmpls); -} - -int git_win32__find_xdg_dirs(git_buf *out) -{ - static const wchar_t *global_tmpls[7] = { - L"%XDG_CONFIG_HOME%\\git", - L"%APPDATA%\\git", - L"%LOCALAPPDATA%\\git", - L"%HOME%\\.config\\git", - L"%HOMEDRIVE%%HOMEPATH%\\.config\\git", - L"%USERPROFILE%\\.config\\git", - NULL, - }; - - return win32_find_existing_dirs(out, global_tmpls); -} - -int git_win32__find_programdata_dirs(git_buf *out) -{ - static const wchar_t *programdata_tmpls[2] = { - L"%PROGRAMDATA%\\Git", - NULL, - }; - - return win32_find_existing_dirs(out, programdata_tmpls); -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/findfile.h r-cran-git2r-0.22.1/src/libgit2/src/win32/findfile.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/findfile.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/findfile.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -/* - * 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_findfile_h__ -#define INCLUDE_git_findfile_h__ - -extern int git_win32__find_system_dirs(git_buf *out, const wchar_t *subpath); -extern int git_win32__find_global_dirs(git_buf *out); -extern int git_win32__find_xdg_dirs(git_buf *out); -extern int git_win32__find_programdata_dirs(git_buf *out); - -#endif - diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/git2.rc r-cran-git2r-0.22.1/src/libgit2/src/win32/git2.rc --- r-cran-git2r-0.21.0/src/libgit2/src/win32/git2.rc 2018-01-02 10:53:08.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/git2.rc 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -#include -#include "../../include/git2/version.h" - -#ifndef LIBGIT2_FILENAME -# define LIBGIT2_FILENAME "git2" -#endif - -#ifndef LIBGIT2_COMMENTS -# define LIBGIT2_COMMENTS "For more information visit http://libgit2.github.com/" -#endif - -VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH - PRODUCTVERSION LIBGIT2_VER_MAJOR,LIBGIT2_VER_MINOR,LIBGIT2_VER_REVISION,LIBGIT2_VER_PATCH - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0 -#endif - FILEOS VOS_NT_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - BEGIN - VALUE "FileDescription", "libgit2 - the Git linkable library\0" - VALUE "FileVersion", LIBGIT2_VERSION "\0" - VALUE "InternalName", LIBGIT2_FILENAME ".dll\0" - VALUE "LegalCopyright", "Copyright (C) the libgit2 contributors. All rights reserved.\0" - VALUE "OriginalFilename", LIBGIT2_FILENAME ".dll\0" - VALUE "ProductName", "libgit2\0" - VALUE "ProductVersion", LIBGIT2_VERSION "\0" - VALUE "Comments", LIBGIT2_COMMENTS "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/map.c r-cran-git2r-0.22.1/src/libgit2/src/win32/map.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/map.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/map.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ -/* - * 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. - */ - -#include "map.h" -#include - -#ifndef NO_MMAP - -static DWORD get_page_size(void) -{ - static DWORD page_size; - SYSTEM_INFO sys; - - if (!page_size) { - GetSystemInfo(&sys); - page_size = sys.dwPageSize; - } - - return page_size; -} - -static DWORD get_allocation_granularity(void) -{ - static DWORD granularity; - SYSTEM_INFO sys; - - if (!granularity) { - GetSystemInfo(&sys); - granularity = sys.dwAllocationGranularity; - } - - return granularity; -} - -int git__page_size(size_t *page_size) -{ - *page_size = get_page_size(); - return 0; -} - -int git__mmap_alignment(size_t *page_size) -{ - *page_size = get_allocation_granularity(); - return 0; -} - -int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset) -{ - HANDLE fh = (HANDLE)_get_osfhandle(fd); - DWORD alignment = get_allocation_granularity(); - DWORD fmap_prot = 0; - DWORD view_prot = 0; - DWORD off_low = 0; - DWORD off_hi = 0; - git_off_t page_start; - git_off_t page_offset; - - GIT_MMAP_VALIDATE(out, len, prot, flags); - - out->data = NULL; - out->len = 0; - out->fmh = NULL; - - if (fh == INVALID_HANDLE_VALUE) { - errno = EBADF; - giterr_set(GITERR_OS, "failed to mmap. Invalid handle value"); - return -1; - } - - if (prot & GIT_PROT_WRITE) - fmap_prot |= PAGE_READWRITE; - else if (prot & GIT_PROT_READ) - fmap_prot |= PAGE_READONLY; - - if (prot & GIT_PROT_WRITE) - view_prot |= FILE_MAP_WRITE; - if (prot & GIT_PROT_READ) - view_prot |= FILE_MAP_READ; - - page_start = (offset / alignment) * alignment; - page_offset = offset - page_start; - - if (page_offset != 0) { /* offset must be multiple of the allocation granularity */ - errno = EINVAL; - giterr_set(GITERR_OS, "failed to mmap. Offset must be multiple of allocation granularity"); - return -1; - } - - out->fmh = CreateFileMapping(fh, NULL, fmap_prot, 0, 0, NULL); - if (!out->fmh || out->fmh == INVALID_HANDLE_VALUE) { - giterr_set(GITERR_OS, "failed to mmap. Invalid handle value"); - out->fmh = NULL; - return -1; - } - - assert(sizeof(git_off_t) == 8); - - off_low = (DWORD)(page_start); - off_hi = (DWORD)(page_start >> 32); - out->data = MapViewOfFile(out->fmh, view_prot, off_hi, off_low, len); - if (!out->data) { - giterr_set(GITERR_OS, "failed to mmap. No data written"); - CloseHandle(out->fmh); - out->fmh = NULL; - return -1; - } - out->len = len; - - return 0; -} - -int p_munmap(git_map *map) -{ - int error = 0; - - assert(map != NULL); - - if (map->data) { - if (!UnmapViewOfFile(map->data)) { - giterr_set(GITERR_OS, "failed to munmap. Could not unmap view of file"); - error = -1; - } - map->data = NULL; - } - - if (map->fmh) { - if (!CloseHandle(map->fmh)) { - giterr_set(GITERR_OS, "failed to munmap. Could not close handle"); - error = -1; - } - map->fmh = NULL; - } - - return error; -} - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/mingw-compat.h r-cran-git2r-0.22.1/src/libgit2/src/win32/mingw-compat.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/mingw-compat.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/mingw-compat.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* - * 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_mingw_compat__ -#define INCLUDE_mingw_compat__ - -#if defined(__MINGW32__) - -#undef stat - -#if _WIN32_WINNT < 0x0600 && !defined(__MINGW64_VERSION_MAJOR) -#undef MemoryBarrier -void __mingworg_MemoryBarrier(void); -#define MemoryBarrier __mingworg_MemoryBarrier -#define VOLUME_NAME_DOS 0x0 -#endif - -#endif - -#endif /* INCLUDE_mingw_compat__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/msvc-compat.h r-cran-git2r-0.22.1/src/libgit2/src/win32/msvc-compat.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/msvc-compat.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/msvc-compat.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* - * 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_msvc_compat__ -#define INCLUDE_msvc_compat__ - -#if defined(_MSC_VER) - -typedef unsigned short mode_t; -typedef SSIZE_T ssize_t; - -#define strcasecmp(s1, s2) _stricmp(s1, s2) -#define strncasecmp(s1, s2, c) _strnicmp(s1, s2, c) - -#endif - -#define GIT_STDLIB_CALL __cdecl - -#endif /* INCLUDE_msvc_compat__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/path_w32.c r-cran-git2r-0.22.1/src/libgit2/src/win32/path_w32.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/path_w32.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/path_w32.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,387 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "path.h" -#include "path_w32.h" -#include "utf-conv.h" -#include "posix.h" -#include "reparse.h" -#include "dir.h" - -#define PATH__NT_NAMESPACE L"\\\\?\\" -#define PATH__NT_NAMESPACE_LEN 4 - -#define PATH__ABSOLUTE_LEN 3 - -#define path__is_dirsep(p) ((p) == '/' || (p) == '\\') - -#define path__is_absolute(p) \ - (git__isalpha((p)[0]) && (p)[1] == ':' && ((p)[2] == '\\' || (p)[2] == '/')) - -#define path__is_nt_namespace(p) \ - (((p)[0] == '\\' && (p)[1] == '\\' && (p)[2] == '?' && (p)[3] == '\\') || \ - ((p)[0] == '/' && (p)[1] == '/' && (p)[2] == '?' && (p)[3] == '/')) - -#define path__is_unc(p) \ - (((p)[0] == '\\' && (p)[1] == '\\') || ((p)[0] == '/' && (p)[1] == '/')) - -GIT_INLINE(int) path__cwd(wchar_t *path, int size) -{ - int len; - - if ((len = GetCurrentDirectoryW(size, path)) == 0) { - errno = GetLastError() == ERROR_ACCESS_DENIED ? EACCES : ENOENT; - return -1; - } else if (len > size) { - errno = ENAMETOOLONG; - return -1; - } - - /* The Win32 APIs may return "\\?\" once you've used it first. - * But it may not. What a gloriously predictible API! - */ - if (wcsncmp(path, PATH__NT_NAMESPACE, PATH__NT_NAMESPACE_LEN)) - return len; - - len -= PATH__NT_NAMESPACE_LEN; - - memmove(path, path + PATH__NT_NAMESPACE_LEN, sizeof(wchar_t) * len); - return len; -} - -static wchar_t *path__skip_server(wchar_t *path) -{ - wchar_t *c; - - for (c = path; *c; c++) { - if (path__is_dirsep(*c)) - return c + 1; - } - - return c; -} - -static wchar_t *path__skip_prefix(wchar_t *path) -{ - if (path__is_nt_namespace(path)) { - path += PATH__NT_NAMESPACE_LEN; - - if (wcsncmp(path, L"UNC\\", 4) == 0) - path = path__skip_server(path + 4); - else if (path__is_absolute(path)) - path += PATH__ABSOLUTE_LEN; - } else if (path__is_absolute(path)) { - path += PATH__ABSOLUTE_LEN; - } else if (path__is_unc(path)) { - path = path__skip_server(path + 2); - } - - return path; -} - -int git_win32_path_canonicalize(git_win32_path path) -{ - wchar_t *base, *from, *to, *next; - size_t len; - - base = to = path__skip_prefix(path); - - /* Unposixify if the prefix */ - for (from = path; from < to; from++) { - if (*from == L'/') - *from = L'\\'; - } - - while (*from) { - for (next = from; *next; ++next) { - if (*next == L'/') { - *next = L'\\'; - break; - } - - if (*next == L'\\') - break; - } - - len = next - from; - - if (len == 1 && from[0] == L'.') - /* do nothing with singleton dot */; - - else if (len == 2 && from[0] == L'.' && from[1] == L'.') { - if (to == base) { - /* no more path segments to strip, eat the "../" */ - if (*next == L'\\') - len++; - - base = to; - } else { - /* back up a path segment */ - while (to > base && to[-1] == L'\\') to--; - while (to > base && to[-1] != L'\\') to--; - } - } else { - if (*next == L'\\' && *from != L'\\') - len++; - - if (to != from) - memmove(to, from, sizeof(wchar_t) * len); - - to += len; - } - - from += len; - - while (*from == L'\\') from++; - } - - /* Strip trailing backslashes */ - while (to > base && to[-1] == L'\\') to--; - - *to = L'\0'; - - return (to - path); -} - -int git_win32_path__cwd(wchar_t *out, size_t len) -{ - int cwd_len; - - if ((cwd_len = path__cwd(out, len)) < 0) - return -1; - - /* UNC paths */ - if (wcsncmp(L"\\\\", out, 2) == 0) { - /* Our buffer must be at least 5 characters larger than the - * current working directory: we swallow one of the leading - * '\'s, but we we add a 'UNC' specifier to the path, plus - * a trailing directory separator, plus a NUL. - */ - if (cwd_len > MAX_PATH - 4) { - errno = ENAMETOOLONG; - return -1; - } - - memmove(out+2, out, sizeof(wchar_t) * cwd_len); - out[0] = L'U'; - out[1] = L'N'; - out[2] = L'C'; - - cwd_len += 2; - } - - /* Our buffer must be at least 2 characters larger than the current - * working directory. (One character for the directory separator, - * one for the null. - */ - else if (cwd_len > MAX_PATH - 2) { - errno = ENAMETOOLONG; - return -1; - } - - return cwd_len; -} - -int git_win32_path_from_utf8(git_win32_path out, const char *src) -{ - wchar_t *dest = out; - - /* All win32 paths are in NT-prefixed format, beginning with "\\?\". */ - memcpy(dest, PATH__NT_NAMESPACE, sizeof(wchar_t) * PATH__NT_NAMESPACE_LEN); - dest += PATH__NT_NAMESPACE_LEN; - - /* See if this is an absolute path (beginning with a drive letter) */ - if (path__is_absolute(src)) { - if (git__utf8_to_16(dest, MAX_PATH, src) < 0) - goto on_error; - } - /* File-prefixed NT-style paths beginning with \\?\ */ - else if (path__is_nt_namespace(src)) { - /* Skip the NT prefix, the destination already contains it */ - if (git__utf8_to_16(dest, MAX_PATH, src + PATH__NT_NAMESPACE_LEN) < 0) - goto on_error; - } - /* UNC paths */ - else if (path__is_unc(src)) { - memcpy(dest, L"UNC\\", sizeof(wchar_t) * 4); - dest += 4; - - /* Skip the leading "\\" */ - if (git__utf8_to_16(dest, MAX_PATH - 2, src + 2) < 0) - goto on_error; - } - /* Absolute paths omitting the drive letter */ - else if (src[0] == '\\' || src[0] == '/') { - if (path__cwd(dest, MAX_PATH) < 0) - goto on_error; - - if (!path__is_absolute(dest)) { - errno = ENOENT; - goto on_error; - } - - /* Skip the drive letter specification ("C:") */ - if (git__utf8_to_16(dest + 2, MAX_PATH - 2, src) < 0) - goto on_error; - } - /* Relative paths */ - else { - int cwd_len; - - if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0) - goto on_error; - - dest[cwd_len++] = L'\\'; - - if (git__utf8_to_16(dest + cwd_len, MAX_PATH - cwd_len, src) < 0) - goto on_error; - } - - return git_win32_path_canonicalize(out); - -on_error: - /* set windows error code so we can use its error message */ - if (errno == ENAMETOOLONG) - SetLastError(ERROR_FILENAME_EXCED_RANGE); - - return -1; -} - -int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src) -{ - char *out = dest; - int len; - - /* Strip NT namespacing "\\?\" */ - if (path__is_nt_namespace(src)) { - src += 4; - - /* "\\?\UNC\server\share" -> "\\server\share" */ - if (wcsncmp(src, L"UNC\\", 4) == 0) { - src += 4; - - memcpy(dest, "\\\\", 2); - out = dest + 2; - } - } - - if ((len = git__utf16_to_8(out, GIT_WIN_PATH_UTF8, src)) < 0) - return len; - - git_path_mkposix(dest); - - return len; -} - -char *git_win32_path_8dot3_name(const char *path) -{ - git_win32_path longpath, shortpath; - wchar_t *start; - char *shortname; - int len, namelen = 1; - - if (git_win32_path_from_utf8(longpath, path) < 0) - return NULL; - - len = GetShortPathNameW(longpath, shortpath, GIT_WIN_PATH_UTF16); - - while (len && shortpath[len-1] == L'\\') - shortpath[--len] = L'\0'; - - if (len == 0 || len >= GIT_WIN_PATH_UTF16) - return NULL; - - for (start = shortpath + (len - 1); - start > shortpath && *(start-1) != '/' && *(start-1) != '\\'; - start--) - namelen++; - - /* We may not have actually been given a short name. But if we have, - * it will be in the ASCII byte range, so we don't need to worry about - * multi-byte sequences and can allocate naively. - */ - if (namelen > 12 || (shortname = git__malloc(namelen + 1)) == NULL) - return NULL; - - if ((len = git__utf16_to_8(shortname, namelen + 1, start)) < 0) - return NULL; - - return shortname; -} - -static bool path_is_volume(wchar_t *target, size_t target_len) -{ - return (target_len && wcsncmp(target, L"\\??\\Volume{", 11) == 0); -} - -/* On success, returns the length, in characters, of the path stored in dest. -* On failure, returns a negative value. */ -int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path) -{ - BYTE buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE]; - GIT_REPARSE_DATA_BUFFER *reparse_buf = (GIT_REPARSE_DATA_BUFFER *)buf; - HANDLE handle = NULL; - DWORD ioctl_ret; - wchar_t *target; - size_t target_len; - - int error = -1; - - handle = CreateFileW(path, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL); - - if (handle == INVALID_HANDLE_VALUE) { - errno = ENOENT; - return -1; - } - - if (!DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, NULL, 0, - reparse_buf, sizeof(buf), &ioctl_ret, NULL)) { - errno = EINVAL; - goto on_error; - } - - switch (reparse_buf->ReparseTag) { - case IO_REPARSE_TAG_SYMLINK: - target = reparse_buf->SymbolicLinkReparseBuffer.PathBuffer + - (reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); - target_len = reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - break; - case IO_REPARSE_TAG_MOUNT_POINT: - target = reparse_buf->MountPointReparseBuffer.PathBuffer + - (reparse_buf->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR)); - target_len = reparse_buf->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR); - break; - default: - errno = EINVAL; - goto on_error; - } - - if (path_is_volume(target, target_len)) { - /* This path is a reparse point that represents another volume mounted - * at this location, it is not a symbolic link our input was canonical. - */ - errno = EINVAL; - error = -1; - } else if (target_len) { - /* The path may need to have a prefix removed. */ - target_len = git_win32__canonicalize_path(target, target_len); - - /* Need one additional character in the target buffer - * for the terminating NULL. */ - if (GIT_WIN_PATH_UTF16 > target_len) { - wcscpy(dest, target); - error = (int)target_len; - } - } - -on_error: - CloseHandle(handle); - return error; -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/path_w32.h r-cran-git2r-0.22.1/src/libgit2/src/win32/path_w32.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/path_w32.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/path_w32.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/* - * 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_path_w32_h__ -#define INCLUDE_git_path_w32_h__ - -#include "common.h" -#include "vector.h" - -/* - * Provides a large enough buffer to support Windows paths: MAX_PATH is - * 260, corresponding to a maximum path length of 259 characters plus a - * NULL terminator. Prefixing with "\\?\" adds 4 characters, but if the - * original was a UNC path, then we turn "\\server\share" into - * "\\?\UNC\server\share". So we replace the first two characters with - * 8 characters, a net gain of 6, so the maximum length is MAX_PATH+6. - */ -#define GIT_WIN_PATH_UTF16 MAX_PATH+6 - -/* Maximum size of a UTF-8 Win32 path. We remove the "\\?\" or "\\?\UNC\" - * prefixes for presentation, bringing us back to 259 (non-NULL) - * characters. UTF-8 does have 4-byte sequences, but they are encoded in - * UTF-16 using surrogate pairs, which takes up the space of two characters. - * Two characters in the range U+0800 -> U+FFFF take up more space in UTF-8 - * (6 bytes) than one surrogate pair (4 bytes). - */ -#define GIT_WIN_PATH_UTF8 (259 * 3 + 1) - -/* - * The length of a Windows "shortname", for 8.3 compatibility. - */ -#define GIT_WIN_PATH_SHORTNAME 13 - -/* Win32 path types */ -typedef wchar_t git_win32_path[GIT_WIN_PATH_UTF16]; -typedef char git_win32_utf8_path[GIT_WIN_PATH_UTF8]; - -/** - * Create a Win32 path (in UCS-2 format) from a UTF-8 string. - * - * @param dest The buffer to receive the wide string. - * @param src The UTF-8 string to convert. - * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure - */ -extern int git_win32_path_from_utf8(git_win32_path dest, const char *src); - -/** - * Canonicalize a Win32 UCS-2 path so that it is suitable for delivery to the - * Win32 APIs: remove multiple directory separators, squashing to a single one, - * strip trailing directory separators, ensure directory separators are all - * canonical (always backslashes, never forward slashes) and process any - * directory entries of '.' or '..'. - * - * This processes the buffer in place. - * - * @param path The buffer to process - * @return The new length of the buffer, in wchar_t's (not counting the NULL terminator) - */ -extern int git_win32_path_canonicalize(git_win32_path path); - -/** - * Create an internal format (posix-style) UTF-8 path from a Win32 UCS-2 path. - * - * @param dest The buffer to receive the UTF-8 string. - * @param src The wide string to convert. - * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure - */ -extern int git_win32_path_to_utf8(git_win32_utf8_path dest, const wchar_t *src); - -/** - * Get the short name for the terminal path component in the given path. - * For example, given "C:\Foo\Bar\Asdf.txt", this will return the short name - * for the file "Asdf.txt". - * - * @param path The given path in UTF-8 - * @return The name of the shortname for the given path - */ -extern char *git_win32_path_8dot3_name(const char *path); - -extern int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/posix.h r-cran-git2r-0.22.1/src/libgit2/src/win32/posix.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/posix.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/posix.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* - * 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_posix__w32_h__ -#define INCLUDE_posix__w32_h__ - -#include "common.h" -#include "../posix.h" -#include "win32-compat.h" -#include "path_w32.h" -#include "utf-conv.h" -#include "dir.h" - -extern unsigned long git_win32__createfile_sharemode; -extern int git_win32__retries; - -typedef SOCKET GIT_SOCKET; - -#define p_lseek(f,n,w) _lseeki64(f, n, w) - -extern int p_fstat(int fd, struct stat *buf); -extern int p_lstat(const char *file_name, struct stat *buf); -extern int p_stat(const char* path, struct stat *buf); - -extern int p_utimes(const char *filename, const struct p_timeval times[2]); -extern int p_futimes(int fd, const struct p_timeval times[2]); - -extern int p_readlink(const char *path, char *buf, size_t bufsiz); -extern int p_symlink(const char *old, const char *new); -extern int p_link(const char *old, const char *new); -extern int p_unlink(const char *path); -extern int p_mkdir(const char *path, mode_t mode); -extern int p_fsync(int fd); -extern char *p_realpath(const char *orig_path, char *buffer); - -extern int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags); -extern int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags); -extern int p_inet_pton(int af, const char* src, void* dst); - -extern int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr); -extern int p_snprintf(char *buffer, size_t count, const char *format, ...) GIT_FORMAT_PRINTF(3, 4); -extern int p_mkstemp(char *tmp_path); -extern int p_chdir(const char* path); -extern int p_chmod(const char* path, mode_t mode); -extern int p_rmdir(const char* path); -extern int p_access(const char* path, mode_t mode); -extern int p_ftruncate(int fd, git_off_t size); - -/* p_lstat is almost but not quite POSIX correct. Specifically, the use of - * ENOTDIR is wrong, in that it does not mean precisely that a non-directory - * entry was encountered. Making it correct is potentially expensive, - * however, so this is a separate version of p_lstat to use when correct - * POSIX ENOTDIR semantics is required. - */ -extern int p_lstat_posixly(const char *filename, struct stat *buf); - -extern struct tm * p_localtime_r(const time_t *timer, struct tm *result); -extern struct tm * p_gmtime_r(const time_t *timer, struct tm *result); - -/* Use the bundled regcomp */ -#define p_regcomp regcomp - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/posix_w32.c r-cran-git2r-0.22.1/src/libgit2/src/win32/posix_w32.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/posix_w32.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/posix_w32.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,946 +0,0 @@ -/* - * 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. - */ -#include "../posix.h" -#include "../fileops.h" -#include "path.h" -#include "path_w32.h" -#include "utf-conv.h" -#include "repository.h" -#include "reparse.h" -#include "global.h" -#include "buffer.h" -#include -#include -#include -#include - -#ifndef FILE_NAME_NORMALIZED -# define FILE_NAME_NORMALIZED 0 -#endif - -#ifndef IO_REPARSE_TAG_SYMLINK -#define IO_REPARSE_TAG_SYMLINK (0xA000000CL) -#endif - -/* Allowable mode bits on Win32. Using mode bits that are not supported on - * Win32 (eg S_IRWXU) is generally ignored, but Wine warns loudly about it - * so we simply remove them. - */ -#define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE) - -/* GetFinalPathNameByHandleW signature */ -typedef DWORD(WINAPI *PFGetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, DWORD); - -unsigned long git_win32__createfile_sharemode = - FILE_SHARE_READ | FILE_SHARE_WRITE; -int git_win32__retries = 10; - -GIT_INLINE(void) set_errno(void) -{ - switch (GetLastError()) { - case ERROR_FILE_NOT_FOUND: - case ERROR_PATH_NOT_FOUND: - case ERROR_INVALID_DRIVE: - case ERROR_NO_MORE_FILES: - case ERROR_BAD_NETPATH: - case ERROR_BAD_NET_NAME: - case ERROR_BAD_PATHNAME: - case ERROR_FILENAME_EXCED_RANGE: - errno = ENOENT; - break; - case ERROR_BAD_ENVIRONMENT: - errno = E2BIG; - break; - case ERROR_BAD_FORMAT: - case ERROR_INVALID_STARTING_CODESEG: - case ERROR_INVALID_STACKSEG: - case ERROR_INVALID_MODULETYPE: - case ERROR_INVALID_EXE_SIGNATURE: - case ERROR_EXE_MARKED_INVALID: - case ERROR_BAD_EXE_FORMAT: - case ERROR_ITERATED_DATA_EXCEEDS_64k: - case ERROR_INVALID_MINALLOCSIZE: - case ERROR_DYNLINK_FROM_INVALID_RING: - case ERROR_IOPL_NOT_ENABLED: - case ERROR_INVALID_SEGDPL: - case ERROR_AUTODATASEG_EXCEEDS_64k: - case ERROR_RING2SEG_MUST_BE_MOVABLE: - case ERROR_RELOC_CHAIN_XEEDS_SEGLIM: - case ERROR_INFLOOP_IN_RELOC_CHAIN: - errno = ENOEXEC; - break; - case ERROR_INVALID_HANDLE: - case ERROR_INVALID_TARGET_HANDLE: - case ERROR_DIRECT_ACCESS_HANDLE: - errno = EBADF; - break; - case ERROR_WAIT_NO_CHILDREN: - case ERROR_CHILD_NOT_COMPLETE: - errno = ECHILD; - break; - case ERROR_NO_PROC_SLOTS: - case ERROR_MAX_THRDS_REACHED: - case ERROR_NESTING_NOT_ALLOWED: - errno = EAGAIN; - break; - case ERROR_ARENA_TRASHED: - case ERROR_NOT_ENOUGH_MEMORY: - case ERROR_INVALID_BLOCK: - case ERROR_NOT_ENOUGH_QUOTA: - errno = ENOMEM; - break; - case ERROR_ACCESS_DENIED: - case ERROR_CURRENT_DIRECTORY: - case ERROR_WRITE_PROTECT: - case ERROR_BAD_UNIT: - case ERROR_NOT_READY: - case ERROR_BAD_COMMAND: - case ERROR_CRC: - case ERROR_BAD_LENGTH: - case ERROR_SEEK: - case ERROR_NOT_DOS_DISK: - case ERROR_SECTOR_NOT_FOUND: - case ERROR_OUT_OF_PAPER: - case ERROR_WRITE_FAULT: - case ERROR_READ_FAULT: - case ERROR_GEN_FAILURE: - case ERROR_SHARING_VIOLATION: - case ERROR_LOCK_VIOLATION: - case ERROR_WRONG_DISK: - case ERROR_SHARING_BUFFER_EXCEEDED: - case ERROR_NETWORK_ACCESS_DENIED: - case ERROR_CANNOT_MAKE: - case ERROR_FAIL_I24: - case ERROR_DRIVE_LOCKED: - case ERROR_SEEK_ON_DEVICE: - case ERROR_NOT_LOCKED: - case ERROR_LOCK_FAILED: - errno = EACCES; - break; - case ERROR_FILE_EXISTS: - case ERROR_ALREADY_EXISTS: - errno = EEXIST; - break; - case ERROR_NOT_SAME_DEVICE: - errno = EXDEV; - break; - case ERROR_INVALID_FUNCTION: - case ERROR_INVALID_ACCESS: - case ERROR_INVALID_DATA: - case ERROR_INVALID_PARAMETER: - case ERROR_NEGATIVE_SEEK: - errno = EINVAL; - break; - case ERROR_TOO_MANY_OPEN_FILES: - errno = EMFILE; - break; - case ERROR_DISK_FULL: - errno = ENOSPC; - break; - case ERROR_BROKEN_PIPE: - errno = EPIPE; - break; - case ERROR_DIR_NOT_EMPTY: - errno = ENOTEMPTY; - break; - default: - errno = EINVAL; - } -} - -GIT_INLINE(bool) last_error_retryable(void) -{ - int os_error = GetLastError(); - - return (os_error == ERROR_SHARING_VIOLATION || - os_error == ERROR_ACCESS_DENIED); -} - -#define do_with_retries(fn, remediation) \ - do { \ - int __tries, __ret; \ - for (__tries = 0; __tries < git_win32__retries; __tries++) { \ - if (__tries && (__ret = (remediation)) != 0) \ - return __ret; \ - if ((__ret = (fn)) != GIT_RETRY) \ - return __ret; \ - Sleep(5); \ - } \ - return -1; \ - } while (0) \ - -static int ensure_writable(wchar_t *path) -{ - DWORD attrs; - - if ((attrs = GetFileAttributesW(path)) == INVALID_FILE_ATTRIBUTES) - goto on_error; - - if ((attrs & FILE_ATTRIBUTE_READONLY) == 0) - return 0; - - if (!SetFileAttributesW(path, (attrs & ~FILE_ATTRIBUTE_READONLY))) - goto on_error; - - return 0; - -on_error: - set_errno(); - return -1; -} - -/** - * Truncate or extend file. - * - * We now take a "git_off_t" rather than "long" because - * files may be longer than 2Gb. - */ -int p_ftruncate(int fd, git_off_t size) -{ - if (size < 0) { - errno = EINVAL; - return -1; - } - -#if !defined(__MINGW32__) || defined(MINGW_HAS_SECURE_API) - return ((_chsize_s(fd, size) == 0) ? 0 : -1); -#else - /* TODO MINGW32 Find a replacement for _chsize() that handles big files. */ - if (size > INT32_MAX) { - errno = EFBIG; - return -1; - } - return _chsize(fd, (long)size); -#endif -} - -int p_mkdir(const char *path, mode_t mode) -{ - git_win32_path buf; - - GIT_UNUSED(mode); - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - return _wmkdir(buf); -} - -int p_link(const char *old, const char *new) -{ - GIT_UNUSED(old); - GIT_UNUSED(new); - errno = ENOSYS; - return -1; -} - -GIT_INLINE(int) unlink_once(const wchar_t *path) -{ - if (DeleteFileW(path)) - return 0; - - if (last_error_retryable()) - return GIT_RETRY; - - set_errno(); - return -1; -} - -int p_unlink(const char *path) -{ - git_win32_path wpath; - - if (git_win32_path_from_utf8(wpath, path) < 0) - return -1; - - do_with_retries(unlink_once(wpath), ensure_writable(wpath)); -} - -int p_fsync(int fd) -{ - HANDLE fh = (HANDLE)_get_osfhandle(fd); - - p_fsync__cnt++; - - if (fh == INVALID_HANDLE_VALUE) { - errno = EBADF; - return -1; - } - - if (!FlushFileBuffers(fh)) { - DWORD code = GetLastError(); - - if (code == ERROR_INVALID_HANDLE) - errno = EINVAL; - else - errno = EIO; - - return -1; - } - - return 0; -} - -#define WIN32_IS_WSEP(CH) ((CH) == L'/' || (CH) == L'\\') - -static int lstat_w( - wchar_t *path, - struct stat *buf, - bool posix_enotdir) -{ - WIN32_FILE_ATTRIBUTE_DATA fdata; - - if (GetFileAttributesExW(path, GetFileExInfoStandard, &fdata)) { - if (!buf) - return 0; - - return git_win32__file_attribute_to_stat(buf, &fdata, path); - } - - switch (GetLastError()) { - case ERROR_ACCESS_DENIED: - errno = EACCES; - break; - default: - errno = ENOENT; - break; - } - - /* To match POSIX behavior, set ENOTDIR when any of the folders in the - * file path is a regular file, otherwise set ENOENT. - */ - if (errno == ENOENT && posix_enotdir) { - size_t path_len = wcslen(path); - - /* scan up path until we find an existing item */ - while (1) { - DWORD attrs; - - /* remove last directory component */ - for (path_len--; path_len > 0 && !WIN32_IS_WSEP(path[path_len]); path_len--); - - if (path_len <= 0) - break; - - path[path_len] = L'\0'; - attrs = GetFileAttributesW(path); - - if (attrs != INVALID_FILE_ATTRIBUTES) { - if (!(attrs & FILE_ATTRIBUTE_DIRECTORY)) - errno = ENOTDIR; - break; - } - } - } - - return -1; -} - -static int do_lstat(const char *path, struct stat *buf, bool posixly_correct) -{ - git_win32_path path_w; - int len; - - if ((len = git_win32_path_from_utf8(path_w, path)) < 0) - return -1; - - git_win32__path_trim_end(path_w, len); - - return lstat_w(path_w, buf, posixly_correct); -} - -int p_lstat(const char *filename, struct stat *buf) -{ - return do_lstat(filename, buf, false); -} - -int p_lstat_posixly(const char *filename, struct stat *buf) -{ - return do_lstat(filename, buf, true); -} - -int p_readlink(const char *path, char *buf, size_t bufsiz) -{ - git_win32_path path_w, target_w; - git_win32_utf8_path target; - int len; - - /* readlink(2) does not NULL-terminate the string written - * to the target buffer. Furthermore, the target buffer need - * not be large enough to hold the entire result. A truncated - * result should be written in this case. Since this truncation - * could occur in the middle of the encoding of a code point, - * we need to buffer the result on the stack. */ - - if (git_win32_path_from_utf8(path_w, path) < 0 || - git_win32_path_readlink_w(target_w, path_w) < 0 || - (len = git_win32_path_to_utf8(target, target_w)) < 0) - return -1; - - bufsiz = min((size_t)len, bufsiz); - memcpy(buf, target, bufsiz); - - return (int)bufsiz; -} - -int p_symlink(const char *old, const char *new) -{ - /* Real symlinks on NTFS require admin privileges. Until this changes, - * libgit2 just creates a text file with the link target in the contents. - */ - return git_futils_fake_symlink(old, new); -} - -struct open_opts { - DWORD access; - DWORD sharing; - SECURITY_ATTRIBUTES security; - DWORD creation_disposition; - DWORD attributes; - int osf_flags; -}; - -GIT_INLINE(void) open_opts_from_posix(struct open_opts *opts, int flags, mode_t mode) -{ - memset(opts, 0, sizeof(struct open_opts)); - - switch (flags & (O_WRONLY | O_RDWR)) { - case O_WRONLY: - opts->access = GENERIC_WRITE; - break; - case O_RDWR: - opts->access = GENERIC_READ | GENERIC_WRITE; - break; - default: - opts->access = GENERIC_READ; - break; - } - - opts->sharing = (DWORD)git_win32__createfile_sharemode; - - switch (flags & (O_CREAT | O_TRUNC | O_EXCL)) { - case O_CREAT | O_EXCL: - case O_CREAT | O_TRUNC | O_EXCL: - opts->creation_disposition = CREATE_NEW; - break; - case O_CREAT | O_TRUNC: - opts->creation_disposition = CREATE_ALWAYS; - break; - case O_TRUNC: - opts->creation_disposition = TRUNCATE_EXISTING; - break; - case O_CREAT: - opts->creation_disposition = OPEN_ALWAYS; - break; - default: - opts->creation_disposition = OPEN_EXISTING; - break; - } - - opts->attributes = ((flags & O_CREAT) && !(mode & S_IWRITE)) ? - FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL; - opts->osf_flags = flags & (O_RDONLY | O_APPEND); - - opts->security.nLength = sizeof(SECURITY_ATTRIBUTES); - opts->security.lpSecurityDescriptor = NULL; - opts->security.bInheritHandle = 0; -} - -GIT_INLINE(int) open_once( - const wchar_t *path, - struct open_opts *opts) -{ - int fd; - - HANDLE handle = CreateFileW(path, opts->access, opts->sharing, - &opts->security, opts->creation_disposition, opts->attributes, 0); - - if (handle == INVALID_HANDLE_VALUE) { - if (last_error_retryable()) - return GIT_RETRY; - - set_errno(); - return -1; - } - - if ((fd = _open_osfhandle((intptr_t)handle, opts->osf_flags)) < 0) - CloseHandle(handle); - - return fd; -} - -int p_open(const char *path, int flags, ...) -{ - git_win32_path wpath; - mode_t mode = 0; - struct open_opts opts = {0}; - - if (git_win32_path_from_utf8(wpath, path) < 0) - return -1; - - if (flags & O_CREAT) { - va_list arg_list; - - va_start(arg_list, flags); - mode = (mode_t)va_arg(arg_list, int); - va_end(arg_list); - } - - open_opts_from_posix(&opts, flags, mode); - - do_with_retries( - open_once(wpath, &opts), - 0); -} - -int p_creat(const char *path, mode_t mode) -{ - return p_open(path, O_WRONLY | O_CREAT | O_TRUNC, mode); -} - -int p_utimes(const char *path, const struct p_timeval times[2]) -{ - git_win32_path wpath; - int fd, error; - DWORD attrs_orig, attrs_new = 0; - struct open_opts opts = { 0 }; - - if (git_win32_path_from_utf8(wpath, path) < 0) - return -1; - - attrs_orig = GetFileAttributesW(wpath); - - if (attrs_orig & FILE_ATTRIBUTE_READONLY) { - attrs_new = attrs_orig & ~FILE_ATTRIBUTE_READONLY; - - if (!SetFileAttributesW(wpath, attrs_new)) { - giterr_set(GITERR_OS, "failed to set attributes"); - return -1; - } - } - - open_opts_from_posix(&opts, O_RDWR, 0); - - if ((fd = open_once(wpath, &opts)) < 0) { - error = -1; - goto done; - } - - error = p_futimes(fd, times); - close(fd); - -done: - if (attrs_orig != attrs_new) { - DWORD os_error = GetLastError(); - SetFileAttributesW(wpath, attrs_orig); - SetLastError(os_error); - } - - return error; -} - -int p_futimes(int fd, const struct p_timeval times[2]) -{ - HANDLE handle; - FILETIME atime = { 0 }, mtime = { 0 }; - - if (times == NULL) { - SYSTEMTIME st; - - GetSystemTime(&st); - SystemTimeToFileTime(&st, &atime); - SystemTimeToFileTime(&st, &mtime); - } - else { - git_win32__timeval_to_filetime(&atime, times[0]); - git_win32__timeval_to_filetime(&mtime, times[1]); - } - - if ((handle = (HANDLE)_get_osfhandle(fd)) == INVALID_HANDLE_VALUE) - return -1; - - if (SetFileTime(handle, NULL, &atime, &mtime) == 0) - return -1; - - return 0; -} - -int p_getcwd(char *buffer_out, size_t size) -{ - git_win32_path buf; - wchar_t *cwd = _wgetcwd(buf, GIT_WIN_PATH_UTF16); - - if (!cwd) - return -1; - - /* Convert the working directory back to UTF-8 */ - if (git__utf16_to_8(buffer_out, size, cwd) < 0) { - DWORD code = GetLastError(); - - if (code == ERROR_INSUFFICIENT_BUFFER) - errno = ERANGE; - else - errno = EINVAL; - - return -1; - } - - return 0; -} - -/* - * Returns the address of the GetFinalPathNameByHandleW function. - * This function is available on Windows Vista and higher. - */ -static PFGetFinalPathNameByHandleW get_fpnbyhandle(void) -{ - static PFGetFinalPathNameByHandleW pFunc = NULL; - PFGetFinalPathNameByHandleW toReturn = pFunc; - - if (!toReturn) { - HMODULE hModule = GetModuleHandleW(L"kernel32"); - - if (hModule) - toReturn = (PFGetFinalPathNameByHandleW)GetProcAddress(hModule, "GetFinalPathNameByHandleW"); - - pFunc = toReturn; - } - - assert(toReturn); - - return toReturn; -} - -static int getfinalpath_w( - git_win32_path dest, - const wchar_t *path) -{ - PFGetFinalPathNameByHandleW pgfp = get_fpnbyhandle(); - HANDLE hFile; - DWORD dwChars; - - if (!pgfp) - return -1; - - /* Use FILE_FLAG_BACKUP_SEMANTICS so we can open a directory. Do not - * specify FILE_FLAG_OPEN_REPARSE_POINT; we want to open a handle to the - * target of the link. */ - hFile = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE, - NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); - - if (INVALID_HANDLE_VALUE == hFile) - return -1; - - /* Call GetFinalPathNameByHandle */ - dwChars = pgfp(hFile, dest, GIT_WIN_PATH_UTF16, FILE_NAME_NORMALIZED); - CloseHandle(hFile); - - if (!dwChars || dwChars >= GIT_WIN_PATH_UTF16) - return -1; - - /* The path may be delivered to us with a prefix; canonicalize */ - return (int)git_win32__canonicalize_path(dest, dwChars); -} - -static int follow_and_lstat_link(git_win32_path path, struct stat* buf) -{ - git_win32_path target_w; - - if (getfinalpath_w(target_w, path) < 0) - return -1; - - return lstat_w(target_w, buf, false); -} - -int p_fstat(int fd, struct stat *buf) -{ - BY_HANDLE_FILE_INFORMATION fhInfo; - - HANDLE fh = (HANDLE)_get_osfhandle(fd); - - if (fh == INVALID_HANDLE_VALUE || - !GetFileInformationByHandle(fh, &fhInfo)) { - errno = EBADF; - return -1; - } - - git_win32__file_information_to_stat(buf, &fhInfo); - return 0; -} - -int p_stat(const char* path, struct stat* buf) -{ - git_win32_path path_w; - int len; - - if ((len = git_win32_path_from_utf8(path_w, path)) < 0 || - lstat_w(path_w, buf, false) < 0) - return -1; - - /* The item is a symbolic link or mount point. No need to iterate - * to follow multiple links; use GetFinalPathNameFromHandle. */ - if (S_ISLNK(buf->st_mode)) - return follow_and_lstat_link(path_w, buf); - - return 0; -} - -int p_chdir(const char* path) -{ - git_win32_path buf; - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - return _wchdir(buf); -} - -int p_chmod(const char* path, mode_t mode) -{ - git_win32_path buf; - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - return _wchmod(buf, mode); -} - -int p_rmdir(const char* path) -{ - git_win32_path buf; - int error; - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - error = _wrmdir(buf); - - if (error == -1) { - switch (GetLastError()) { - /* _wrmdir() is documented to return EACCES if "A program has an open - * handle to the directory." This sounds like what everybody else calls - * EBUSY. Let's convert appropriate error codes. - */ - case ERROR_SHARING_VIOLATION: - errno = EBUSY; - break; - - /* This error can be returned when trying to rmdir an extant file. */ - case ERROR_DIRECTORY: - errno = ENOTDIR; - break; - } - } - - return error; -} - -char *p_realpath(const char *orig_path, char *buffer) -{ - git_win32_path orig_path_w, buffer_w; - - if (git_win32_path_from_utf8(orig_path_w, orig_path) < 0) - return NULL; - - /* Note that if the path provided is a relative path, then the current directory - * is used to resolve the path -- which is a concurrency issue because the current - * directory is a process-wide variable. */ - if (!GetFullPathNameW(orig_path_w, GIT_WIN_PATH_UTF16, buffer_w, NULL)) { - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - errno = ENAMETOOLONG; - else - errno = EINVAL; - - return NULL; - } - - /* The path must exist. */ - if (GetFileAttributesW(buffer_w) == INVALID_FILE_ATTRIBUTES) { - errno = ENOENT; - return NULL; - } - - if (!buffer && !(buffer = git__malloc(GIT_WIN_PATH_UTF8))) { - errno = ENOMEM; - return NULL; - } - - /* Convert the path to UTF-8. If the caller provided a buffer, then it - * is assumed to be GIT_WIN_PATH_UTF8 characters in size. If it isn't, - * then we may overflow. */ - if (git_win32_path_to_utf8(buffer, buffer_w) < 0) - return NULL; - - git_path_mkposix(buffer); - - return buffer; -} - -int p_vsnprintf(char *buffer, size_t count, const char *format, va_list argptr) -{ -#if defined(_MSC_VER) - int len; - - if (count == 0) - return _vscprintf(format, argptr); - - #if _MSC_VER >= 1500 - len = _vsnprintf_s(buffer, count, _TRUNCATE, format, argptr); - #else - len = _vsnprintf(buffer, count, format, argptr); - #endif - - if (len < 0) - return _vscprintf(format, argptr); - - return len; -#else /* MinGW */ - return vsnprintf(buffer, count, format, argptr); -#endif -} - -int p_snprintf(char *buffer, size_t count, const char *format, ...) -{ - va_list va; - int r; - - va_start(va, format); - r = p_vsnprintf(buffer, count, format, va); - va_end(va); - - return r; -} - -/* TODO: wut? */ -int p_mkstemp(char *tmp_path) -{ -#if defined(_MSC_VER) && _MSC_VER >= 1500 - if (_mktemp_s(tmp_path, strlen(tmp_path) + 1) != 0) - return -1; -#else - if (_mktemp(tmp_path) == NULL) - return -1; -#endif - - return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); //-V536 -} - -int p_access(const char* path, mode_t mode) -{ - git_win32_path buf; - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - return _waccess(buf, mode & WIN32_MODE_MASK); -} - -GIT_INLINE(int) rename_once(const wchar_t *from, const wchar_t *to) -{ - if (MoveFileExW(from, to, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED)) - return 0; - - if (last_error_retryable()) - return GIT_RETRY; - - set_errno(); - return -1; -} - -int p_rename(const char *from, const char *to) -{ - git_win32_path wfrom, wto; - - if (git_win32_path_from_utf8(wfrom, from) < 0 || - git_win32_path_from_utf8(wto, to) < 0) - return -1; - - do_with_retries(rename_once(wfrom, wto), ensure_writable(wto)); -} - -int p_recv(GIT_SOCKET socket, void *buffer, size_t length, int flags) -{ - if ((size_t)((int)length) != length) - return -1; /* giterr_set will be done by caller */ - - return recv(socket, buffer, (int)length, flags); -} - -int p_send(GIT_SOCKET socket, const void *buffer, size_t length, int flags) -{ - if ((size_t)((int)length) != length) - return -1; /* giterr_set will be done by caller */ - - return send(socket, buffer, (int)length, flags); -} - -/** - * Borrowed from http://old.nabble.com/Porting-localtime_r-and-gmtime_r-td15282276.html - * On Win32, `gmtime_r` doesn't exist but `gmtime` is threadsafe, so we can use that - */ -struct tm * -p_localtime_r (const time_t *timer, struct tm *result) -{ - struct tm *local_result; - local_result = localtime (timer); - - if (local_result == NULL || result == NULL) - return NULL; - - memcpy (result, local_result, sizeof (struct tm)); - return result; -} -struct tm * -p_gmtime_r (const time_t *timer, struct tm *result) -{ - struct tm *local_result; - local_result = gmtime (timer); - - if (local_result == NULL || result == NULL) - return NULL; - - memcpy (result, local_result, sizeof (struct tm)); - return result; -} - -int p_inet_pton(int af, const char *src, void *dst) -{ - struct sockaddr_storage sin; - void *addr; - int sin_len = sizeof(struct sockaddr_storage), addr_len; - int error = 0; - - if (af == AF_INET) { - addr = &((struct sockaddr_in *)&sin)->sin_addr; - addr_len = sizeof(struct in_addr); - } else if (af == AF_INET6) { - addr = &((struct sockaddr_in6 *)&sin)->sin6_addr; - addr_len = sizeof(struct in6_addr); - } else { - errno = EAFNOSUPPORT; - return -1; - } - - if ((error = WSAStringToAddressA((LPSTR)src, af, NULL, (LPSOCKADDR)&sin, &sin_len)) == 0) { - memcpy(dst, addr, addr_len); - return 1; - } - - switch(WSAGetLastError()) { - case WSAEINVAL: - return 0; - case WSAEFAULT: - errno = ENOSPC; - return -1; - case WSA_NOT_ENOUGH_MEMORY: - errno = ENOMEM; - return -1; - } - - errno = EINVAL; - return -1; -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/precompiled.c r-cran-git2r-0.22.1/src/libgit2/src/win32/precompiled.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/precompiled.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/precompiled.c 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -#include "precompiled.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/precompiled.h r-cran-git2r-0.22.1/src/libgit2/src/win32/precompiled.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/precompiled.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/precompiled.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include -#ifdef GIT_THREADS - #include "win32/thread.h" -#endif - -#include "git2.h" -#include "common.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/reparse.h r-cran-git2r-0.22.1/src/libgit2/src/win32/reparse.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/reparse.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/reparse.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -* 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_win32_reparse_h__ -#define INCLUDE_git_win32_reparse_h__ - -/* This structure is defined on MSDN at -* http://msdn.microsoft.com/en-us/library/windows/hardware/ff552012(v=vs.85).aspx -* -* It was formerly included in the Windows 2000 SDK and remains defined in -* MinGW, so we must define it with a silly name to avoid conflicting. -*/ -typedef struct _GIT_REPARSE_DATA_BUFFER { - ULONG ReparseTag; - USHORT ReparseDataLength; - USHORT Reserved; - _ANONYMOUS_UNION union { - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[1]; - } SymbolicLinkReparseBuffer; - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - WCHAR PathBuffer[1]; - } MountPointReparseBuffer; - struct { - UCHAR DataBuffer[1]; - } GenericReparseBuffer; - } DUMMYUNIONNAME; -} GIT_REPARSE_DATA_BUFFER; - -#define REPARSE_DATA_HEADER_SIZE 8 -#define REPARSE_DATA_MOUNTPOINT_HEADER_SIZE 8 -#define REPARSE_DATA_UNION_SIZE 12 - -/* Missing in MinGW */ -#ifndef FSCTL_GET_REPARSE_POINT -# define FSCTL_GET_REPARSE_POINT 0x000900a8 -#endif - -/* Missing in MinGW */ -#ifndef FSCTL_SET_REPARSE_POINT -# define FSCTL_SET_REPARSE_POINT 0x000900a4 -#endif - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/thread.h r-cran-git2r-0.22.1/src/libgit2/src/win32/thread.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/thread.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/thread.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* - * 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_win32_thread_h__ -#define INCLUDE_win32_thread_h__ - -#include "../common.h" - -#if defined (_MSC_VER) -# define GIT_RESTRICT __restrict -#else -# define GIT_RESTRICT __restrict__ -#endif - -typedef struct { - HANDLE thread; - void *(*proc)(void *); - void *param; - void *result; -} git_thread; - -typedef CRITICAL_SECTION git_mutex; -typedef HANDLE git_cond; - -typedef struct { void *Ptr; } GIT_SRWLOCK; - -typedef struct { - union { - GIT_SRWLOCK srwl; - CRITICAL_SECTION csec; - } native; -} git_rwlock; - -int git_threads_init(void); - -int git_thread_create(git_thread *GIT_RESTRICT, - void *(*) (void *), - void *GIT_RESTRICT); -int git_thread_join(git_thread *, void **); -size_t git_thread_currentid(void); -void git_thread_exit(void *); - -int git_mutex_init(git_mutex *GIT_RESTRICT mutex); -int git_mutex_free(git_mutex *); -int git_mutex_lock(git_mutex *); -int git_mutex_unlock(git_mutex *); - -int git_cond_init(git_cond *); -int git_cond_free(git_cond *); -int git_cond_wait(git_cond *, git_mutex *); -int git_cond_signal(git_cond *); - -int git_rwlock_init(git_rwlock *GIT_RESTRICT lock); -int git_rwlock_rdlock(git_rwlock *); -int git_rwlock_rdunlock(git_rwlock *); -int git_rwlock_wrlock(git_rwlock *); -int git_rwlock_wrunlock(git_rwlock *); -int git_rwlock_free(git_rwlock *); - -#endif /* INCLUDE_win32_thread_h__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/utf-conv.c r-cran-git2r-0.22.1/src/libgit2/src/win32/utf-conv.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/utf-conv.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/utf-conv.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "utf-conv.h" - -GIT_INLINE(void) git__set_errno(void) -{ - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - errno = ENAMETOOLONG; - else - errno = EINVAL; -} - -/** - * Converts a UTF-8 string to wide characters. - * - * @param dest The buffer to receive the wide string. - * @param dest_size The size of the buffer, in characters. - * @param src The UTF-8 string to convert. - * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure - */ -int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src) -{ - int len; - - /* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to - * turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's - * length. MultiByteToWideChar never returns int's minvalue, so underflow is not possible */ - if ((len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, dest, (int)dest_size) - 1) < 0) - git__set_errno(); - - return len; -} - -/** - * Converts a wide string to UTF-8. - * - * @param dest The buffer to receive the UTF-8 string. - * @param dest_size The size of the buffer, in bytes. - * @param src The wide string to convert. - * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure - */ -int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src) -{ - int len; - - /* Length of -1 indicates NULL termination of the input string. Subtract 1 from the result to - * turn 0 into -1 (an error code) and to not count the NULL terminator as part of the string's - * length. WideCharToMultiByte never returns int's minvalue, so underflow is not possible */ - if ((len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, dest, (int)dest_size, NULL, NULL) - 1) < 0) - git__set_errno(); - - return len; -} - -/** - * Converts a UTF-8 string to wide characters. - * Memory is allocated to hold the converted string. - * The caller is responsible for freeing the string with git__free. - * - * @param dest Receives a pointer to the wide string. - * @param src The UTF-8 string to convert. - * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure - */ -int git__utf8_to_16_alloc(wchar_t **dest, const char *src) -{ - int utf16_size; - - *dest = NULL; - - /* Length of -1 indicates NULL termination of the input string */ - utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, NULL, 0); - - if (!utf16_size) { - git__set_errno(); - return -1; - } - - if (!(*dest = git__mallocarray(utf16_size, sizeof(wchar_t)))) { - errno = ENOMEM; - return -1; - } - - utf16_size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, src, -1, *dest, utf16_size); - - if (!utf16_size) { - git__set_errno(); - - git__free(*dest); - *dest = NULL; - } - - /* Subtract 1 from the result to turn 0 into -1 (an error code) and to not count the NULL - * terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue, - * so underflow is not possible */ - return utf16_size - 1; -} - -/** - * Converts a wide string to UTF-8. - * Memory is allocated to hold the converted string. - * The caller is responsible for freeing the string with git__free. - * - * @param dest Receives a pointer to the UTF-8 string. - * @param src The wide string to convert. - * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure - */ -int git__utf16_to_8_alloc(char **dest, const wchar_t *src) -{ - int utf8_size; - - *dest = NULL; - - /* Length of -1 indicates NULL termination of the input string */ - utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, NULL, 0, NULL, NULL); - - if (!utf8_size) { - git__set_errno(); - return -1; - } - - *dest = git__malloc(utf8_size); - - if (!*dest) { - errno = ENOMEM; - return -1; - } - - utf8_size = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, src, -1, *dest, utf8_size, NULL, NULL); - - if (!utf8_size) { - git__set_errno(); - - git__free(*dest); - *dest = NULL; - } - - /* Subtract 1 from the result to turn 0 into -1 (an error code) and to not count the NULL - * terminator as part of the string's length. MultiByteToWideChar never returns int's minvalue, - * so underflow is not possible */ - return utf8_size - 1; -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/utf-conv.h r-cran-git2r-0.22.1/src/libgit2/src/win32/utf-conv.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/utf-conv.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/utf-conv.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* - * 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_utfconv_h__ -#define INCLUDE_git_utfconv_h__ - -#include -#include "common.h" - -#ifndef WC_ERR_INVALID_CHARS -# define WC_ERR_INVALID_CHARS 0x80 -#endif - -/** - * Converts a UTF-8 string to wide characters. - * - * @param dest The buffer to receive the wide string. - * @param dest_size The size of the buffer, in characters. - * @param src The UTF-8 string to convert. - * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure - */ -int git__utf8_to_16(wchar_t *dest, size_t dest_size, const char *src); - -/** - * Converts a wide string to UTF-8. - * - * @param dest The buffer to receive the UTF-8 string. - * @param dest_size The size of the buffer, in bytes. - * @param src The wide string to convert. - * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure - */ -int git__utf16_to_8(char *dest, size_t dest_size, const wchar_t *src); - -/** - * Converts a UTF-8 string to wide characters. - * Memory is allocated to hold the converted string. - * The caller is responsible for freeing the string with git__free. - * - * @param dest Receives a pointer to the wide string. - * @param src The UTF-8 string to convert. - * @return The length of the wide string, in characters (not counting the NULL terminator), or < 0 for failure - */ -int git__utf8_to_16_alloc(wchar_t **dest, const char *src); - -/** - * Converts a wide string to UTF-8. - * Memory is allocated to hold the converted string. - * The caller is responsible for freeing the string with git__free. - * - * @param dest Receives a pointer to the UTF-8 string. - * @param src The wide string to convert. - * @return The length of the UTF-8 string, in bytes (not counting the NULL terminator), or < 0 for failure - */ -int git__utf16_to_8_alloc(char **dest, const wchar_t *src); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/version.h r-cran-git2r-0.22.1/src/libgit2/src/win32/version.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/version.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/version.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* - * 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_win32_version_h__ -#define INCLUDE_win32_version_h__ - -#include - -GIT_INLINE(int) git_has_win32_version(int major, int minor, int service_pack) -{ - OSVERSIONINFOEX version_test = {0}; - DWORD version_test_mask; - DWORDLONG version_condition_mask = 0; - - version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - version_test.dwMajorVersion = major; - version_test.dwMinorVersion = minor; - version_test.wServicePackMajor = (WORD)service_pack; - version_test.wServicePackMinor = 0; - - version_test_mask = (VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR); - - VER_SET_CONDITION(version_condition_mask, VER_MAJORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(version_condition_mask, VER_MINORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); - VER_SET_CONDITION(version_condition_mask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL); - - if (!VerifyVersionInfo(&version_test, version_test_mask, version_condition_mask)) - return 0; - - return 1; -} - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_buffer.c r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_buffer.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_buffer.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_buffer.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* - * 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. - */ - -#include "common.h" -#include "w32_buffer.h" -#include "../buffer.h" -#include "utf-conv.h" - -GIT_INLINE(int) handle_wc_error(void) -{ - if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) - errno = ENAMETOOLONG; - else - errno = EINVAL; - - return -1; -} - -int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w) -{ - int utf8_len, utf8_write_len; - size_t new_size; - - if (!len_w) - return 0; - - assert(string_w); - - /* Measure the string necessary for conversion */ - if ((utf8_len = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, string_w, len_w, NULL, 0, NULL, NULL)) == 0) - return 0; - - assert(utf8_len > 0); - - GITERR_CHECK_ALLOC_ADD(&new_size, buf->size, (size_t)utf8_len); - GITERR_CHECK_ALLOC_ADD(&new_size, new_size, 1); - - if (git_buf_grow(buf, new_size) < 0) - return -1; - - if ((utf8_write_len = WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, string_w, len_w, &buf->ptr[buf->size], utf8_len, NULL, NULL)) == 0) - return handle_wc_error(); - - assert(utf8_write_len == utf8_len); - - buf->size += utf8_write_len; - buf->ptr[buf->size] = '\0'; - return 0; -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_buffer.h r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_buffer.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_buffer.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_buffer.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* - * 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_win32_buffer_h__ -#define INCLUDE_git_win32_buffer_h__ - -#include "../buffer.h" - -/** - * Convert a wide character string to UTF-8 and append the results to the - * buffer. - */ -int git_buf_put_w(git_buf *buf, const wchar_t *string_w, size_t len_w); - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_util.c r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_util.c --- r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_util.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_util.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -/* - * 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. - */ - -#include "w32_util.h" - -/** - * Creates a FindFirstFile(Ex) filter string from a UTF-8 path. - * The filter string enumerates all items in the directory. - * - * @param dest The buffer to receive the filter string. - * @param src The UTF-8 path of the directory to enumerate. - * @return True if the filter string was created successfully; false otherwise - */ -bool git_win32__findfirstfile_filter(git_win32_path dest, const char *src) -{ - static const wchar_t suffix[] = L"\\*"; - int len = git_win32_path_from_utf8(dest, src); - - /* Ensure the path was converted */ - if (len < 0) - return false; - - /* Ensure that the path does not end with a trailing slash, - * because we're about to add one. Don't rely our trim_end - * helper, because we want to remove the backslash even for - * drive letter paths, in this case. */ - if (len > 0 && - (dest[len - 1] == L'/' || dest[len - 1] == L'\\')) { - dest[len - 1] = L'\0'; - len--; - } - - /* Ensure we have enough room to add the suffix */ - if ((size_t)len >= GIT_WIN_PATH_UTF16 - CONST_STRLEN(suffix)) - return false; - - wcscat(dest, suffix); - return true; -} - -/** - * Ensures the given path (file or folder) has the +H (hidden) attribute set. - * - * @param path The path which should receive the +H bit. - * @return 0 on success; -1 on failure - */ -int git_win32__set_hidden(const char *path, bool hidden) -{ - git_win32_path buf; - DWORD attrs, newattrs; - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - attrs = GetFileAttributesW(buf); - - /* Ensure the path exists */ - if (attrs == INVALID_FILE_ATTRIBUTES) - return -1; - - if (hidden) - newattrs = attrs | FILE_ATTRIBUTE_HIDDEN; - else - newattrs = attrs & ~FILE_ATTRIBUTE_HIDDEN; - - if (attrs != newattrs && !SetFileAttributesW(buf, newattrs)) { - giterr_set(GITERR_OS, "failed to %s hidden bit for '%s'", - hidden ? "set" : "unset", path); - return -1; - } - - return 0; -} - -int git_win32__hidden(bool *out, const char *path) -{ - git_win32_path buf; - DWORD attrs; - - if (git_win32_path_from_utf8(buf, path) < 0) - return -1; - - attrs = GetFileAttributesW(buf); - - /* Ensure the path exists */ - if (attrs == INVALID_FILE_ATTRIBUTES) - return -1; - - *out = (attrs & FILE_ATTRIBUTE_HIDDEN) ? true : false; - return 0; -} - -/** - * Removes any trailing backslashes from a path, except in the case of a drive - * letter path (C:\, D:\, etc.). This function cannot fail. - * - * @param path The path which should be trimmed. - * @return The length of the modified string (<= the input length) - */ -size_t git_win32__path_trim_end(wchar_t *str, size_t len) -{ - while (1) { - if (!len || str[len - 1] != L'\\') - break; - - /* Don't trim backslashes from drive letter paths, which - * are 3 characters long and of the form C:\, D:\, etc. */ - if (len == 3 && git_win32__isalpha(str[0]) && str[1] == ':') - break; - - len--; - } - - str[len] = L'\0'; - - return len; -} - -/** - * Removes any of the following namespace prefixes from a path, - * if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail. - * - * @param path The path which should be converted. - * @return The length of the modified string (<= the input length) - */ -size_t git_win32__canonicalize_path(wchar_t *str, size_t len) -{ - static const wchar_t dosdevices_prefix[] = L"\\\?\?\\"; - static const wchar_t nt_prefix[] = L"\\\\?\\"; - static const wchar_t unc_prefix[] = L"UNC\\"; - size_t to_advance = 0; - - /* "\??\" -- DOS Devices prefix */ - if (len >= CONST_STRLEN(dosdevices_prefix) && - !wcsncmp(str, dosdevices_prefix, CONST_STRLEN(dosdevices_prefix))) { - to_advance += CONST_STRLEN(dosdevices_prefix); - len -= CONST_STRLEN(dosdevices_prefix); - } - /* "\\?\" -- NT namespace prefix */ - else if (len >= CONST_STRLEN(nt_prefix) && - !wcsncmp(str, nt_prefix, CONST_STRLEN(nt_prefix))) { - to_advance += CONST_STRLEN(nt_prefix); - len -= CONST_STRLEN(nt_prefix); - } - - /* "\??\UNC\", "\\?\UNC\" -- UNC prefix */ - if (to_advance && len >= CONST_STRLEN(unc_prefix) && - !wcsncmp(str + to_advance, unc_prefix, CONST_STRLEN(unc_prefix))) { - to_advance += CONST_STRLEN(unc_prefix); - len -= CONST_STRLEN(unc_prefix); - } - - if (to_advance) { - memmove(str, str + to_advance, len * sizeof(wchar_t)); - str[len] = L'\0'; - } - - return git_win32__path_trim_end(str, len); -} diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_util.h r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_util.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/w32_util.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/w32_util.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -/* - * 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_w32_util_h__ -#define INCLUDE_w32_util_h__ - -#include "utf-conv.h" -#include "posix.h" -#include "path_w32.h" - -/* - -#include "common.h" -#include "path.h" -#include "path_w32.h" -#include "utf-conv.h" -#include "posix.h" -#include "reparse.h" -#include "dir.h" -*/ - - -GIT_INLINE(bool) git_win32__isalpha(wchar_t c) -{ - return ((c >= L'A' && c <= L'Z') || (c >= L'a' && c <= L'z')); -} - -/** - * Creates a FindFirstFile(Ex) filter string from a UTF-8 path. - * The filter string enumerates all items in the directory. - * - * @param dest The buffer to receive the filter string. - * @param src The UTF-8 path of the directory to enumerate. - * @return True if the filter string was created successfully; false otherwise - */ -bool git_win32__findfirstfile_filter(git_win32_path dest, const char *src); - -/** - * Ensures the given path (file or folder) has the +H (hidden) attribute set - * or unset. - * - * @param path The path that should receive the +H bit. - * @param hidden true to set +H, false to unset it - * @return 0 on success; -1 on failure - */ -extern int git_win32__set_hidden(const char *path, bool hidden); - -/** - * Determines if the given file or folder has the hidden attribute set. - * @param hidden pointer to store hidden value - * @param path The path that should be queried for hiddenness. - * @return 0 on success or an error code. - */ -extern int git_win32__hidden(bool *hidden, const char *path); - -/** - * Removes any trailing backslashes from a path, except in the case of a drive - * letter path (C:\, D:\, etc.). This function cannot fail. - * - * @param path The path which should be trimmed. - * @return The length of the modified string (<= the input length) - */ -size_t git_win32__path_trim_end(wchar_t *str, size_t len); - -/** - * Removes any of the following namespace prefixes from a path, - * if found: "\??\", "\\?\", "\\?\UNC\". This function cannot fail. - * - * @param path The path which should be converted. - * @return The length of the modified string (<= the input length) - */ -size_t git_win32__canonicalize_path(wchar_t *str, size_t len); - -/** - * Converts a FILETIME structure to a struct timespec. - * - * @param FILETIME A pointer to a FILETIME - * @param ts A pointer to the timespec structure to fill in - */ -GIT_INLINE(void) git_win32__filetime_to_timespec( - const FILETIME *ft, - struct timespec *ts) -{ - long long winTime = ((long long)ft->dwHighDateTime << 32) + ft->dwLowDateTime; - winTime -= 116444736000000000LL; /* Windows to Unix Epoch conversion */ - ts->tv_sec = (time_t)(winTime / 10000000); -#ifdef GIT_USE_NSEC - ts->tv_nsec = (winTime % 10000000) * 100; -#else - ts->tv_nsec = 0; -#endif -} - -GIT_INLINE(void) git_win32__timeval_to_filetime( - FILETIME *ft, const struct p_timeval tv) -{ - long long ticks = (tv.tv_sec * 10000000LL) + - (tv.tv_usec * 10LL) + 116444736000000000LL; - - ft->dwHighDateTime = ((ticks >> 32) & 0xffffffffLL); - ft->dwLowDateTime = (ticks & 0xffffffffLL); -} - -GIT_INLINE(void) git_win32__stat_init( - struct stat *st, - DWORD dwFileAttributes, - DWORD nFileSizeHigh, - DWORD nFileSizeLow, - FILETIME ftCreationTime, - FILETIME ftLastAccessTime, - FILETIME ftLastWriteTime) -{ - mode_t mode = S_IREAD; - - memset(st, 0, sizeof(struct stat)); - - if (dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - mode |= S_IFDIR; - else - mode |= S_IFREG; - - if ((dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0) - mode |= S_IWRITE; - - st->st_ino = 0; - st->st_gid = 0; - st->st_uid = 0; - st->st_nlink = 1; - st->st_mode = mode; - st->st_size = ((git_off_t)nFileSizeHigh << 32) + nFileSizeLow; - st->st_dev = _getdrive() - 1; - st->st_rdev = st->st_dev; - git_win32__filetime_to_timespec(&ftLastAccessTime, &(st->st_atim)); - git_win32__filetime_to_timespec(&ftLastWriteTime, &(st->st_mtim)); - git_win32__filetime_to_timespec(&ftCreationTime, &(st->st_ctim)); -} - -GIT_INLINE(void) git_win32__file_information_to_stat( - struct stat *st, - const BY_HANDLE_FILE_INFORMATION *fileinfo) -{ - git_win32__stat_init(st, - fileinfo->dwFileAttributes, - fileinfo->nFileSizeHigh, - fileinfo->nFileSizeLow, - fileinfo->ftCreationTime, - fileinfo->ftLastAccessTime, - fileinfo->ftLastWriteTime); -} - -GIT_INLINE(int) git_win32__file_attribute_to_stat( - struct stat *st, - const WIN32_FILE_ATTRIBUTE_DATA *attrdata, - const wchar_t *path) -{ - git_win32__stat_init(st, - attrdata->dwFileAttributes, - attrdata->nFileSizeHigh, - attrdata->nFileSizeLow, - attrdata->ftCreationTime, - attrdata->ftLastAccessTime, - attrdata->ftLastWriteTime); - - if (attrdata->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && path) { - git_win32_path target; - - if (git_win32_path_readlink_w(target, path) >= 0) { - st->st_mode = (st->st_mode & ~S_IFMT) | S_IFLNK; - - /* st_size gets the UTF-8 length of the target name, in bytes, - * not counting the NULL terminator */ - if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) { - giterr_set(GITERR_OS, "could not convert reparse point name for '%ls'", path); - return -1; - } - } - } - - return 0; -} - -#endif diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/win32/win32-compat.h r-cran-git2r-0.22.1/src/libgit2/src/win32/win32-compat.h --- r-cran-git2r-0.21.0/src/libgit2/src/win32/win32-compat.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/win32/win32-compat.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* - * 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_win32_compat__ -#define INCLUDE_win32_compat__ - -#include -#include -#include -#include -#include - -typedef long suseconds_t; - -struct p_timeval { - time_t tv_sec; - suseconds_t tv_usec; -}; - -struct p_timespec { - time_t tv_sec; - long tv_nsec; -}; - -#define timespec p_timespec - -struct p_stat { - _dev_t st_dev; - _ino_t st_ino; - mode_t st_mode; - short st_nlink; - short st_uid; - short st_gid; - _dev_t st_rdev; - __int64 st_size; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; -#define st_atime st_atim.tv_sec -#define st_mtime st_mtim.tv_sec -#define st_ctime st_ctim.tv_sec -#define st_atime_nsec st_atim.tv_nsec -#define st_mtime_nsec st_mtim.tv_nsec -#define st_ctime_nsec st_ctim.tv_nsec -}; - -#define stat p_stat - -#endif /* INCLUDE_win32_compat__ */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/worktree.c r-cran-git2r-0.22.1/src/libgit2/src/worktree.c --- r-cran-git2r-0.21.0/src/libgit2/src/worktree.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/worktree.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,14 +5,13 @@ * a Linking Exception. For full terms see the included COPYING file. */ -#include "common.h" +#include "worktree.h" #include "git2/branch.h" #include "git2/commit.h" #include "git2/worktree.h" #include "repository.h" -#include "worktree.h" static bool is_worktree_dir(const char *dir) { @@ -132,7 +131,7 @@ goto out; } - if ((wt = git__calloc(1, sizeof(struct git_repository))) == NULL) { + if ((wt = git__calloc(1, sizeof(*wt))) == NULL) { error = -1; goto out; } @@ -384,7 +383,7 @@ return err; } -int git_worktree_lock(git_worktree *wt, char *creason) +int git_worktree_lock(git_worktree *wt, const char *reason) { git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT; int err; @@ -397,8 +396,8 @@ if ((err = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0) goto out; - if (creason) - git_buf_attach_notowned(&buf, creason, strlen(creason)); + if (reason) + git_buf_attach_notowned(&buf, reason, strlen(reason)); if ((err = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0) goto out; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/worktree.h r-cran-git2r-0.22.1/src/libgit2/src/worktree.h --- r-cran-git2r-0.21.0/src/libgit2/src/worktree.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/worktree.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,6 +7,8 @@ #ifndef INCLUDE_worktree_h__ #define INCLUDE_worktree_h__ +#include "common.h" + #include "git2/common.h" #include "git2/worktree.h" diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xdiff.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xdiff.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xdiff.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xdiff.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,15 +13,13 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * */ -#include "../util.h" - #if !defined(XDIFF_H) #define XDIFF_H @@ -29,22 +27,29 @@ extern "C" { #endif /* #ifdef __cplusplus */ +/* xpparm_t.flags */ +#define XDF_NEED_MINIMAL (1 << 0) + +#define XDF_IGNORE_WHITESPACE (1 << 1) +#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 2) +#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 3) +#define XDF_IGNORE_CR_AT_EOL (1 << 4) +#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | \ + XDF_IGNORE_WHITESPACE_CHANGE | \ + XDF_IGNORE_WHITESPACE_AT_EOL | \ + XDF_IGNORE_CR_AT_EOL) -#define XDF_NEED_MINIMAL (1 << 1) -#define XDF_IGNORE_WHITESPACE (1 << 2) -#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 3) -#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 4) -#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE | XDF_IGNORE_WHITESPACE_AT_EOL) +#define XDF_IGNORE_BLANK_LINES (1 << 7) -#define XDF_PATIENCE_DIFF (1 << 5) -#define XDF_HISTOGRAM_DIFF (1 << 6) +#define XDF_PATIENCE_DIFF (1 << 14) +#define XDF_HISTOGRAM_DIFF (1 << 15) #define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF) #define XDF_DIFF_ALG(x) ((x) & XDF_DIFF_ALGORITHM_MASK) -#define XDF_IGNORE_BLANK_LINES (1 << 7) +#define XDF_INDENT_HEURISTIC (1 << 23) +/* xdemitconf_t.flags */ #define XDL_EMIT_FUNCNAMES (1 << 0) -#define XDL_EMIT_COMMON (1 << 1) #define XDL_EMIT_FUNCCONTEXT (1 << 2) #define XDL_MMB_READONLY (1 << 0) @@ -81,6 +86,10 @@ typedef struct s_xpparam { unsigned long flags; + + /* See Documentation/diff-options.txt. */ + char **anchors; + size_t anchors_nr; } xpparam_t; typedef struct s_xdemitcb { diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xdiffi.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xdiffi.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xdiffi.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xdiffi.c 2018-07-10 13:23:34.000000000 +0000 @@ -13,15 +13,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * */ #include "xinclude.h" -#include "common.h" #include "integer.h" @@ -31,7 +30,12 @@ #define XDL_SNAKE_CNT 20 #define XDL_K_HEUR 4 - +/** Declare a function as always inlined. */ +#if defined(_MSC_VER) +# define XDL_INLINE(type) static __inline type +#else +# define XDL_INLINE(type) static inline type +#endif typedef struct s_xdpsplit { long i1, i2; @@ -404,106 +408,544 @@ } -int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { - long ix, ixo, ixs, ixref, grpsiz, nrec = xdf->nrec; - char *rchg = xdf->rchg, *rchgo = xdfo->rchg; - xrecord_t **recs = xdf->recs; - - /* - * This is the same of what GNU diff does. Move back and forward - * change groups for a consistent and pretty diff output. This also - * helps in finding joinable change groups and reduce the diff size. - */ - for (ix = ixo = 0;;) { - /* - * Find the first changed line in the to-be-compacted file. - * We need to keep track of both indexes, so if we find a - * changed lines group on the other file, while scanning the - * to-be-compacted file, we need to skip it properly. Note - * that loops that are testing for changed lines on rchg* do - * not need index bounding since the array is prepared with - * a zero at position -1 and N. - */ - for (; ix < nrec && !rchg[ix]; ix++) - while (rchgo[ixo++]); - if (ix == nrec) +static int recs_match(xrecord_t *rec1, xrecord_t *rec2, long flags) +{ + return (rec1->ha == rec2->ha && + xdl_recmatch(rec1->ptr, rec1->size, + rec2->ptr, rec2->size, + flags)); +} + +/* + * If a line is indented more than this, get_indent() just returns this value. + * This avoids having to do absurd amounts of work for data that are not + * human-readable text, and also ensures that the output of get_indent fits within + * an int. + */ +#define MAX_INDENT 200 + +/* + * Return the amount of indentation of the specified line, treating TAB as 8 + * columns. Return -1 if line is empty or contains only whitespace. Clamp the + * output value at MAX_INDENT. + */ +static int get_indent(xrecord_t *rec) +{ + long i; + int ret = 0; + + for (i = 0; i < rec->size; i++) { + char c = rec->ptr[i]; + + if (!XDL_ISSPACE(c)) + return ret; + else if (c == ' ') + ret += 1; + else if (c == '\t') + ret += 8 - ret % 8; + /* ignore other whitespace characters */ + + if (ret >= MAX_INDENT) + return MAX_INDENT; + } + + /* The line contains only whitespace. */ + return -1; +} + +/* + * If more than this number of consecutive blank rows are found, just return this + * value. This avoids requiring O(N^2) work for pathological cases, and also + * ensures that the output of score_split fits in an int. + */ +#define MAX_BLANKS 20 + +/* Characteristics measured about a hypothetical split position. */ +struct split_measurement { + /* + * Is the split at the end of the file (aside from any blank lines)? + */ + int end_of_file; + + /* + * How much is the line immediately following the split indented (or -1 if + * the line is blank): + */ + int indent; + + /* + * How many consecutive lines above the split are blank? + */ + int pre_blank; + + /* + * How much is the nearest non-blank line above the split indented (or -1 + * if there is no such line)? + */ + int pre_indent; + + /* + * How many lines after the line following the split are blank? + */ + int post_blank; + + /* + * How much is the nearest non-blank line after the line following the + * split indented (or -1 if there is no such line)? + */ + int post_indent; +}; + +struct split_score { + /* The effective indent of this split (smaller is preferred). */ + int effective_indent; + + /* Penalty for this split (smaller is preferred). */ + int penalty; +}; + +/* + * Fill m with information about a hypothetical split of xdf above line split. + */ +static void measure_split(const xdfile_t *xdf, long split, + struct split_measurement *m) +{ + long i; + + if (split >= xdf->nrec) { + m->end_of_file = 1; + m->indent = -1; + } else { + m->end_of_file = 0; + m->indent = get_indent(xdf->recs[split]); + } + + m->pre_blank = 0; + m->pre_indent = -1; + for (i = split - 1; i >= 0; i--) { + m->pre_indent = get_indent(xdf->recs[i]); + if (m->pre_indent != -1) + break; + m->pre_blank += 1; + if (m->pre_blank == MAX_BLANKS) { + m->pre_indent = 0; break; + } + } + m->post_blank = 0; + m->post_indent = -1; + for (i = split + 1; i < xdf->nrec; i++) { + m->post_indent = get_indent(xdf->recs[i]); + if (m->post_indent != -1) + break; + m->post_blank += 1; + if (m->post_blank == MAX_BLANKS) { + m->post_indent = 0; + break; + } + } +} + +/* + * The empirically-determined weight factors used by score_split() below. + * Larger values means that the position is a less favorable place to split. + * + * Note that scores are only ever compared against each other, so multiplying + * all of these weight/penalty values by the same factor wouldn't change the + * heuristic's behavior. Still, we need to set that arbitrary scale *somehow*. + * In practice, these numbers are chosen to be large enough that they can be + * adjusted relative to each other with sufficient precision despite using + * integer math. + */ + +/* Penalty if there are no non-blank lines before the split */ +#define START_OF_FILE_PENALTY 1 + +/* Penalty if there are no non-blank lines after the split */ +#define END_OF_FILE_PENALTY 21 + +/* Multiplier for the number of blank lines around the split */ +#define TOTAL_BLANK_WEIGHT (-30) + +/* Multiplier for the number of blank lines after the split */ +#define POST_BLANK_WEIGHT 6 + +/* + * Penalties applied if the line is indented more than its predecessor + */ +#define RELATIVE_INDENT_PENALTY (-4) +#define RELATIVE_INDENT_WITH_BLANK_PENALTY 10 + +/* + * Penalties applied if the line is indented less than both its predecessor and + * its successor + */ +#define RELATIVE_OUTDENT_PENALTY 24 +#define RELATIVE_OUTDENT_WITH_BLANK_PENALTY 17 + +/* + * Penalties applied if the line is indented less than its predecessor but not + * less than its successor + */ +#define RELATIVE_DEDENT_PENALTY 23 +#define RELATIVE_DEDENT_WITH_BLANK_PENALTY 17 + +/* + * We only consider whether the sum of the effective indents for splits are + * less than (-1), equal to (0), or greater than (+1) each other. The resulting + * value is multiplied by the following weight and combined with the penalty to + * determine the better of two scores. + */ +#define INDENT_WEIGHT 60 + +/* + * Compute a badness score for the hypothetical split whose measurements are + * stored in m. The weight factors were determined empirically using the tools and + * corpus described in + * + * https://github.com/mhagger/diff-slider-tools + * + * Also see that project if you want to improve the weights based on, for example, + * a larger or more diverse corpus. + */ +static void score_add_split(const struct split_measurement *m, struct split_score *s) +{ + /* + * A place to accumulate penalty factors (positive makes this index more + * favored): + */ + int post_blank, total_blank, indent, any_blanks; + + if (m->pre_indent == -1 && m->pre_blank == 0) + s->penalty += START_OF_FILE_PENALTY; + + if (m->end_of_file) + s->penalty += END_OF_FILE_PENALTY; + + /* + * Set post_blank to the number of blank lines following the split, + * including the line immediately after the split: + */ + post_blank = (m->indent == -1) ? 1 + m->post_blank : 0; + total_blank = m->pre_blank + post_blank; + + /* Penalties based on nearby blank lines: */ + s->penalty += TOTAL_BLANK_WEIGHT * total_blank; + s->penalty += POST_BLANK_WEIGHT * post_blank; + + if (m->indent != -1) + indent = m->indent; + else + indent = m->post_indent; + + any_blanks = (total_blank != 0); + + /* Note that the effective indent is -1 at the end of the file: */ + s->effective_indent += indent; + + if (indent == -1) { + /* No additional adjustments needed. */ + } else if (m->pre_indent == -1) { + /* No additional adjustments needed. */ + } else if (indent > m->pre_indent) { + /* + * The line is indented more than its predecessor. + */ + s->penalty += any_blanks ? + RELATIVE_INDENT_WITH_BLANK_PENALTY : + RELATIVE_INDENT_PENALTY; + } else if (indent == m->pre_indent) { + /* + * The line has the same indentation level as its predecessor. + * No additional adjustments needed. + */ + } else { /* - * Record the start of a changed-group in the to-be-compacted file - * and find the end of it, on both to-be-compacted and other file - * indexes (ix and ixo). - */ - ixs = ix; - for (ix++; rchg[ix]; ix++); - for (; rchgo[ixo]; ixo++); + * The line is indented less than its predecessor. It could be + * the block terminator of the previous block, but it could + * also be the start of a new block (e.g., an "else" block, or + * maybe the previous block didn't have a block terminator). + * Try to distinguish those cases based on what comes next: + */ + if (m->post_indent != -1 && m->post_indent > indent) { + /* + * The following line is indented more. So it is likely + * that this line is the start of a block. + */ + s->penalty += any_blanks ? + RELATIVE_OUTDENT_WITH_BLANK_PENALTY : + RELATIVE_OUTDENT_PENALTY; + } else { + /* + * That was probably the end of a block. + */ + s->penalty += any_blanks ? + RELATIVE_DEDENT_WITH_BLANK_PENALTY : + RELATIVE_DEDENT_PENALTY; + } + } +} + +static int score_cmp(struct split_score *s1, struct split_score *s2) +{ + /* -1 if s1.effective_indent < s2->effective_indent, etc. */ + int cmp_indents = ((s1->effective_indent > s2->effective_indent) - + (s1->effective_indent < s2->effective_indent)); + + return INDENT_WEIGHT * cmp_indents + (s1->penalty - s2->penalty); +} + +/* + * Represent a group of changed lines in an xdfile_t (i.e., a contiguous group + * of lines that was inserted or deleted from the corresponding version of the + * file). We consider there to be such a group at the beginning of the file, at + * the end of the file, and between any two unchanged lines, though most such + * groups will usually be empty. + * + * If the first line in a group is equal to the line following the group, then + * the group can be slid down. Similarly, if the last line in a group is equal + * to the line preceding the group, then the group can be slid up. See + * group_slide_down() and group_slide_up(). + * + * Note that loops that are testing for changed lines in xdf->rchg do not need + * index bounding since the array is prepared with a zero at position -1 and N. + */ +struct xdlgroup { + /* + * The index of the first changed line in the group, or the index of + * the unchanged line above which the (empty) group is located. + */ + long start; + + /* + * The index of the first unchanged line after the group. For an empty + * group, end is equal to start. + */ + long end; +}; + +/* + * Initialize g to point at the first group in xdf. + */ +static void group_init(xdfile_t *xdf, struct xdlgroup *g) +{ + g->start = g->end = 0; + while (xdf->rchg[g->end]) + g->end++; +} + +/* + * Move g to describe the next (possibly empty) group in xdf and return 0. If g + * is already at the end of the file, do nothing and return -1. + */ +XDL_INLINE(int) group_next(xdfile_t *xdf, struct xdlgroup *g) +{ + if (g->end == xdf->nrec) + return -1; + + g->start = g->end + 1; + for (g->end = g->start; xdf->rchg[g->end]; g->end++) + ; + + return 0; +} + +/* + * Move g to describe the previous (possibly empty) group in xdf and return 0. + * If g is already at the beginning of the file, do nothing and return -1. + */ +XDL_INLINE(int) group_previous(xdfile_t *xdf, struct xdlgroup *g) +{ + if (g->start == 0) + return -1; + + g->end = g->start - 1; + for (g->start = g->end; xdf->rchg[g->start - 1]; g->start--) + ; + + return 0; +} + +/* + * If g can be slid toward the end of the file, do so, and if it bumps into a + * following group, expand this group to include it. Return 0 on success or -1 + * if g cannot be slid down. + */ +static int group_slide_down(xdfile_t *xdf, struct xdlgroup *g, long flags) +{ + if (g->end < xdf->nrec && + recs_match(xdf->recs[g->start], xdf->recs[g->end], flags)) { + xdf->rchg[g->start++] = 0; + xdf->rchg[g->end++] = 1; + while (xdf->rchg[g->end]) + g->end++; + + return 0; + } else { + return -1; + } +} + +/* + * If g can be slid toward the beginning of the file, do so, and if it bumps + * into a previous group, expand this group to include it. Return 0 on success + * or -1 if g cannot be slid up. + */ +static int group_slide_up(xdfile_t *xdf, struct xdlgroup *g, long flags) +{ + if (g->start > 0 && + recs_match(xdf->recs[g->start - 1], xdf->recs[g->end - 1], flags)) { + xdf->rchg[--g->start] = 1; + xdf->rchg[--g->end] = 0; + + while (xdf->rchg[g->start - 1]) + g->start--; + + return 0; + } else { + return -1; + } +} + +static void xdl_bug(const char *msg) +{ + fprintf(stderr, "BUG: %s\n", msg); + exit(1); +} + +/* + * Move back and forward change groups for a consistent and pretty diff output. + * This also helps in finding joinable change groups and reducing the diff + * size. + */ +int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { + struct xdlgroup g, go; + long earliest_end, end_matching_other; + long groupsize; + + group_init(xdf, &g); + group_init(xdfo, &go); + + while (1) { + /* If the group is empty in the to-be-compacted file, skip it: */ + if (g.end == g.start) + goto next; + + /* + * Now shift the change up and then down as far as possible in + * each direction. If it bumps into any other changes, merge them. + */ do { - grpsiz = ix - ixs; + groupsize = g.end - g.start; /* - * If the line before the current change group, is equal to - * the last line of the current change group, shift backward - * the group. + * Keep track of the last "end" index that causes this + * group to align with a group of changed lines in the + * other file. -1 indicates that we haven't found such + * a match yet: */ - while (ixs > 0 && recs[ixs - 1]->ha == recs[ix - 1]->ha && - xdl_recmatch(recs[ixs - 1]->ptr, recs[ixs - 1]->size, recs[ix - 1]->ptr, recs[ix - 1]->size, flags)) { - rchg[--ixs] = 1; - rchg[--ix] = 0; - - /* - * This change might have joined two change groups, - * so we try to take this scenario in account by moving - * the start index accordingly (and so the other-file - * end-of-group index). - */ - for (; rchg[ixs - 1]; ixs--); - while (rchgo[--ixo]); - } + end_matching_other = -1; + + /* Shift the group backward as much as possible: */ + while (!group_slide_up(xdf, &g, flags)) + if (group_previous(xdfo, &go)) + xdl_bug("group sync broken sliding up"); /* - * Record the end-of-group position in case we are matched - * with a group of changes in the other file (that is, the - * change record before the end-of-group index in the other - * file is set). + * This is this highest that this group can be shifted. + * Record its end index: */ - ixref = rchgo[ixo - 1] ? ix: nrec; + earliest_end = g.end; + if (go.end > go.start) + end_matching_other = g.end; + + /* Now shift the group forward as far as possible: */ + while (1) { + if (group_slide_down(xdf, &g, flags)) + break; + if (group_next(xdfo, &go)) + xdl_bug("group sync broken sliding down"); + + if (go.end > go.start) + end_matching_other = g.end; + } + } while (groupsize != g.end - g.start); + + /* + * If the group can be shifted, then we can possibly use this + * freedom to produce a more intuitive diff. + * + * The group is currently shifted as far down as possible, so the + * heuristics below only have to handle upwards shifts. + */ + + if (g.end == earliest_end) { + /* no shifting was possible */ + } else if (end_matching_other != -1) { /* - * If the first line of the current change group, is equal to - * the line next of the current change group, shift forward - * the group. + * Move the possibly merged group of changes back to line + * up with the last group of changes from the other file + * that it can align with. */ - while (ix < nrec && recs[ixs]->ha == recs[ix]->ha && - xdl_recmatch(recs[ixs]->ptr, recs[ixs]->size, recs[ix]->ptr, recs[ix]->size, flags)) { - rchg[ixs++] = 0; - rchg[ix++] = 1; - - /* - * This change might have joined two change groups, - * so we try to take this scenario in account by moving - * the start index accordingly (and so the other-file - * end-of-group index). Keep tracking the reference - * index in case we are shifting together with a - * corresponding group of changes in the other file. - */ - for (; rchg[ix]; ix++); - while (rchgo[++ixo]) - ixref = ix; - } - } while (grpsiz != ix - ixs); - - /* - * Try to move back the possibly merged group of changes, to match - * the recorded position in the other file. - */ - while (ixref < ix) { - rchg[--ixs] = 1; - rchg[--ix] = 0; - while (rchgo[--ixo]); + while (go.end == go.start) { + if (group_slide_up(xdf, &g, flags)) + xdl_bug("match disappeared"); + if (group_previous(xdfo, &go)) + xdl_bug("group sync broken sliding to match"); + } + } else if (flags & XDF_INDENT_HEURISTIC) { + /* + * Indent heuristic: a group of pure add/delete lines + * implies two splits, one between the end of the "before" + * context and the start of the group, and another between + * the end of the group and the beginning of the "after" + * context. Some splits are aesthetically better and some + * are worse. We compute a badness "score" for each split, + * and add the scores for the two splits to define a + * "score" for each position that the group can be shifted + * to. Then we pick the shift with the lowest score. + */ + long shift, best_shift = -1; + struct split_score best_score; + + for (shift = earliest_end; shift <= g.end; shift++) { + struct split_measurement m; + struct split_score score = {0, 0}; + + measure_split(xdf, shift, &m); + score_add_split(&m, &score); + measure_split(xdf, shift - groupsize, &m); + score_add_split(&m, &score); + if (best_shift == -1 || + score_cmp(&score, &best_score) <= 0) { + best_score.effective_indent = score.effective_indent; + best_score.penalty = score.penalty; + best_shift = shift; + } + } + + while (g.end > best_shift) { + if (group_slide_up(xdf, &g, flags)) + xdl_bug("best shift unreached"); + if (group_previous(xdfo, &go)) + xdl_bug("group sync broken sliding to blank line"); + } } + + next: + /* Move past the just-processed group: */ + if (group_next(xdf, &g)) + break; + if (group_next(xdfo, &go)) + xdl_bug("group sync broken moving to next group"); } + if (!group_next(xdfo, &go)) + xdl_bug("group sync broken at end of file"); + return 0; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xdiffi.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xdiffi.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xdiffi.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xdiffi.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xemit.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xemit.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xemit.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xemit.c 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * @@ -22,15 +22,6 @@ #include "xinclude.h" - - - -static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec); -static int xdl_emit_record(xdfile_t *xdf, long ri, char const *pre, xdemitcb_t *ecb); - - - - static long xdl_get_rec(xdfile_t *xdf, long ri, char const **rec) { *rec = xdf->recs[ri]->ptr; @@ -110,7 +101,7 @@ if (len > 0 && (isalpha((unsigned char)*rec) || /* identifier? */ - *rec == '_' || /* also identifier? */ + *rec == '_' || /* also identifier? */ *rec == '$')) { /* identifiers from VMS and other esoterico */ if (len > sz) len = sz; @@ -122,22 +113,20 @@ return -1; } -static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, - xdemitconf_t const *xecfg) { - xdfile_t *xdf = &xe->xdf2; - const char *rchg = xdf->rchg; - long ix; - - (void)xscr; - (void)xecfg; - - for (ix = 0; ix < xdf->nrec; ix++) { - if (rchg[ix]) - continue; - if (xdl_emit_record(xdf, ix, "", ecb)) - return -1; - } - return 0; +static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri, + char *buf, long sz) +{ + const char *rec; + long len = xdl_get_rec(xdf, ri, &rec); + if (!xecfg->find_func) + return def_ff(rec, len, buf, sz, xecfg->find_func_priv); + return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv); +} + +static int is_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri) +{ + char dummy[1]; + return match_func_rec(xdf, xecfg, ri, dummy, sizeof(dummy)) >= 0; } struct func_line { @@ -148,7 +137,6 @@ static long get_func_line(xdfenv_t *xe, xdemitconf_t const *xecfg, struct func_line *func_line, long start, long limit) { - find_func_t ff = xecfg->find_func ? xecfg->find_func : def_ff; long l, size, step = (start > limit) ? -1 : 1; char *buf, dummy[1]; @@ -156,9 +144,7 @@ size = func_line ? sizeof(func_line->buf) : sizeof(dummy); for (l = start; l != limit && 0 <= l && l < xe->xdf1.nrec; l += step) { - const char *rec; - long reclen = xdl_get_rec(&xe->xdf1, l, &rec); - long len = ff(rec, reclen, buf, size, xecfg->find_func_priv); + long len = match_func_rec(&xe->xdf1, xecfg, l, buf, size); if (len >= 0) { if (func_line) func_line->len = len; @@ -168,6 +154,18 @@ return -1; } +static int is_empty_rec(xdfile_t *xdf, long ri) +{ + const char *rec; + long len = xdl_get_rec(xdf, ri, &rec); + + while (len > 0 && XDL_ISSPACE(*rec)) { + rec++; + len--; + } + return !len; +} + int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { long s1, s2, e1, e2, lctx; @@ -175,9 +173,6 @@ long funclineprev = -1; struct func_line func_line = { 0 }; - if (xecfg->flags & XDL_EMIT_COMMON) - return xdl_emit_common(xe, xscr, ecb, xecfg); - for (xch = xscr; xch; xch = xche->next) { xche = xdl_get_hunk(&xch, xecfg); if (!xch) @@ -187,7 +182,33 @@ s2 = XDL_MAX(xch->i2 - xecfg->ctxlen, 0); if (xecfg->flags & XDL_EMIT_FUNCCONTEXT) { - long fs1 = get_func_line(xe, xecfg, NULL, xch->i1, -1); + long fs1, i1 = xch->i1; + + /* Appended chunk? */ + if (i1 >= xe->xdf1.nrec) { + long i2 = xch->i2; + + /* + * We don't need additional context if + * a whole function was added. + */ + while (i2 < xe->xdf2.nrec) { + if (is_func_rec(&xe->xdf2, xecfg, i2)) + goto post_context_calculation; + i2++; + } + + /* + * Otherwise get more context from the + * pre-image. + */ + i1 = xe->xdf1.nrec - 1; + } + + fs1 = get_func_line(xe, xecfg, NULL, i1, -1); + while (fs1 > 0 && !is_empty_rec(&xe->xdf1, fs1 - 1) && + !is_func_rec(&xe->xdf1, xecfg, fs1 - 1)) + fs1--; if (fs1 < 0) fs1 = 0; if (fs1 < s1) { @@ -196,7 +217,7 @@ } } - again: + post_context_calculation: lctx = xecfg->ctxlen; lctx = XDL_MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1)); lctx = XDL_MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2)); @@ -208,6 +229,8 @@ long fe1 = get_func_line(xe, xecfg, NULL, xche->i1 + xche->chg1, xe->xdf1.nrec); + while (fe1 > 0 && is_empty_rec(&xe->xdf1, fe1 - 1)) + fe1--; if (fe1 < 0) fe1 = xe->xdf1.nrec; if (fe1 > e1) { @@ -221,11 +244,12 @@ * its new end. */ if (xche->next) { - long l = xche->next->i1; - if (l <= e1 || + long l = XDL_MIN(xche->next->i1, + xe->xdf1.nrec - 1); + if (l - xecfg->ctxlen <= e1 || get_func_line(xe, xecfg, NULL, l, e1) < 0) { xche = xche->next; - goto again; + goto post_context_calculation; } } } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xemit.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xemit.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xemit.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xemit.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xhistogram.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xhistogram.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xhistogram.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xhistogram.c 2018-07-10 13:23:34.000000000 +0000 @@ -44,7 +44,6 @@ #include "xinclude.h" #include "xtypes.h" #include "xdiff.h" -#include "common.h" #define MAX_PTR UINT_MAX #define MAX_CNT UINT_MAX diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xinclude.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xinclude.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xinclude.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xinclude.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * @@ -42,5 +42,6 @@ #include "xdiffi.h" #include "xemit.h" +#include "common.h" #endif /* #if !defined(XINCLUDE_H) */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xmacros.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xmacros.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xmacros.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xmacros.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xmerge.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xmerge.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xmerge.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xmerge.c 2018-07-10 13:23:34.000000000 +0000 @@ -13,15 +13,14 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * */ #include "xinclude.h" -#include "common.h" typedef struct s_xdmerge { struct s_xdmerge *next; @@ -110,7 +109,7 @@ return 0; } -static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int add_nl, char *dest) +static int xdl_recs_copy_0(size_t *out, int use_orig, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest) { xrecord_t **recs; size_t size = 0; @@ -132,6 +131,12 @@ if (add_nl) { i = recs[count - 1]->size; if (i == 0 || recs[count - 1]->ptr[i - 1] != '\n') { + if (needs_cr) { + if (dest) + dest[size] = '\r'; + GITERR_CHECK_ALLOC_ADD(&size, size, 1); + } + if (dest) dest[size] = '\n'; @@ -143,14 +148,58 @@ return 0; } -static int xdl_recs_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest) +static int xdl_recs_copy(size_t *out, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest) +{ + return xdl_recs_copy_0(out, 0, xe, i, count, needs_cr, add_nl, dest); +} + +static int xdl_orig_copy(size_t *out, xdfenv_t *xe, int i, int count, int needs_cr, int add_nl, char *dest) +{ + return xdl_recs_copy_0(out, 1, xe, i, count, needs_cr, add_nl, dest); +} + +/* + * Returns 1 if the i'th line ends in CR/LF (if it is the last line and + * has no eol, the preceding line, if any), 0 if it ends in LF-only, and + * -1 if the line ending cannot be determined. + */ +static int is_eol_crlf(xdfile_t *file, int i) { - return xdl_recs_copy_0(out, 0, xe, i, count, add_nl, dest); + long size; + + if (i < file->nrec - 1) + /* All lines before the last *must* end in LF */ + return (size = file->recs[i]->size) > 1 && + file->recs[i]->ptr[size - 2] == '\r'; + if (!file->nrec) + /* Cannot determine eol style from empty file */ + return -1; + if ((size = file->recs[i]->size) && + file->recs[i]->ptr[size - 1] == '\n') + /* Last line; ends in LF; Is it CR/LF? */ + return size > 1 && + file->recs[i]->ptr[size - 2] == '\r'; + if (!i) + /* The only line has no eol */ + return -1; + /* Determine eol from second-to-last line */ + return (size = file->recs[i - 1]->size) > 1 && + file->recs[i - 1]->ptr[size - 2] == '\r'; } -static int xdl_orig_copy(size_t *out, xdfenv_t *xe, int i, int count, int add_nl, char *dest) +static int is_cr_needed(xdfenv_t *xe1, xdfenv_t *xe2, xdmerge_t *m) { - return xdl_recs_copy_0(out, 1, xe, i, count, add_nl, dest); + int needs_cr; + + /* Match post-images' preceding, or first, lines' end-of-line style */ + needs_cr = is_eol_crlf(&xe1->xdf2, m->i1 ? m->i1 - 1 : 0); + if (needs_cr) + needs_cr = is_eol_crlf(&xe2->xdf2, m->i2 ? m->i2 - 1 : 0); + /* Look at pre-image's first line, unless we already settled on LF */ + if (needs_cr) + needs_cr = is_eol_crlf(&xe1->xdf1, 0); + /* If still undecided, use LF-only */ + return needs_cr < 0 ? 0 : needs_cr; } static int fill_conflict_hunk(size_t *out, xdfenv_t *xe1, const char *name1, @@ -162,6 +211,7 @@ int marker1_size = (name1 ? (int)strlen(name1) + 1 : 0); int marker2_size = (name2 ? (int)strlen(name2) + 1 : 0); int marker3_size = (name3 ? (int)strlen(name3) + 1 : 0); + int needs_cr = is_cr_needed(xe1, xe2, m); size_t copied; *out = 0; @@ -170,14 +220,14 @@ marker_size = DEFAULT_CONFLICT_MARKER_SIZE; /* Before conflicting part */ - if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, + if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); if (!dest) { - GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker1_size); + GITERR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker1_size); } else { memset(dest + size, '<', marker_size); size += marker_size; @@ -186,11 +236,13 @@ memcpy(dest + size + 1, name1, marker1_size - 1); size += marker1_size; } + if (needs_cr) + dest[size++] = '\r'; dest[size++] = '\n'; } /* Postimage from side #1 */ - if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, 1, + if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, 1, dest ? dest + size : NULL) < 0) return -1; @@ -199,7 +251,7 @@ if (style == XDL_MERGE_DIFF3) { /* Shared preimage */ if (!dest) { - GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker3_size); + GITERR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker3_size); } else { memset(dest + size, '|', marker_size); size += marker_size; @@ -208,32 +260,36 @@ memcpy(dest + size + 1, name3, marker3_size - 1); size += marker3_size; } + if (needs_cr) + dest[size++] = '\r'; dest[size++] = '\n'; } - if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, 1, + if (xdl_orig_copy(&copied, xe1, m->i0, m->chg0, needs_cr, 1, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); } if (!dest) { - GITERR_CHECK_ALLOC_ADD3(&size, size, marker_size, 1); + GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, needs_cr); } else { memset(dest + size, '=', marker_size); size += marker_size; + if (needs_cr) + dest[size++] = '\r'; dest[size++] = '\n'; } /* Postimage from side #2 */ - if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 1, + if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, needs_cr, 1, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); if (!dest) { - GITERR_CHECK_ALLOC_ADD4(&size, size, marker_size, 1, marker2_size); + GITERR_CHECK_ALLOC_ADD5(&size, size, marker_size, 1, needs_cr, marker2_size); } else { memset(dest + size, '>', marker_size); size += marker_size; @@ -242,6 +298,8 @@ memcpy(dest + size + 1, name2, marker2_size - 1); size += marker2_size; } + if (needs_cr) + dest[size++] = '\r'; dest[size++] = '\n'; } @@ -275,14 +333,16 @@ } else if (m->mode & 3) { /* Before conflicting part */ - if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, + if (xdl_recs_copy(&copied, xe1, i, m->i1 - i, 0, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); /* Postimage from side #1 */ if (m->mode & 1) { - if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, (m->mode & 2), + int needs_cr = is_cr_needed(xe1, xe2, m); + + if (xdl_recs_copy(&copied, xe1, m->i1, m->chg1, needs_cr, (m->mode & 2), dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); @@ -290,7 +350,7 @@ /* Postimage from side #2 */ if (m->mode & 2) { - if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, + if (xdl_recs_copy(&copied, xe2, m->i2, m->chg2, 0, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); @@ -300,7 +360,7 @@ i = m->i1 + m->chg1; } - if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, + if (xdl_recs_copy(&copied, xe1, i, xe1->xdf2.nrec - i, 0, 0, dest ? dest + size : NULL) < 0) return -1; GITERR_CHECK_ALLOC_ADD(&size, size, copied); diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xpatience.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xpatience.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xpatience.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xpatience.c 2018-07-10 13:23:34.000000000 +0000 @@ -1,6 +1,6 @@ /* * LibXDiff by Davide Libenzi ( File Differential Library ) - * Copyright (C) 2003-2009 Davide Libenzi, Johannes E. Schindelin + * Copyright (C) 2003-2016 Davide Libenzi, Johannes E. Schindelin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * @@ -62,6 +62,12 @@ * initially, "next" reflects only the order in file1. */ struct entry *next, *previous; + + /* + * If 1, this entry can serve as an anchor. See + * Documentation/diff-options.txt for more information. + */ + unsigned anchor : 1; } *entries, *first, *last; /* were common records found? */ unsigned long has_matches; @@ -70,8 +76,19 @@ xpparam_t const *xpp; }; +static int is_anchor(xpparam_t const *xpp, const char *line) +{ + unsigned long i; + for (i = 0; i < xpp->anchors_nr; i++) { + if (!strncmp(line, xpp->anchors[i], strlen(xpp->anchors[i]))) + return 1; + } + return 0; +} + /* The argument "pass" is 1 for the first file, 2 for the second. */ -static void insert_record(int line, struct hashmap *map, int pass) +static void insert_record(xpparam_t const *xpp, int line, struct hashmap *map, + int pass) { xrecord_t **records = pass == 1 ? map->env->xdf1.recs : map->env->xdf2.recs; @@ -110,6 +127,7 @@ return; map->entries[index].line1 = line; map->entries[index].hash = record->ha; + map->entries[index].anchor = is_anchor(xpp, map->env->xdf1.recs[line - 1]->ptr); if (!map->first) map->first = map->entries + index; if (map->last) { @@ -147,11 +165,11 @@ /* First, fill with entries from the first file */ while (count1--) - insert_record(line1++, result, 1); + insert_record(xpp, line1++, result, 1); /* Then search for matches in the second file */ while (count2--) - insert_record(line2++, result, 2); + insert_record(xpp, line2++, result, 2); return 0; } @@ -166,7 +184,7 @@ int left = -1, right = longest; while (left + 1 < right) { - int middle = (left + right) / 2; + int middle = left + (right - left) / 2; /* by construction, no two entries can be equal */ if (sequence[middle]->line2 > entry->line2) right = middle; @@ -192,14 +210,28 @@ int longest = 0, i; struct entry *entry; + /* + * If not -1, this entry in sequence must never be overridden. + * Therefore, overriding entries before this has no effect, so + * do not do that either. + */ + int anchor_i = -1; + for (entry = map->first; entry; entry = entry->next) { if (!entry->line2 || entry->line2 == NON_UNIQUE) continue; i = binary_search(sequence, longest, entry); entry->previous = i < 0 ? NULL : sequence[i]; - sequence[++i] = entry; - if (i == longest) + ++i; + if (i <= anchor_i) + continue; + sequence[i] = entry; + if (entry->anchor) { + anchor_i = i; + longest = anchor_i + 1; + } else if (i == longest) { longest++; + } } /* No common unique lines were found */ diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xprepare.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xprepare.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xprepare.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xprepare.c 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xprepare.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xprepare.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xprepare.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xprepare.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xtypes.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xtypes.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xtypes.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xtypes.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xutils.c r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xutils.c --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xutils.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xutils.c 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * @@ -62,14 +62,14 @@ void *xdl_mmfile_first(mmfile_t *mmf, long *size) { - *size = (long)mmf->size; + *size = mmf->size; return mmf->ptr; } long xdl_mmfile_size(mmfile_t *mmf) { - return (long)mmf->size; + return mmf->size; } @@ -154,6 +154,24 @@ return (i == size); } +/* + * Have we eaten everything on the line, except for an optional + * CR at the very end? + */ +static int ends_with_optional_cr(const char *l, long s, long i) +{ + int complete = s && l[s-1] == '\n'; + + if (complete) + s--; + if (s == i) + return 1; + /* do not ignore CR at the end of an incomplete line */ + if (complete && s == i + 1 && l[i] == '\r') + return 1; + return 0; +} + int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) { int i1, i2; @@ -168,7 +186,8 @@ /* * -w matches everything that matches with -b, and -b in turn - * matches everything that matches with --ignore-space-at-eol. + * matches everything that matches with --ignore-space-at-eol, + * which in turn matches everything that matches with --ignore-cr-at-eol. * * Each flavor of ignoring needs different logic to skip whitespaces * while we have both sides to compare. @@ -198,8 +217,18 @@ return 0; } } else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL) { - while (i1 < s1 && i2 < s2 && l1[i1++] == l2[i2++]) - ; /* keep going */ + while (i1 < s1 && i2 < s2 && l1[i1] == l2[i2]) { + i1++; + i2++; + } + } else if (flags & XDF_IGNORE_CR_AT_EOL) { + /* Find the first difference and see how the line ends */ + while (i1 < s1 && i2 < s2 && l1[i1] == l2[i2]) { + i1++; + i2++; + } + return (ends_with_optional_cr(l1, s1, i1) && + ends_with_optional_cr(l2, s2, i2)); } /* @@ -226,9 +255,16 @@ char const *top, long flags) { unsigned long ha = 5381; char const *ptr = *data; + int cr_at_eol_only = (flags & XDF_WHITESPACE_FLAGS) == XDF_IGNORE_CR_AT_EOL; for (; ptr < top && *ptr != '\n'; ptr++) { - if (XDL_ISSPACE(*ptr)) { + if (cr_at_eol_only) { + /* do not ignore CR at the end of an incomplete line */ + if (*ptr == '\r' && + (ptr + 1 < top && ptr[1] == '\n')) + continue; + } + else if (XDL_ISSPACE(*ptr)) { const char *ptr2 = ptr; int at_eol; while (ptr + 1 < top && XDL_ISSPACE(ptr[1]) @@ -260,7 +296,6 @@ return ha; } - unsigned long xdl_hash_record(char const **data, char const *top, long flags) { unsigned long ha = 5381; char const *ptr = *data; @@ -277,7 +312,6 @@ return ha; } - unsigned int xdl_hashbits(unsigned int size) { unsigned int val = 1, bits = 0; @@ -305,23 +339,9 @@ *str++ = '0'; *str = '\0'; - return (int)(str - out); + return str - out; } - -long xdl_atol(char const *str, char const **next) { - long val, base; - char const *top; - - for (top = str; XDL_ISDIGIT(*top); top++); - if (next) - *next = top; - for (val = 0, base = 1, top--; top >= str; top--, base *= 10) - val += base * (long)(*top - '0'); - return val; -} - - int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, const char *func, long funclen, xdemitcb_t *ecb) { int nb = 0; @@ -356,8 +376,8 @@ nb += 3; if (func && funclen) { buf[nb++] = ' '; - if (funclen > (long)sizeof(buf) - nb - 1) - funclen = (long)sizeof(buf) - nb - 1; + if (funclen > (long)(sizeof(buf) - nb - 1)) + funclen = sizeof(buf) - nb - 1; memcpy(buf + nb, func, funclen); nb += funclen; } diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xutils.h r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xutils.h --- r-cran-git2r-0.21.0/src/libgit2/src/xdiff/xutils.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/xdiff/xutils.h 2018-07-10 13:23:34.000000000 +0000 @@ -13,8 +13,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see + * . * * Davide Libenzi * @@ -31,15 +31,12 @@ int xdl_cha_init(chastore_t *cha, long isize, long icount); void xdl_cha_free(chastore_t *cha); void *xdl_cha_alloc(chastore_t *cha); -void *xdl_cha_first(chastore_t *cha); -void *xdl_cha_next(chastore_t *cha); long xdl_guess_lines(mmfile_t *mf, long sample); int xdl_blankline(const char *line, long size, long flags); int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags); unsigned long xdl_hash_record(char const **data, char const *top, long flags); unsigned int xdl_hashbits(unsigned int size); int xdl_num_out(char *out, long val); -long xdl_atol(char const *str, char const **next); int xdl_emit_hunk_hdr(long s1, long c1, long s2, long c2, const char *func, long funclen, xdemitcb_t *ecb); int xdl_fall_back_diff(xdfenv_t *diff_env, xpparam_t const *xpp, diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/zstream.c r-cran-git2r-0.22.1/src/libgit2/src/zstream.c --- r-cran-git2r-0.21.0/src/libgit2/src/zstream.c 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/zstream.c 2018-07-10 13:23:34.000000000 +0000 @@ -5,25 +5,31 @@ * a Linking Exception. For full terms see the included COPYING file. */ +#include "zstream.h" + #include -#include "zstream.h" #include "buffer.h" #define ZSTREAM_BUFFER_SIZE (1024 * 1024) #define ZSTREAM_BUFFER_MIN_EXTRA 8 -static int zstream_seterr(git_zstream *zs) +GIT_INLINE(int) zstream_seterr(git_zstream *zs) { - if (zs->zerr == Z_OK || zs->zerr == Z_STREAM_END) + switch (zs->zerr) { + case Z_OK: + case Z_STREAM_END: + case Z_BUF_ERROR: /* not fatal; we retry with a larger buffer */ return 0; - - if (zs->zerr == Z_MEM_ERROR) + case Z_MEM_ERROR: giterr_set_oom(); - else if (zs->z.msg) - giterr_set_str(GITERR_ZLIB, zs->z.msg); - else - giterr_set(GITERR_ZLIB, "unknown compression error"); + break; + default: + if (zs->z.msg) + giterr_set_str(GITERR_ZLIB, zs->z.msg); + else + giterr_set(GITERR_ZLIB, "unknown compression error"); + } return -1; } @@ -81,9 +87,52 @@ return ZSTREAM_BUFFER_MIN_EXTRA; } +int git_zstream_get_output_chunk( + void *out, size_t *out_len, git_zstream *zstream) +{ + size_t in_queued, in_used, out_queued; + + /* set up input data */ + zstream->z.next_in = (Bytef *)zstream->in; + + /* feed as much data to zlib as it can consume, at most UINT_MAX */ + if (zstream->in_len > UINT_MAX) { + zstream->z.avail_in = UINT_MAX; + zstream->flush = Z_NO_FLUSH; + } else { + zstream->z.avail_in = (uInt)zstream->in_len; + zstream->flush = Z_FINISH; + } + in_queued = (size_t)zstream->z.avail_in; + + /* set up output data */ + zstream->z.next_out = out; + zstream->z.avail_out = (uInt)*out_len; + + if ((size_t)zstream->z.avail_out != *out_len) + zstream->z.avail_out = UINT_MAX; + out_queued = (size_t)zstream->z.avail_out; + + /* compress next chunk */ + if (zstream->type == GIT_ZSTREAM_INFLATE) + zstream->zerr = inflate(&zstream->z, zstream->flush); + else + zstream->zerr = deflate(&zstream->z, zstream->flush); + + if (zstream_seterr(zstream)) + return -1; + + in_used = (in_queued - zstream->z.avail_in); + zstream->in_len -= in_used; + zstream->in += in_used; + + *out_len = (out_queued - zstream->z.avail_out); + + return 0; +} + int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream) { - int zflush = Z_FINISH; size_t out_remain = *out_len; if (zstream->in_len && zstream->zerr == Z_STREAM_END) { @@ -92,46 +141,17 @@ } while (out_remain > 0 && zstream->zerr != Z_STREAM_END) { - size_t out_queued, in_queued, out_used, in_used; - - /* set up in data */ - zstream->z.next_in = (Bytef *)zstream->in; - zstream->z.avail_in = (uInt)zstream->in_len; - if ((size_t)zstream->z.avail_in != zstream->in_len) { - zstream->z.avail_in = INT_MAX; - zflush = Z_NO_FLUSH; - } else { - zflush = Z_FINISH; - } - in_queued = (size_t)zstream->z.avail_in; - - /* set up out data */ - zstream->z.next_out = out; - zstream->z.avail_out = (uInt)out_remain; - if ((size_t)zstream->z.avail_out != out_remain) - zstream->z.avail_out = INT_MAX; - out_queued = (size_t)zstream->z.avail_out; - - /* compress next chunk */ - if (zstream->type == GIT_ZSTREAM_INFLATE) - zstream->zerr = inflate(&zstream->z, zflush); - else - zstream->zerr = deflate(&zstream->z, zflush); + size_t out_written = out_remain; - if (zstream->zerr == Z_STREAM_ERROR) - return zstream_seterr(zstream); + if (git_zstream_get_output_chunk(out, &out_written, zstream) < 0) + return -1; - out_used = (out_queued - zstream->z.avail_out); - out_remain -= out_used; - out = ((char *)out) + out_used; - - in_used = (in_queued - zstream->z.avail_in); - zstream->in_len -= in_used; - zstream->in += in_used; + out_remain -= out_written; + out = ((char *)out) + out_written; } /* either we finished the input or we did not flush the data */ - assert(zstream->in_len > 0 || zflush == Z_FINISH); + assert(zstream->in_len > 0 || zstream->flush == Z_FINISH); /* set out_size to number of bytes actually written to output */ *out_len = *out_len - out_remain; diff -Nru r-cran-git2r-0.21.0/src/libgit2/src/zstream.h r-cran-git2r-0.22.1/src/libgit2/src/zstream.h --- r-cran-git2r-0.21.0/src/libgit2/src/zstream.h 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/libgit2/src/zstream.h 2018-07-10 13:23:34.000000000 +0000 @@ -7,9 +7,10 @@ #ifndef INCLUDE_zstream_h__ #define INCLUDE_zstream_h__ +#include "common.h" + #include -#include "common.h" #include "buffer.h" typedef enum { @@ -22,6 +23,7 @@ git_zstream_t type; const char *in; size_t in_len; + int flush; int zerr; } git_zstream; @@ -34,6 +36,11 @@ size_t git_zstream_suggest_output_len(git_zstream *zstream); +/* get as much output as is available in the input buffer */ +int git_zstream_get_output_chunk( + void *out, size_t *out_len, git_zstream *zstream); + +/* get all the output from the entire input buffer */ int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream); bool git_zstream_done(git_zstream *zstream); @@ -43,4 +50,4 @@ int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len); int git_zstream_inflatebuf(git_buf *out, const void *in, size_t in_len); -#endif /* INCLUDE_zstream_h__ */ +#endif diff -Nru r-cran-git2r-0.21.0/src/Makevars.in r-cran-git2r-0.22.1/src/Makevars.in --- r-cran-git2r-0.21.0/src/Makevars.in 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/Makevars.in 2018-07-10 13:23:34.000000000 +0000 @@ -1,71 +1,3 @@ -# Generated by scripts/build_Makevars.r: do not edit by hand - +PKG_CPPFLAGS = -DR_NO_REMAP -DSTRICT_R_HEADERS PKG_CFLAGS = @PKG_CFLAGS@ -PKG_CPPFLAGS = @PKG_CPPFLAGS@ -PKG_LIBS = -L. -lmygit @PKG_LIBS@ - -OBJECTS.libgit2 = libgit2/src/annotated_commit.o libgit2/src/apply.o libgit2/src/attr_file.o \ - libgit2/src/attr.o libgit2/src/attrcache.o libgit2/src/blame_git.o \ - libgit2/src/blame.o libgit2/src/blob.o libgit2/src/branch.o \ - libgit2/src/buf_text.o libgit2/src/buffer.o libgit2/src/cache.o \ - libgit2/src/checkout.o libgit2/src/cherrypick.o libgit2/src/clone.o \ - libgit2/src/commit_list.o libgit2/src/commit.o libgit2/src/config_cache.o \ - libgit2/src/config_file.o libgit2/src/config.o libgit2/src/crlf.o \ - libgit2/src/curl_stream.o libgit2/src/date.o libgit2/src/delta.o \ - libgit2/src/describe.o libgit2/src/diff_driver.o libgit2/src/diff_file.o \ - libgit2/src/diff_generate.o libgit2/src/diff_parse.o libgit2/src/diff_print.o \ - libgit2/src/diff_stats.o libgit2/src/diff_tform.o libgit2/src/diff_xdiff.o \ - libgit2/src/diff.o libgit2/src/errors.o libgit2/src/fetch.o \ - libgit2/src/fetchhead.o libgit2/src/filebuf.o libgit2/src/fileops.o \ - libgit2/src/filter.o libgit2/src/fnmatch.o libgit2/src/global.o \ - libgit2/src/graph.o libgit2/src/hash.o libgit2/src/hashsig.o \ - libgit2/src/ident.o libgit2/src/idxmap.o libgit2/src/ignore.o \ - libgit2/src/index.o libgit2/src/indexer.o libgit2/src/iterator.o \ - libgit2/src/merge_driver.o libgit2/src/merge_file.o libgit2/src/merge.o \ - libgit2/src/message.o libgit2/src/mwindow.o libgit2/src/netops.o \ - libgit2/src/notes.o libgit2/src/object_api.o libgit2/src/object.o \ - libgit2/src/odb_loose.o libgit2/src/odb_mempack.o libgit2/src/odb_pack.o \ - libgit2/src/odb.o libgit2/src/offmap.o libgit2/src/oid.o \ - libgit2/src/oidarray.o libgit2/src/oidmap.o libgit2/src/openssl_stream.o \ - libgit2/src/pack-objects.o libgit2/src/pack.o libgit2/src/patch_generate.o \ - libgit2/src/patch_parse.o libgit2/src/patch.o libgit2/src/path.o \ - libgit2/src/pathspec.o libgit2/src/pool.o libgit2/src/posix.o \ - libgit2/src/pqueue.o libgit2/src/proxy.o libgit2/src/push.o \ - libgit2/src/rebase.o libgit2/src/refdb_fs.o libgit2/src/refdb.o \ - libgit2/src/reflog.o libgit2/src/refs.o libgit2/src/refspec.o \ - libgit2/src/remote.o libgit2/src/repository.o libgit2/src/reset.o \ - libgit2/src/revert.o libgit2/src/revparse.o libgit2/src/revwalk.o \ - libgit2/src/settings.o libgit2/src/sha1_lookup.o libgit2/src/signature.o \ - libgit2/src/socket_stream.o libgit2/src/sortedcache.o libgit2/src/stash.o \ - libgit2/src/status.o libgit2/src/strmap.o libgit2/src/submodule.o \ - libgit2/src/sysdir.o libgit2/src/tag.o libgit2/src/thread-utils.o \ - libgit2/src/tls_stream.o libgit2/src/trace.o libgit2/src/transaction.o \ - libgit2/src/transport.o libgit2/src/tree-cache.o libgit2/src/tree.o \ - libgit2/src/tsort.o libgit2/src/util.o libgit2/src/varint.o \ - libgit2/src/vector.o libgit2/src/worktree.o libgit2/src/zstream.o - -OBJECTS.libgit2.transports = libgit2/src/transports/auth.o libgit2/src/transports/cred_helpers.o libgit2/src/transports/cred.o \ - libgit2/src/transports/git.o libgit2/src/transports/http.o libgit2/src/transports/local.o \ - libgit2/src/transports/smart_pkt.o libgit2/src/transports/smart_protocol.o libgit2/src/transports/smart.o \ - libgit2/src/transports/ssh.o - -OBJECTS.libgit2.unix = libgit2/src/unix/map.o libgit2/src/unix/realpath.o - -OBJECTS.libgit2.xdiff = libgit2/src/xdiff/xdiffi.o libgit2/src/xdiff/xemit.o libgit2/src/xdiff/xhistogram.o \ - libgit2/src/xdiff/xmerge.o libgit2/src/xdiff/xpatience.o libgit2/src/xdiff/xprepare.o \ - libgit2/src/xdiff/xutils.o - -OBJECTS.http_parser = libgit2/deps/http-parser/http_parser.o - -LIBGIT = $(OBJECTS.libgit2) $(OBJECTS.libgit2.transports) $(OBJECTS.libgit2.unix) \ - $(OBJECTS.libgit2.xdiff) $(OBJECTS.http_parser) @GIT2R_SRC_REGEX@ - -$(SHLIB): libmygit.a - -libmygit.a: $(LIBGIT) - $(AR) rcs libmygit.a $(LIBGIT) - -clean: - rm -f *.o libmygit.a git2r.so $(LIBGIT) - -.PHONY: all clean +PKG_LIBS = @PKG_LIBS@ diff -Nru r-cran-git2r-0.21.0/src/Makevars_libgit2.in r-cran-git2r-0.22.1/src/Makevars_libgit2.in --- r-cran-git2r-0.21.0/src/Makevars_libgit2.in 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/src/Makevars_libgit2.in 2018-07-01 21:27:09.000000000 +0000 @@ -0,0 +1,74 @@ +# Generated by scripts/build_Makevars.R: do not edit by hand + +PKG_CFLAGS = @PKG_CFLAGS@ +PKG_CPPFLAGS = @PKG_CPPFLAGS@ +PKG_LIBS = -L. -lmygit @PKG_LIBS@ + +OBJECTS.libgit2 = libgit2/src/annotated_commit.o libgit2/src/apply.o libgit2/src/attr_file.o \ + libgit2/src/attr.o libgit2/src/attrcache.o libgit2/src/blame_git.o \ + libgit2/src/blame.o libgit2/src/blob.o libgit2/src/branch.o \ + libgit2/src/buf_text.o libgit2/src/buffer.o libgit2/src/cache.o \ + libgit2/src/checkout.o libgit2/src/cherrypick.o libgit2/src/clone.o \ + libgit2/src/commit_list.o libgit2/src/commit.o libgit2/src/config_cache.o \ + libgit2/src/config_file.o libgit2/src/config_parse.o libgit2/src/config.o \ + libgit2/src/crlf.o libgit2/src/date.o libgit2/src/delta.o \ + libgit2/src/describe.o libgit2/src/diff_driver.o libgit2/src/diff_file.o \ + libgit2/src/diff_generate.o libgit2/src/diff_parse.o libgit2/src/diff_print.o \ + libgit2/src/diff_stats.o libgit2/src/diff_tform.o libgit2/src/diff_xdiff.o \ + libgit2/src/diff.o libgit2/src/errors.o libgit2/src/fetch.o \ + libgit2/src/fetchhead.o libgit2/src/filebuf.o libgit2/src/fileops.o \ + libgit2/src/filter.o libgit2/src/fnmatch.o libgit2/src/global.o \ + libgit2/src/graph.o libgit2/src/hash.o libgit2/src/hashsig.o \ + libgit2/src/ident.o libgit2/src/idxmap.o libgit2/src/ignore.o \ + libgit2/src/index.o libgit2/src/indexer.o libgit2/src/iterator.o \ + libgit2/src/merge_driver.o libgit2/src/merge_file.o libgit2/src/merge.o \ + libgit2/src/message.o libgit2/src/mwindow.o libgit2/src/netops.o \ + libgit2/src/notes.o libgit2/src/object_api.o libgit2/src/object.o \ + libgit2/src/odb_loose.o libgit2/src/odb_mempack.o libgit2/src/odb_pack.o \ + libgit2/src/odb.o libgit2/src/offmap.o libgit2/src/oid.o \ + libgit2/src/oidarray.o libgit2/src/oidmap.o libgit2/src/pack-objects.o \ + libgit2/src/pack.o libgit2/src/parse.o libgit2/src/patch_generate.o \ + libgit2/src/patch_parse.o libgit2/src/patch.o libgit2/src/path.o \ + libgit2/src/pathspec.o libgit2/src/pool.o libgit2/src/posix.o \ + libgit2/src/pqueue.o libgit2/src/proxy.o libgit2/src/push.o \ + libgit2/src/rebase.o libgit2/src/refdb_fs.o libgit2/src/refdb.o \ + libgit2/src/reflog.o libgit2/src/refs.o libgit2/src/refspec.o \ + libgit2/src/remote.o libgit2/src/repository.o libgit2/src/reset.o \ + libgit2/src/revert.o libgit2/src/revparse.o libgit2/src/revwalk.o \ + libgit2/src/settings.o libgit2/src/sha1_lookup.o libgit2/src/signature.o \ + libgit2/src/sortedcache.o libgit2/src/stash.o libgit2/src/status.o \ + libgit2/src/strmap.o libgit2/src/submodule.o libgit2/src/sysdir.o \ + libgit2/src/tag.o libgit2/src/thread-utils.o libgit2/src/trace.o \ + libgit2/src/trailer.o libgit2/src/transaction.o libgit2/src/transport.o \ + libgit2/src/tree-cache.o libgit2/src/tree.o libgit2/src/tsort.o \ + libgit2/src/util.o libgit2/src/varint.o libgit2/src/vector.o \ + libgit2/src/worktree.o libgit2/src/zstream.o + +OBJECTS.libgit2.streams = libgit2/src/streams/curl.o libgit2/src/streams/openssl.o libgit2/src/streams/socket.o \ + libgit2/src/streams/stransport.o libgit2/src/streams/tls.o + +OBJECTS.libgit2.transports = libgit2/src/transports/auth.o libgit2/src/transports/cred_helpers.o libgit2/src/transports/cred.o \ + libgit2/src/transports/git.o libgit2/src/transports/http.o libgit2/src/transports/local.o \ + libgit2/src/transports/smart_pkt.o libgit2/src/transports/smart_protocol.o libgit2/src/transports/smart.o \ + libgit2/src/transports/ssh.o + +OBJECTS.libgit2.unix = libgit2/src/unix/map.o libgit2/src/unix/realpath.o + +OBJECTS.libgit2.xdiff = libgit2/src/xdiff/xdiffi.o libgit2/src/xdiff/xemit.o libgit2/src/xdiff/xhistogram.o \ + libgit2/src/xdiff/xmerge.o libgit2/src/xdiff/xpatience.o libgit2/src/xdiff/xprepare.o \ + libgit2/src/xdiff/xutils.o + +OBJECTS.http_parser = libgit2/deps/http-parser/http_parser.o + +LIBGIT = $(OBJECTS.libgit2) $(OBJECTS.libgit2.streams) $(OBJECTS.libgit2.transports) \ + $(OBJECTS.libgit2.unix) $(OBJECTS.libgit2.xdiff) $(OBJECTS.http_parser) @GIT2R_SRC_REGEX@ + +$(SHLIB): libmygit.a + +libmygit.a: $(LIBGIT) + $(AR) rcs libmygit.a $(LIBGIT) + +clean: + rm -f *.o libmygit.a git2r.so $(LIBGIT) + +.PHONY: all clean diff -Nru r-cran-git2r-0.21.0/src/Makevars.win r-cran-git2r-0.22.1/src/Makevars.win --- r-cran-git2r-0.21.0/src/Makevars.win 2018-01-03 21:29:02.000000000 +0000 +++ r-cran-git2r-0.22.1/src/Makevars.win 2018-07-10 13:23:34.000000000 +0000 @@ -1,36 +1,19 @@ -PKG_CPPFLAGS=-Ilibgit2/src -Ilibgit2/include -Ilibgit2/deps/http-parser \ - -Ilibgit2/deps/regex -Ilibgit2/deps/libssh2/include \ - -I../windows/libz-1.2.8/include -I../windows/libssh2-1.6.0/include - -PKG_LIBS=-L. -lmygit \ - -L../windows/libz-1.2.8/lib${R_ARCH} \ - -L../windows/libssh2-1.6.0/lib${R_ARCH} -lssh2 -lz \ - -L../windows/openssl-1.0.2d/lib${R_ARCH} -lssl -lcrypto \ - -lgdi32 -lws2_32 -lwinhttp -lrpcrt4 -lole32 -lcrypt32 - -PKG_CFLAGS=-DWIN32 -D_WIN32_WINNT=0x0501 -D__USE_MINGW_ANSI_STDIO=1 \ - -DGIT_WINHTTP -D_FILE_OFFSET_BITS=64 -DGIT_SSH \ - -DGIT_USE_NSEC -DGIT_ARCH_$(WIN) -DLIBGIT2_NO_FEATURES_H - -LIBGIT=$(patsubst %.c,%.o,$(filter-out libgit2/src/transports/http.c,$(wildcard \ - libgit2/src/*.c libgit2/src/streams/*.c libgit2/src/transports/*.c \ - libgit2/src/xdiff/*.c libgit2/src/win32/*.c))) -LIBGIT+=libgit2/src/hash/hash_generic.o -LIBGIT+=libgit2/deps/http-parser/http_parser.o -LIBGIT+=libgit2/deps/regex/regex.o +VERSION = 0.27.2 +RWINLIB = ../windows/libgit2-${VERSION} -all: clean winlibs libwinhttp.dll.a libmygit.a +PKG_CPPFLAGS = -I${RWINLIB}/include \ + -DR_NO_REMAP -DSTRICT_R_HEADERS -winhttp.def: - cp libgit2/deps/winhttp/winhttp$(WIN).def.in winhttp.def +PKG_LIBS = -L${RWINLIB}/lib${R_ARCH} \ + -lgit2 -lcurl-dualssl -lhttp_parser -lssh2 -lz -lssl -lcrypto \ + -lwinhttp -lgdi32 -lole32 -lrpcrt4 -lws2_32 -lcrypt32 -lwldap32 -libmygit.a: $(LIBGIT) - $(AR) rcs libmygit.a $(LIBGIT) +all: clean winlibs winlibs: - "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" + "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" "../tools/winlibs.R" $(VERSION) clean: - rm -f *.o libwinhttp.dll.a winhttp.def git2r.dll libmygit.a $(LIBGIT) + rm -f $(SHLIB) $(OBJECTS) .PHONY: all winlibs clean diff -Nru r-cran-git2r-0.21.0/tests/blame.R r-cran-git2r-0.22.1/tests/blame.R --- r-cran-git2r-0.21.0/tests/blame.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/blame.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -41,33 +41,33 @@ ## Check blame b <- blame(repo, "test.txt") -stopifnot(identical(length(b@hunks), 2L)) +stopifnot(identical(length(b$hunks), 2L)) ## Hunk: 1 -stopifnot(identical(b@hunks[[1]]@lines_in_hunk, 1L)) -stopifnot(identical(b@hunks[[1]]@final_commit_id, commit.1@sha)) -stopifnot(identical(b@hunks[[1]]@final_start_line_number, 1L)) -stopifnot(identical(b@hunks[[1]]@final_signature@name, "Alice")) -stopifnot(identical(b@hunks[[1]]@final_signature@email, "alice@example.org")) -stopifnot(identical(b@hunks[[1]]@orig_commit_id, commit.1@sha)) -stopifnot(identical(b@hunks[[1]]@orig_start_line_number, 1L)) -stopifnot(identical(b@hunks[[1]]@orig_signature@name, "Alice")) -stopifnot(identical(b@hunks[[1]]@orig_signature@email, "alice@example.org")) -stopifnot(identical(b@hunks[[1]]@orig_path, "test.txt")) -stopifnot(identical(b@hunks[[1]]@boundary, TRUE)) +stopifnot(identical(b$hunks[[1]]$lines_in_hunk, 1L)) +stopifnot(identical(b$hunks[[1]]$final_commit_id, sha(commit.1))) +stopifnot(identical(b$hunks[[1]]$final_start_line_number, 1L)) +stopifnot(identical(b$hunks[[1]]$final_signature$name, "Alice")) +stopifnot(identical(b$hunks[[1]]$final_signature$email, "alice@example.org")) +stopifnot(identical(b$hunks[[1]]$orig_commit_id, sha(commit.1))) +stopifnot(identical(b$hunks[[1]]$orig_start_line_number, 1L)) +stopifnot(identical(b$hunks[[1]]$orig_signature$name, "Alice")) +stopifnot(identical(b$hunks[[1]]$orig_signature$email, "alice@example.org")) +stopifnot(identical(b$hunks[[1]]$orig_path, "test.txt")) +stopifnot(identical(b$hunks[[1]]$boundary, TRUE)) ## Hunk: 2 -stopifnot(identical(b@hunks[[2]]@lines_in_hunk, 2L)) -stopifnot(identical(b@hunks[[2]]@final_commit_id, commit.2@sha)) -stopifnot(identical(b@hunks[[2]]@final_start_line_number, 2L)) -stopifnot(identical(b@hunks[[2]]@final_signature@name, "Bob")) -stopifnot(identical(b@hunks[[2]]@final_signature@email, "bob@example.org")) -stopifnot(identical(b@hunks[[2]]@orig_commit_id, commit.2@sha)) -stopifnot(identical(b@hunks[[2]]@orig_start_line_number, 2L)) -stopifnot(identical(b@hunks[[2]]@orig_signature@name, "Bob")) -stopifnot(identical(b@hunks[[2]]@orig_signature@email, "bob@example.org")) -stopifnot(identical(b@hunks[[2]]@orig_path, "test.txt")) -stopifnot(identical(b@hunks[[2]]@boundary, FALSE)) +stopifnot(identical(b$hunks[[2]]$lines_in_hunk, 2L)) +stopifnot(identical(b$hunks[[2]]$final_commit_id, sha(commit.2))) +stopifnot(identical(b$hunks[[2]]$final_start_line_number, 2L)) +stopifnot(identical(b$hunks[[2]]$final_signature$name, "Bob")) +stopifnot(identical(b$hunks[[2]]$final_signature$email, "bob@example.org")) +stopifnot(identical(b$hunks[[2]]$orig_commit_id, sha(commit.2))) +stopifnot(identical(b$hunks[[2]]$orig_start_line_number, 2L)) +stopifnot(identical(b$hunks[[2]]$orig_signature$name, "Bob")) +stopifnot(identical(b$hunks[[2]]$orig_signature$email, "bob@example.org")) +stopifnot(identical(b$hunks[[2]]$orig_path, "test.txt")) +stopifnot(identical(b$hunks[[2]]$boundary, FALSE)) ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/blob.R r-cran-git2r-0.22.1/tests/blob.R --- r-cran-git2r-0.21.0/tests/blob.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/blob.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -38,19 +38,19 @@ ## Lookup blob blob <- lookup(repo, "cd0875583aabe89ee197ea133980a9085d08e497") -stopifnot(is(blob, "git_blob")) -stopifnot(identical(is_blob(blob), TRUE)) +stopifnot(isTRUE(is_blob(blob))) stopifnot(identical(is_binary(blob), FALSE)) stopifnot(identical(blob, lookup(repo, "cd0875"))) stopifnot(identical(length(blob), 13L)) stopifnot(identical(content(blob), "Hello world!")) +blob ## Add one more commit f <- file(file.path(path, "test.txt"), "wb") writeChar("Hello world!\nHELLO WORLD!\nHeLlO wOrLd!\n", f, eos = NULL) close(f) add(repo, "test.txt") -blob <- lookup(repo, tree(commit(repo, "New commit message"))@id[1]) +blob <- lookup(repo, tree(commit(repo, "New commit message"))$id[1]) stopifnot(identical(content(blob), c("Hello world!", "HELLO WORLD!", "HeLlO wOrLd!"))) @@ -103,7 +103,7 @@ blob_list_1 <- blob_create(repo, c(tmp_file_1, tmp_file_2), relative = FALSE) unlink(tmp_file_1) unlink(tmp_file_2) -stopifnot(identical(sapply(blob_list_1, slot, "sha"), +stopifnot(identical(sapply(blob_list_1, "[[", "sha"), c("af5626b4a114abcb82d63db7c8082c3c4756e51b", "d670460b4b4aece5915caf5c68d12f560a9fe3e4"))) @@ -118,24 +118,24 @@ close(f4) blob_list_2 <- blob_create(repo, c("test-workdir-1.txt", "test-workdir-2.txt")) -stopifnot(identical(sapply(blob_list_2, slot, "sha"), +stopifnot(identical(sapply(blob_list_2, "[[", "sha"), c("af5626b4a114abcb82d63db7c8082c3c4756e51b", "d670460b4b4aece5915caf5c68d12f560a9fe3e4"))) ## Test arguments res <- tools::assertError(.Call(git2r:::git2r_blob_content, NULL)) -stopifnot(length(grep("'blob' must be a S4 class git_blob", +stopifnot(length(grep("'blob' must be an S3 class git_blob", res[[1]]$message)) > 0) res <- tools::assertError(.Call(git2r:::git2r_blob_content, 3)) -stopifnot(length(grep("'blob' must be a S4 class git_blob", +stopifnot(length(grep("'blob' must be an S3 class git_blob", res[[1]]$message)) > 0) res <- tools::assertError(.Call(git2r:::git2r_blob_content, repo)) -stopifnot(length(grep("'blob' must be a S4 class git_blob", +stopifnot(length(grep("'blob' must be an S3 class git_blob", res[[1]]$message)) > 0) b <- blob_list_1[[1]] -b@sha <- NA_character_ +b$sha <- NA_character_ res <- tools::assertError(.Call(git2r:::git2r_blob_content, b)) -stopifnot(length(grep("'blob' must be a S4 class git_blob", +stopifnot(length(grep("'blob' must be an S3 class git_blob", res[[1]]$message)) > 0) ## Cleanup diff -Nru r-cran-git2r-0.21.0/tests/branch.R r-cran-git2r-0.22.1/tests/branch.R --- r-cran-git2r-0.21.0/tests/branch.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/branch.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -38,14 +38,14 @@ stopifnot(identical(length(branches(repo)), 1L)) stopifnot(identical(is_head(branches(repo)[[1]]), TRUE)) stopifnot(identical(is_local(branches(repo)[[1]]), TRUE)) -stopifnot(identical(branches(repo)[[1]]@name, "master")) -stopifnot(identical(branches(repo)[[1]], head(repo))) -stopifnot(identical(branches(repo)$master, head(repo))) +stopifnot(identical(branches(repo)[[1]]$name, "master")) +stopifnot(identical(branches(repo)[[1]], repository_head(repo))) +stopifnot(identical(branches(repo)$master, repository_head(repo))) ## Create a branch b <- branch_create(commit.1, name = "test") -stopifnot(identical(b@name, "test")) -stopifnot(identical(b@type, 1L)) +stopifnot(identical(b$name, "test")) +stopifnot(identical(b$type, 1L)) stopifnot(identical(length(branches(repo)), 2L)) stopifnot(identical(branch_target(branches(repo)[[1]]), branch_target(branches(repo)[[2]]))) @@ -73,27 +73,27 @@ ## Test arguments res <- tools::assertError(.Call(git2r:::git2r_branch_delete, NULL)) -stopifnot(length(grep("'branch' must be a S4 class git_branch", +stopifnot(length(grep("'branch' must be an S3 class git_branch", res[[1]]$message)) > 0) res <- tools::assertError(.Call(git2r:::git2r_branch_delete, 3)) -stopifnot(length(grep("'branch' must be a S4 class git_branch", +stopifnot(length(grep("'branch' must be an S3 class git_branch", res[[1]]$message)) > 0) res <- tools::assertError(.Call(git2r:::git2r_branch_delete, repo)) -stopifnot(length(grep("'branch' must be a S4 class git_branch", +stopifnot(length(grep("'branch' must be an S3 class git_branch", res[[1]]$message)) > 0) b_tmp <- b -b_tmp@name <- NA_character_ +b_tmp$name <- NA_character_ res <- tools::assertError(.Call(git2r:::git2r_branch_delete, b_tmp)) -stopifnot(length(grep("'branch' must be a S4 class git_branch", +stopifnot(length(grep("'branch' must be an S3 class git_branch", res[[1]]$message)) > 0) b_tmp <- b -b_tmp@type <- NA_integer_ +b_tmp$type <- NA_integer_ res <- tools::assertError(.Call(git2r:::git2r_branch_delete, b_tmp)) -stopifnot(length(grep("'branch' must be a S4 class git_branch", +stopifnot(length(grep("'branch' must be an S3 class git_branch", res[[1]]$message)) > 0) -b_tmp@type <- 3L +b_tmp$type <- 3L res <- tools::assertError(.Call(git2r:::git2r_branch_delete, b_tmp)) -stopifnot(length(grep("'branch' must be a S4 class git_branch", +stopifnot(length(grep("'branch' must be an S3 class git_branch", res[[1]]$message)) > 0) ## Delete branch @@ -113,7 +113,7 @@ stopifnot(identical(length(branches(repo)), 4L)) b.1 <- branch_rename(b.1, name = "test-1-new-name") stopifnot(identical(length(branches(repo)), 4L)) -stopifnot(identical(b.1@name, "test-1-new-name")) +stopifnot(identical(b.1$name, "test-1-new-name")) tools::assertError(branch_rename(b.1, name = "test-2")) branch_rename(b.1, name = "test-2", force = TRUE) stopifnot(identical(length(branches(repo)), 3L)) diff -Nru r-cran-git2r-0.21.0/tests/checkout_branch.R r-cran-git2r-0.22.1/tests/checkout_branch.R --- r-cran-git2r-0.21.0/tests/checkout_branch.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/checkout_branch.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -69,7 +69,7 @@ commit(repo, "First commit message") stopifnot(identical(length(branches(repo)), 1L)) -stopifnot(identical(branches(repo)[[1]]@name, "dev")) +stopifnot(identical(branches(repo)[[1]]$name, "dev")) ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/checkout-named-branch.R r-cran-git2r-0.22.1/tests/checkout-named-branch.R --- r-cran-git2r-0.21.0/tests/checkout-named-branch.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/checkout-named-branch.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -75,7 +75,7 @@ ## Checkout previous branch checkout(repo_2, "-") -stopifnot(identical(head(repo_2)@name, "master")) +stopifnot(identical(repository_head(repo_2)$name, "master")) ## Cleanup unlink(path_bare, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/checkout.R r-cran-git2r-0.22.1/tests/checkout.R --- r-cran-git2r-0.21.0/tests/checkout.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/checkout.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -74,14 +74,22 @@ ## Check HEAD stopifnot(identical(is_detached(repo), FALSE)) -stopifnot(identical(head(repo)@name, "master")) +stopifnot(identical(repository_head(repo)$name, "master")) + +## Check show and summary +repo +summary(repo) ## Checkout first commit checkout(commit.1, TRUE) stopifnot(identical(is_detached(repo), TRUE)) -stopifnot(identical(head(repo), commit.1)) +stopifnot(identical(repository_head(repo), commit.1)) stopifnot(identical(readLines(file.path(path, "test.txt")), "Hello world!")) +## Check show and summary +repo +summary(repo) + ## Checkout tag checkout(tags(repo)[[1]], TRUE) stopifnot(identical(is_detached(repo), TRUE)) diff -Nru r-cran-git2r-0.21.0/tests/checkout_tag.R r-cran-git2r-0.22.1/tests/checkout_tag.R --- r-cran-git2r-0.21.0/tests/checkout_tag.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/checkout_tag.R 2018-06-04 05:14:13.000000000 +0000 @@ -53,5 +53,9 @@ checkout(tag_2) stopifnot(identical(list.files(path), c("test-1.txt", "test-2.txt"))) +## Checkout "Tag1" and check files +checkout(repo, "Tag1") +stopifnot(identical(list.files(path), "test-1.txt")) + ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/clone_bare.R r-cran-git2r-0.22.1/tests/clone_bare.R --- r-cran-git2r-0.21.0/tests/clone_bare.R 2018-01-01 13:05:51.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/clone_bare.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -50,12 +50,12 @@ ## Check result in bare repository stopifnot(identical(length(commits(bare_repo)), 1L)) bare_commit_1 <- commits(bare_repo)[[1]] -stopifnot(identical(commit_1@sha, bare_commit_1@sha)) -stopifnot(identical(commit_1@author, bare_commit_1@author)) -stopifnot(identical(commit_1@committer, bare_commit_1@committer)) -stopifnot(identical(commit_1@summary, bare_commit_1@summary)) -stopifnot(identical(commit_1@message, bare_commit_1@message)) -stopifnot(!identical(commit_1@repo, bare_commit_1@repo)) +stopifnot(identical(sha(commit_1), sha(bare_commit_1))) +stopifnot(identical(commit_1$author, bare_commit_1$author)) +stopifnot(identical(commit_1$committer, bare_commit_1$committer)) +stopifnot(identical(commit_1$summary, bare_commit_1$summary)) +stopifnot(identical(commit_1$message, bare_commit_1$message)) +stopifnot(!identical(commit_1$repo, bare_commit_1$repo)) ## Cleanup unlink(path_bare, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/clone_branch.R r-cran-git2r-0.22.1/tests/clone_branch.R --- r-cran-git2r-0.21.0/tests/clone_branch.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/clone_branch.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -69,7 +69,7 @@ ## Check branch and commits stopifnot(identical(length(commits(repo_2)), 3L)) -stopifnot(identical(head(repo_2)@name, "dev")) +stopifnot(identical(repository_head(repo_2)$name, "dev")) ## Cleanup unlink(path_bare, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/clone_checkout.R r-cran-git2r-0.22.1/tests/clone_checkout.R --- r-cran-git2r-0.21.0/tests/clone_checkout.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/clone_checkout.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -50,13 +50,14 @@ ## Compare commits stopifnot(identical(length(commits(repo_tgt)), 1L)) -commit_tgt <- commits(repo_tgt)[[1]] -stopifnot(identical(commit_src@sha, commit_tgt@sha)) -stopifnot(identical(commit_src@author, commit_tgt@author)) -stopifnot(identical(commit_src@committer, commit_tgt@committer)) -stopifnot(identical(commit_src@summary, commit_tgt@summary)) -stopifnot(identical(commit_src@message, commit_tgt@message)) -stopifnot(!identical(commit_src@repo, commit_tgt@repo)) +commit_tgt <- last_commit(repo_tgt) +stopifnot(identical(sha(last_commit(path_tgt)), sha(commit_tgt))) +stopifnot(identical(sha(commit_src), sha(commit_tgt))) +stopifnot(identical(commit_src$author, commit_tgt$author)) +stopifnot(identical(commit_src$committer, commit_tgt$committer)) +stopifnot(identical(commit_src$summary, commit_tgt$summary)) +stopifnot(identical(commit_src$message, commit_tgt$message)) +stopifnot(!identical(commit_src$repo, commit_tgt$repo)) ## Cleanup unlink(path_tgt, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/commit.R r-cran-git2r-0.22.1/tests/commit.R --- r-cran-git2r-0.21.0/tests/commit.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/commit.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -41,12 +41,12 @@ commit_1 <- commit(repo, "Commit message") ## Check commit -stopifnot(identical(commit_1@author@name, "Alice")) -stopifnot(identical(commit_1@author@email, "alice@example.org")) -stopifnot(identical(lookup(repo, commit_1@sha), commit_1)) +stopifnot(identical(commit_1$author$name, "Alice")) +stopifnot(identical(commit_1$author$email, "alice@example.org")) +stopifnot(identical(lookup(repo, sha(commit_1)), commit_1)) stopifnot(identical(length(commits(repo)), 1L)) -stopifnot(identical(commits(repo)[[1]]@author@name, "Alice")) -stopifnot(identical(commits(repo)[[1]]@author@email, "alice@example.org")) +stopifnot(identical(commits(repo)[[1]]$author$name, "Alice")) +stopifnot(identical(commits(repo)[[1]]$author$email, "alice@example.org")) stopifnot(identical(parents(commit_1), list())) ## Check is_commit @@ -135,13 +135,14 @@ tools::assertError(commits(repo, n = "2")) ## Check to coerce repository to data.frame -df <- as(repo, "data.frame") +df <- as.data.frame(repo) stopifnot(identical(dim(df), c(8L, 6L))) stopifnot(identical(names(df), c("sha", "summary", "message", "author", "email", "when"))) ## Set working directory to path and check commits setwd(path) +stopifnot(identical(sha(last_commit()), sha(commits(repo, n = 1)[[1]]))) stopifnot(identical(length(commits()), 8L)) stopifnot(identical(length(commits(n = -1)), 8L)) stopifnot(identical(length(commits(n = 2)), 2L)) @@ -166,17 +167,17 @@ ## Check that 'git2r_arg_check_commit' raise error res <- tools::assertError(.Call(git2r:::git2r_commit_tree, NULL)) -stopifnot(length(grep("'commit' must be a S4 class git_commit", +stopifnot(length(grep("'commit' must be an S3 class git_commit", res[[1]]$message)) > 0) res <- tools::assertError(.Call(git2r:::git2r_commit_tree, 3)) -stopifnot(length(grep("'commit' must be a S4 class git_commit", +stopifnot(length(grep("'commit' must be an S3 class git_commit", res[[1]]$message)) > 0) res <- tools::assertError(.Call(git2r:::git2r_commit_tree, repo)) -stopifnot(length(grep("'commit' must be a S4 class git_commit", +stopifnot(length(grep("'commit' must be an S3 class git_commit", res[[1]]$message)) > 0) -commit_1@sha <- NA_character_ +commit_1$sha <- NA_character_ res <- tools::assertError(.Call(git2r:::git2r_commit_tree, commit_1)) -stopifnot(length(grep("'commit' must be a S4 class git_commit", +stopifnot(length(grep("'commit' must be an S3 class git_commit", res[[1]]$message)) > 0) ## Cleanup diff -Nru r-cran-git2r-0.21.0/tests/config.R r-cran-git2r-0.22.1/tests/config.R --- r-cran-git2r-0.21.0/tests/config.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/config.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -52,5 +52,51 @@ stopifnot(identical(cfg$local$user.name, "Alice")) stopifnot(identical(cfg$local$user.email, user.email)) +## Check git config files +cfg <- git_config_files(repo) +stopifnot(identical(length(cfg), 4L)) +stopifnot(identical(names(cfg), c("system", "xdg", "global", "local"))) +stopifnot(!is.na(cfg$local)) + +## Check location of .gitconfig on Windows +if (identical(Sys.getenv("APPVEYOR"), "True")) { + + ## AppVeyor diagnostics + str(Sys.getenv("USERPROFILE")) + str(Sys.getenv("HOMEDRIVE")) + str(normalizePath("~")) + str(git_config_files()) + + ## Temporarily move AppVeyor .gitconfig + gitconfig_appveyor <- "C:/Users/appveyor/.gitconfig" + gitconfig_tmp <- file.path(tempdir(), ".gitconfig") + file.rename(gitconfig_appveyor, gitconfig_tmp) + + ## Test config() on Windows + gitconfig_expected <- file.path(Sys.getenv("USERPROFILE"), ".gitconfig") + ## .gitconfig should not be created if no configuration options specified + config(global = TRUE) + stopifnot(!file.exists(gitconfig_expected)) + ## .gitconfig should be created in the user's home directory + config(global = TRUE, user.name = "name", user.email = "email") + stopifnot(file.exists(gitconfig_expected)) + unlink(gitconfig_expected) + ## .gitconfig should be created if user specifies option other than user.name + ## and user.email + config(global = TRUE, core.editor = "nano") + stopifnot(file.exists(gitconfig_expected)) + unlink(gitconfig_expected) + ## .gitconfig should not create a new .gitconfig if the user already has one + ## in Documents/ + gitconfig_documents <- "~/.gitconfig" + file.create(gitconfig_documents) + config(global = TRUE, core.editor = "nano") + stopifnot(!file.exists(gitconfig_expected)) + unlink(gitconfig_documents) + + ## Return AppVeyor .gitconfig + file.rename(gitconfig_tmp, gitconfig_appveyor) +} + ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/diff.R r-cran-git2r-0.22.1/tests/diff.R --- r-cran-git2r-0.21.0/tests/diff.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/diff.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2017 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -39,13 +39,13 @@ diff(repo, as_char=TRUE) diff(repo, as_char=TRUE, filename = file.path(path, "test.diff")) -stopifnot(identical(diff_1@old, "index")) -stopifnot(identical(diff_1@new, "workdir")) -stopifnot(identical(length(diff_1@files), 1L)) -stopifnot(identical(diff_1@files[[1]]@old_file, "test.txt")) -stopifnot(identical(diff_1@files[[1]]@new_file, "test.txt")) -stopifnot(identical(length(diff_1@files[[1]]@hunks), 1L)) -stopifnot(identical(length(diff_1@files[[1]]@hunks[[1]]@lines), 4L)) +stopifnot(identical(diff_1$old, "index")) +stopifnot(identical(diff_1$new, "workdir")) +stopifnot(identical(length(diff_1$files), 1L)) +stopifnot(identical(diff_1$files[[1]]$old_file, "test.txt")) +stopifnot(identical(diff_1$files[[1]]$new_file, "test.txt")) +stopifnot(identical(length(diff_1$files[[1]]$hunks), 1L)) +stopifnot(identical(length(diff_1$files[[1]]$hunks[[1]]$lines), 4L)) ## TODO: check actual diff ## Diff between index and HEAD is empty @@ -53,18 +53,18 @@ diff(repo, as_char=TRUE) diff(repo, as_char=TRUE, filename = file.path(path, "test.diff")) -stopifnot(identical(diff_2@old, "HEAD")) -stopifnot(identical(diff_2@new, "index")) -stopifnot(identical(diff_2@files, list())) +stopifnot(identical(diff_2$old, "HEAD")) +stopifnot(identical(diff_2$new, "index")) +stopifnot(identical(diff_2$files, list())) ## Diff between tree and working dir, same as diff_1 diff_3 <- diff(tree(commits(repo)[[1]])) diff(repo, as_char=TRUE) diff(repo, as_char=TRUE, filename = file.path(path, "test.diff")) -stopifnot(identical(diff_3@old, tree(commits(repo)[[1]]))) -stopifnot(identical(diff_3@new, "workdir")) -stopifnot(identical(diff_3@files, diff_1@files)) +stopifnot(identical(diff_3$old, tree(commits(repo)[[1]]))) +stopifnot(identical(diff_3$new, "workdir")) +stopifnot(identical(diff_3$files, diff_1$files)) ## Add changes, diff between index and HEAD is the same as diff_1 add(repo, "test.txt") @@ -72,18 +72,18 @@ diff(repo, as_char=TRUE) diff(repo, as_char=TRUE, filename = file.path(path, "test.diff")) -stopifnot(identical(diff_4@old, "HEAD")) -stopifnot(identical(diff_4@new, "index")) -stopifnot(identical(diff_4@files, diff_1@files)) +stopifnot(identical(diff_4$old, "HEAD")) +stopifnot(identical(diff_4$new, "index")) +stopifnot(identical(diff_4$files, diff_1$files)) ## Diff between tree and index diff_5 <- diff(tree(commits(repo)[[1]]), index=TRUE) diff(repo, as_char=TRUE) diff(repo, as_char=TRUE, filename = file.path(path, "test.diff")) -stopifnot(identical(diff_5@old, tree(commits(repo)[[1]]))) -stopifnot(identical(diff_5@new, "index")) -stopifnot(identical(diff_5@files, diff_1@files)) +stopifnot(identical(diff_5$old, tree(commits(repo)[[1]]))) +stopifnot(identical(diff_5$new, "index")) +stopifnot(identical(diff_5$files, diff_1$files)) ## Diff between two trees commit(repo, "Second commit") @@ -93,9 +93,9 @@ diff(repo, as_char=TRUE) diff(repo, as_char=TRUE, filename = file.path(path, "test.diff")) -stopifnot(identical(diff_6@old, tree_1)) -stopifnot(identical(diff_6@new, tree_2)) -stopifnot(identical(diff_6@files, diff_1@files)) +stopifnot(identical(diff_6$old, tree_1)) +stopifnot(identical(diff_6$new, tree_2)) +stopifnot(identical(diff_6$files, diff_1$files)) ## Length of a diff stopifnot(identical(length(diff_1), 1L)) diff -Nru r-cran-git2r-0.21.0/tests/fast_forward_merge.R r-cran-git2r-0.22.1/tests/fast_forward_merge.R --- r-cran-git2r-0.21.0/tests/fast_forward_merge.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/fast_forward_merge.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -45,21 +45,20 @@ # Checkout master and merge b <- branches(repo) -checkout(b[sapply(b, slot, "name") == "master"][[1]], force=TRUE) -m <- git2r:::merge_branch( - branch = b[sapply(b, slot, "name") == "test"][[1]], - commit_on_success = TRUE, - merger = default_signature(repo)) +checkout(b[sapply(b, "[", "name") == "master"][[1]], force=TRUE) +m <- merge(b[sapply(b, "[", "name") == "test"][[1]]) # Check merge -stopifnot(is(object = m, class2 = "git_merge_result")) -stopifnot(identical(m@fast_forward, TRUE)) -stopifnot(identical(m@conflicts, FALSE)) +stopifnot(inherits(m, "git_merge_result")) +stopifnot(identical(m$up_to_date, FALSE)) +stopifnot(identical(m$fast_forward, TRUE)) +stopifnot(identical(m$conflicts, FALSE)) +stopifnot(identical(sha(m), NA_character_)) stopifnot(identical(length(commits(repo)), 2L)) # Check reflog r <- reflog(repo) -stopifnot(identical(r[[1]]@message, "merge test: Fast-forward")) +stopifnot(identical(r[[1]]$message, "merge test: Fast-forward")) ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/fetch.R r-cran-git2r-0.22.1/tests/fetch.R --- r-cran-git2r-0.21.0/tests/fetch.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/fetch.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -48,12 +48,12 @@ ## Check result in bare repository stopifnot(identical(length(commits(bare_repo)), 1L)) bare_commit_1 <- commits(bare_repo)[[1]] -stopifnot(identical(commit_1@sha, bare_commit_1@sha)) -stopifnot(identical(commit_1@author, bare_commit_1@author)) -stopifnot(identical(commit_1@committer, bare_commit_1@committer)) -stopifnot(identical(commit_1@summary, bare_commit_1@summary)) -stopifnot(identical(commit_1@message, bare_commit_1@message)) -stopifnot(!identical(commit_1@repo, bare_commit_1@repo)) +stopifnot(identical(sha(commit_1), sha(bare_commit_1))) +stopifnot(identical(commit_1$author, bare_commit_1$author)) +stopifnot(identical(commit_1$committer, bare_commit_1$committer)) +stopifnot(identical(commit_1$summary, bare_commit_1$summary)) +stopifnot(identical(commit_1$message, bare_commit_1$message)) +stopifnot(!identical(commit_1$repo, bare_commit_1$repo)) ## Fetch fetch(repo_2, "origin") @@ -64,88 +64,88 @@ ## Check that 'git2r_arg_check_credentials' raise error res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", 3, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", repo_1, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) credentials <- cred_env(c("username", "username"), "password") res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) credentials <- cred_env("username", c("password", "passowrd")) res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) credentials <- cred_user_pass(c("username", "username"), "password") res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) credentials <- cred_user_pass("username", c("password", "passowrd")) res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) credentials <- cred_token(c("GITHUB_PAT", "GITHUB_PAT")) res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) -credentials <- new("cred_ssh_key", - publickey = c("id_rsa.pub", "id_rsa.pub"), - privatekey = "id_rsa", - passphrase = character(0)) +credentials <- structure(list(publickey = c("id_rsa.pub", "id_rsa.pub"), + privatekey = "id_rsa", + passphrase = character(0)), + class = "cred_ssh_key") res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) -credentials <- new("cred_ssh_key", - publickey = "id_rsa.pub", - privatekey = c("id_rsa", "id_rsa"), - passphrase = character(0)) +credentials <- structure(list(publickey = "id_rsa.pub", + privatekey = c("id_rsa", "id_rsa"), + passphrase = character(0)), + class = "cred_ssh_key") res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) -credentials <- new("cred_ssh_key", - publickey = "id_rsa.pub", - privatekey = "id_rsa", - passphrase = NA_character_) +credentials <- structure(list(publickey = "id_rsa.pub", + privatekey = "id_rsa", + passphrase = NA_character_), + class = "cred_ssh_key") res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) -credentials <- new("cred_ssh_key", - publickey = "id_rsa.pub", - privatekey = "id_rsa", - passphrase = c("passphrase", "passphrase")) +credentials <- structure(list(publickey = "id_rsa.pub", + privatekey = "id_rsa", + passphrase = c("passphrase", "passphrase")), + class = "cred_ssh_key") res <- tools::assertError( .Call(git2r:::git2r_remote_fetch, repo_1, "origin", credentials, "fetch", FALSE, NULL)) -stopifnot(length(grep("'credentials' must be a S4 class with credentials", +stopifnot(length(grep("'credentials' must be an S3 class with credentials", res[[1]]$message)) > 0) ## Cleanup diff -Nru r-cran-git2r-0.21.0/tests/libgit2.R r-cran-git2r-0.22.1/tests/libgit2.R --- r-cran-git2r-0.21.0/tests/libgit2.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/libgit2.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -24,6 +24,3 @@ stopifnot(identical(names(libgit2_version()), c("major", "minor", "rev"))) - -stopifnot(identical(length(libgit2_sha()), 1L)) -stopifnot(identical(nchar(libgit2_sha()[1]), 40L)) diff -Nru r-cran-git2r-0.21.0/tests/merge_named_branch.R r-cran-git2r-0.22.1/tests/merge_named_branch.R --- r-cran-git2r-0.21.0/tests/merge_named_branch.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/merge_named_branch.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -56,19 +56,19 @@ ## Checkout master b <- branches(repo) -checkout(b[sapply(b, slot, "name") == "master"][[1]], force=TRUE) +checkout(b[sapply(b, "[", "name") == "master"][[1]], force=TRUE) ## Merge branch 1 -m_1 <- git2r:::merge_named_branch(repo, "branch1", TRUE, default_signature(repo)) -stopifnot(identical(m_1@fast_forward, TRUE)) -stopifnot(identical(m_1@conflicts, FALSE)) -stopifnot(identical(m_1@sha, character(0))) +m_1 <- merge(repo, "branch1") +stopifnot(identical(m_1$fast_forward, TRUE)) +stopifnot(identical(m_1$conflicts, FALSE)) +stopifnot(identical(sha(m_1), NA_character_)) ## Merge branch 2 -m_2 <- git2r:::merge_named_branch(repo, "branch2", TRUE, default_signature(repo)) -stopifnot(identical(m_2@fast_forward, FALSE)) -stopifnot(identical(m_2@conflicts, FALSE)) -stopifnot(identical(m_2@sha, commits(repo)[[1]]@sha)) +m_2 <- merge(path, "branch2") +stopifnot(identical(m_2$fast_forward, FALSE)) +stopifnot(identical(m_2$conflicts, FALSE)) +stopifnot(identical(sha(m_2), sha(commits(repo)[[1]]))) ## Create third branch, checkout, change file and commit checkout(repo, "branch3", create=TRUE) @@ -87,11 +87,11 @@ commit(repo, "Some commit message branch 1") ## Merge branch 3 -m_3 <- git2r:::merge_named_branch(repo, "branch3", TRUE, default_signature(repo)) -stopifnot(identical(m_3@up_to_date, FALSE)) -stopifnot(identical(m_3@fast_forward, FALSE)) -stopifnot(identical(m_3@conflicts, TRUE)) -stopifnot(identical(m_3@sha, character(0))) +m_3 <- merge(repo, "branch3") +stopifnot(identical(m_3$up_to_date, FALSE)) +stopifnot(identical(m_3$fast_forward, FALSE)) +stopifnot(identical(m_3$conflicts, TRUE)) +stopifnot(identical(sha(m_3), NA_character_)) ## Check status; Expect to have one unstaged unmerged conflict. stopifnot(identical(status(repo), diff -Nru r-cran-git2r-0.21.0/tests/merge.R r-cran-git2r-0.22.1/tests/merge.R --- r-cran-git2r-0.21.0/tests/merge.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/merge.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -57,30 +57,29 @@ ## Checkout master b <- branches(repo) -checkout(b[sapply(b, slot, "name") == "master"][[1]], force=TRUE) +checkout(b[sapply(b, "[", "name") == "master"][[1]], force=TRUE) ## Merge branch 1 -m_1 <- git2r:::merge_branch( - b[sapply(b, slot, "name") == "branch1"][[1]], - commit_on_success = TRUE, - merger = default_signature(repo)) - -stopifnot(identical(m_1@fast_forward, TRUE)) -stopifnot(identical(m_1@conflicts, FALSE)) -stopifnot(identical(m_1@sha, character(0))) +m_1 <- merge(b[sapply(b, "[", "name") == "branch1"][[1]]) +stopifnot(identical(m_1$fast_forward, TRUE)) +stopifnot(identical(m_1$conflicts, FALSE)) +stopifnot(identical(sha(m_1), NA_character_)) + +## Merge branch 1 again +m_1_again <- merge(b[sapply(b, "[", "name") == "branch1"][[1]]) +stopifnot(identical(m_1_again$up_to_date, TRUE)) +stopifnot(identical(m_1_again$fast_forward, FALSE)) +stopifnot(identical(m_1_again$conflicts, FALSE)) +stopifnot(identical(sha(m_1_again), NA_character_)) ## Merge branch 2 -m_2 <- git2r:::merge_branch( - b[sapply(b, slot, "name") == "branch2"][[1]], - commit_on_success = TRUE, - merger = default_signature(repo)) - -stopifnot(identical(m_2@fast_forward, FALSE)) -stopifnot(identical(m_2@conflicts, FALSE)) -stopifnot(identical(m_2@sha, commits(repo)[[1]]@sha)) +m_2 <- merge(b[sapply(b, "[", "name") == "branch2"][[1]]) +stopifnot(identical(m_2$fast_forward, FALSE)) +stopifnot(identical(m_2$conflicts, FALSE)) +stopifnot(identical(sha(m_2), sha(commits(repo)[[1]]))) ## Create third branch, checkout, change file and commit -b_3 <- branch_create(lookup(repo, m_2@sha), "branch3") +b_3 <- branch_create(lookup(repo, sha(m_2)), "branch3") checkout(b_3) writeLines(c("Lorem ipsum dolor amet sit, consectetur adipisicing elit, sed do", "eiusmod tempor incididunt ut labore et dolore magna aliqua."), @@ -91,23 +90,36 @@ ## Checkout master and create a change that creates a conflict on ## merge b <- branches(repo) -checkout(b[sapply(b, slot, "name") == "master"][[1]], force=TRUE) +checkout(b[sapply(b, "[", "name") == "master"][[1]], force=TRUE) writeLines(c("Lorem ipsum dolor sit amet, adipisicing consectetur elit, sed do", "eiusmod tempor incididunt ut labore et dolore magna aliqua."), con = file.path(path, "test.txt")) add(repo, "test.txt") commit(repo, "Some commit message branch 1") +## Merge branch 3 with fail = TRUE +m_3 <- merge(b[sapply(b, "[", "name") == "branch3"][[1]], fail = TRUE) +stopifnot(identical(m_3$up_to_date, FALSE)) +stopifnot(identical(m_3$fast_forward, FALSE)) +stopifnot(identical(m_3$conflicts, TRUE)) +stopifnot(identical(sha(m_3), NA_character_)) +m_3 + +## Check status; Expect to have a clean working directory +wd <- structure(list(staged = structure(list(), .Names = character(0)), + unstaged = structure(list(), .Names = character(0)), + untracked = structure(list(), .Names = character(0))), + .Names = c("staged", "unstaged", "untracked"), + class = "git_status") +stopifnot(identical(status(repo), wd)) + ## Merge branch 3 -m_3 <- git2r:::merge_branch( - b[sapply(b, slot, "name") == "branch3"][[1]], - commit_on_success = TRUE, - merger = default_signature(repo)) - -stopifnot(identical(m_3@up_to_date, FALSE)) -stopifnot(identical(m_3@fast_forward, FALSE)) -stopifnot(identical(m_3@conflicts, TRUE)) -stopifnot(identical(m_3@sha, character(0))) +m_3 <- merge(b[sapply(b, "[", "name") == "branch3"][[1]]) +stopifnot(identical(m_3$up_to_date, FALSE)) +stopifnot(identical(m_3$fast_forward, FALSE)) +stopifnot(identical(m_3$conflicts, TRUE)) +stopifnot(identical(sha(m_3), NA_character_)) +m_3 ## Check status; Expect to have one unstaged unmerged conflict. stopifnot(identical(status(repo), diff -Nru r-cran-git2r-0.21.0/tests/normal_merge.R r-cran-git2r-0.22.1/tests/normal_merge.R --- r-cran-git2r-0.21.0/tests/normal_merge.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/normal_merge.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -55,14 +55,14 @@ commit(repo, "Fourth commit message") ## Merge 'fix' -git2r:::merge_named_branch(repo, "fix", TRUE, default_signature(repo)) +merge(repo, "fix", TRUE, default_signature(repo)) ## Check number of parents of each commit stopifnot(identical(sapply(commits(repo), function(x) length(parents(x))), c(2L, 1L, 1L, 1L, 0L))) ## Check that last commit is a merge -stopifnot(is_merge(lookup(repo, branch_target(head(repo))))) +stopifnot(is_merge(lookup(repo, branch_target(repository_head(repo))))) ## Check that metadata associated with merge is removed stopifnot(!file.exists(file.path(path, ".git", "MERGE_HEAD"))) diff -Nru r-cran-git2r-0.21.0/tests/note.R r-cran-git2r-0.22.1/tests/note.R --- r-cran-git2r-0.21.0/tests/note.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/note.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -70,11 +70,11 @@ ## Create note on blob and tree tree.1 <- tree(commit.1) note.7 <- note_create(tree.1, "Note-7") -stopifnot(is(object = lookup(repo, note.7@annotated), class2 = "git_tree")) +stopifnot(is(object = lookup(repo, note.7$annotated), class2 = "git_tree")) stopifnot(identical(length(notes(repo)), 2L)) -blob.1 <- lookup(repo, tree.1@id[1]) +blob.1 <- lookup(repo, tree.1$id[1]) note.8 <- note_create(blob.1, "Note-8") -stopifnot(is(object = lookup(repo, note.8@annotated), class2 = "git_blob")) +stopifnot(is(object = lookup(repo, note.8$annotated), class2 = "git_blob")) stopifnot(identical(length(notes(repo)), 3L)) ## Cleanup diff -Nru r-cran-git2r-0.21.0/tests/pre-process-path.R r-cran-git2r-0.22.1/tests/pre-process-path.R --- r-cran-git2r-0.21.0/tests/pre-process-path.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/pre-process-path.R 2018-06-04 05:14:13.000000000 +0000 @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() diff -Nru r-cran-git2r-0.21.0/tests/pull.R r-cran-git2r-0.22.1/tests/pull.R --- r-cran-git2r-0.21.0/tests/pull.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/pull.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -59,14 +59,14 @@ stopifnot(identical(length(commits(repo_2)), 2L)) ## Check remote url of repo_2 -stopifnot(identical(branch_remote_url(branch_get_upstream(head(repo_2))), +stopifnot(identical(branch_remote_url(branch_get_upstream(repository_head(repo_2))), path_bare)) ## Unset remote remote tracking branch -branch_set_upstream(head(repo_2), NULL) -stopifnot(is.null(branch_get_upstream(head(repo_2)))) +branch_set_upstream(repository_head(repo_2), NULL) +stopifnot(is.null(branch_get_upstream(repository_head(repo_2)))) tools::assertError(pull(repo_2)) -tools::assertError(branch_set_upstream(head(repo_2), NULL)) +tools::assertError(branch_set_upstream(repository_head(repo_2), NULL)) ## Add more changes to repo 1 and push to bare writeLines(c("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do", @@ -78,8 +78,8 @@ push(repo_1) ## Set remote tracking branch -branch_set_upstream(head(repo_2), "origin/master") -stopifnot(identical(branch_remote_url(branch_get_upstream(head(repo_2))), +branch_set_upstream(repository_head(repo_2), "origin/master") +stopifnot(identical(branch_remote_url(branch_get_upstream(repository_head(repo_2))), path_bare)) ## Pull changes to repo_2 @@ -91,18 +91,18 @@ stopifnot(identical(references(repo_1), references(repo_2))) ref_1 <- references(repo_1)[["refs/heads/master"]] -stopifnot(identical(ref_1@name, "refs/heads/master")) -stopifnot(identical(ref_1@type, 1L)) -stopifnot(identical(ref_1@sha, commit_3@sha)) -stopifnot(identical(ref_1@target, NA_character_)) -stopifnot(identical(ref_1@shorthand, "master")) +stopifnot(identical(ref_1$name, "refs/heads/master")) +stopifnot(identical(ref_1$type, 1L)) +stopifnot(identical(sha(ref_1), sha(commit_3))) +stopifnot(identical(ref_1$target, NA_character_)) +stopifnot(identical(ref_1$shorthand, "master")) ref_2 <- references(repo_1)[["refs/remotes/origin/master"]] -stopifnot(identical(ref_2@name, "refs/remotes/origin/master")) -stopifnot(identical(ref_2@type, 1L)) -stopifnot(identical(ref_2@sha, commit_3@sha)) -stopifnot(identical(ref_2@target, NA_character_)) -stopifnot(identical(ref_2@shorthand, "origin/master")) +stopifnot(identical(ref_2$name, "refs/remotes/origin/master")) +stopifnot(identical(ref_2$type, 1L)) +stopifnot(identical(sha(ref_2), sha(commit_3))) +stopifnot(identical(ref_2$target, NA_character_)) +stopifnot(identical(ref_2$shorthand, "origin/master")) ## Check references with missing repo argument wd <- setwd(path_repo_1) diff -Nru r-cran-git2r-0.21.0/tests/push-force.R r-cran-git2r-0.22.1/tests/push-force.R --- r-cran-git2r-0.21.0/tests/push-force.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/push-force.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -70,8 +70,8 @@ ## Check commits stopifnot(identical(length(commits(bare_repo)), 2L)) -stopifnot(identical(commits(repo_2)[[1]]@sha, commits(bare_repo)[[1]]@sha)) -stopifnot(identical(commits(repo_2)[[2]]@sha, commits(bare_repo)[[2]]@sha)) +stopifnot(identical(sha(commits(repo_2)[[1]]), sha(commits(bare_repo)[[1]]))) +stopifnot(identical(sha(commits(repo_2)[[2]]), sha(commits(bare_repo)[[2]]))) ## Cleanup unlink(path_bare, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/push.R r-cran-git2r-0.22.1/tests/push.R --- r-cran-git2r-0.21.0/tests/push.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/push.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -43,11 +43,11 @@ commit_1 <- commit(repo, "Commit message") ## Check commit -stopifnot(identical(commit_1@author@name, "Alice")) -stopifnot(identical(commit_1@author@email, "alice@example.org")) +stopifnot(identical(commit_1$author$name, "Alice")) +stopifnot(identical(commit_1$author$email, "alice@example.org")) stopifnot(identical(length(commits(repo)), 1L)) -stopifnot(identical(commits(repo)[[1]]@author@name, "Alice")) -stopifnot(identical(commits(repo)[[1]]@author@email, "alice@example.org")) +stopifnot(identical(commits(repo)[[1]]$author$name, "Alice")) +stopifnot(identical(commits(repo)[[1]]$author$email, "alice@example.org")) ## Check push arguments tools::assertError(push(repo, character(0), "refs/heads/master")) @@ -69,23 +69,23 @@ r <- reflog(repo, "refs/remotes/origin/master") stopifnot(identical(length(r), 1L)) r <- r[[1]] -stopifnot(identical(r@sha, commit_1@sha)) -stopifnot(identical(r@message, "update by push")) -stopifnot(identical(r@index, 0L)) -stopifnot(identical(r@committer@name, "Alice")) -stopifnot(identical(r@committer@email, "alice@example.org")) -stopifnot(identical(r@refname, "refs/remotes/origin/master")) -stopifnot(identical(r@repo@path, repo@path)) +stopifnot(identical(sha(r), sha(commit_1))) +stopifnot(identical(r$message, "update by push")) +stopifnot(identical(r$index, 0L)) +stopifnot(identical(r$committer$name, "Alice")) +stopifnot(identical(r$committer$email, "alice@example.org")) +stopifnot(identical(r$refname, "refs/remotes/origin/master")) +stopifnot(identical(r$repo$path, repo$path)) ## Check result in bare repository stopifnot(identical(length(commits(bare_repo)), 1L)) bare_commit_1 <- commits(bare_repo)[[1]] -stopifnot(identical(commit_1@sha, bare_commit_1@sha)) -stopifnot(identical(commit_1@author, bare_commit_1@author)) -stopifnot(identical(commit_1@committer, bare_commit_1@committer)) -stopifnot(identical(commit_1@summary, bare_commit_1@summary)) -stopifnot(identical(commit_1@message, bare_commit_1@message)) -stopifnot(!identical(commit_1@repo, bare_commit_1@repo)) +stopifnot(identical(sha(commit_1), sha(bare_commit_1))) +stopifnot(identical(commit_1$author, bare_commit_1$author)) +stopifnot(identical(commit_1$committer, bare_commit_1$committer)) +stopifnot(identical(commit_1$summary, bare_commit_1$summary)) +stopifnot(identical(commit_1$message, bare_commit_1$message)) +stopifnot(!identical(commit_1$repo, bare_commit_1$repo)) ## Add changes to repo and push head writeLines(c("Hello world", "HELLO WORLD"), @@ -93,13 +93,13 @@ add(repo, "test.txt") commit_2 <- commit(repo, "Commit message 2") push(repo) -bare_commit_2 <- lookup(bare_repo, commit_2@sha) -stopifnot(identical(commit_2@sha, bare_commit_2@sha)) -stopifnot(identical(commit_2@author, bare_commit_2@author)) -stopifnot(identical(commit_2@committer, bare_commit_2@committer)) -stopifnot(identical(commit_2@summary, bare_commit_2@summary)) -stopifnot(identical(commit_2@message, bare_commit_2@message)) -stopifnot(!identical(commit_2@repo, bare_commit_2@repo)) +bare_commit_2 <- lookup(bare_repo, sha(commit_2)) +stopifnot(identical(sha(commit_2), sha(bare_commit_2))) +stopifnot(identical(commit_2$author, bare_commit_2$author)) +stopifnot(identical(commit_2$committer, bare_commit_2$committer)) +stopifnot(identical(commit_2$summary, bare_commit_2$summary)) +stopifnot(identical(commit_2$message, bare_commit_2$message)) +stopifnot(!identical(commit_2$repo, bare_commit_2$repo)) ## Cleanup unlink(path_bare, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/reflog.R r-cran-git2r-0.22.1/tests/reflog.R --- r-cran-git2r-0.21.0/tests/reflog.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/reflog.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2016 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -40,11 +40,14 @@ ## Check that reflog is not empry stopifnot(identical(length(reflog(repo)), 1L)) reflog_entry <- reflog(repo)[[1]] -stopifnot(identical(reflog_entry@sha, commit.1@sha)) -stopifnot(identical(reflog_entry@refname, "HEAD")) -stopifnot(identical(reflog_entry@index, 0L)) -stopifnot(identical(reflog_entry@committer@email, "alice@example.org")) -stopifnot(identical(reflog_entry@message, "commit (initial): Commit message")) +stopifnot(identical(sha(reflog_entry), sha(commit.1))) +stopifnot(identical(reflog_entry$refname, "HEAD")) +stopifnot(identical(reflog_entry$index, 0L)) +stopifnot(identical(reflog_entry$committer$email, "alice@example.org")) +stopifnot(identical(reflog_entry$message, "commit (initial): Commit message")) + +## Check printing +reflog(repo) ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/remove.R r-cran-git2r-0.22.1/tests/remove.R --- r-cran-git2r-0.21.0/tests/remove.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/remove.R 2018-06-04 05:14:18.000000000 +0000 @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() diff -Nru r-cran-git2r-0.21.0/tests/repository.R r-cran-git2r-0.22.1/tests/repository.R --- r-cran-git2r-0.21.0/tests/repository.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/repository.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013 - 2016 The git2r contributors +## Copyright (C) 2013 - 2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -36,20 +36,19 @@ repo <- init(path) ## Check the state of the repository -stopifnot(validObject(repo)) stopifnot(identical(is_bare(repo), FALSE)) stopifnot(identical(is_empty(repo), TRUE)) stopifnot(identical(is_shallow(repo), FALSE)) stopifnot(identical(branches(repo), structure(list(), .Names = character(0)))) stopifnot(identical(references(repo), structure(list(), .Names = character(0)))) stopifnot(identical(commits(repo), list())) -stopifnot(identical(head(repo), NULL)) +stopifnot(identical(repository_head(repo), NULL)) # check that we can find repository from a path wd <- sub(paste0("[", .Platform$file.sep, "]$"), "", workdir(repo)) writeLines('test file', con = file.path(wd, "myfile.txt")) stopifnot(identical(discover_repository(file.path(wd, "myfile.txt")), - paste0(file.path(wd, ".git"), .Platform$file.sep))) + file.path(wd, ".git"))) stopifnot(identical(discover_repository(file.path(wd, "doesntexist.txt")), NULL)) @@ -57,7 +56,7 @@ dir.create(file.path(wd, "temp")) stopifnot(identical(discover_repository(file.path(wd, "temp"), 0), NULL)) stopifnot(identical(discover_repository(file.path(wd, "temp"), 1), - paste0(file.path(wd, ".git"), .Platform$file.sep))) + file.path(wd, ".git"))) tools::assertError(discover_repository(file.path(wd, "temp"), 2)) ## Check that lookup with a sha of less than 4 characters or more than diff -Nru r-cran-git2r-0.21.0/tests/revparse.R r-cran-git2r-0.22.1/tests/revparse.R --- r-cran-git2r-0.21.0/tests/revparse.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/revparse.R 2018-06-04 05:14:13.000000000 +0000 @@ -42,6 +42,7 @@ commit(repo, "Second commit message") stopifnot(identical(revparse_single(repo, "HEAD^"), commit_1)) +stopifnot(is_blob(revparse_single(repo, "HEAD:test.txt"))) ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/signature.R r-cran-git2r-0.22.1/tests/signature.R --- r-cran-git2r-0.21.0/tests/signature.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/signature.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,34 +14,17 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() -## Check validity of S4 class git_signature -## Each slot must have length equal to one -when <- new("git_time", time = 1395567947, offset = 60) - -tools::assertError(validObject(new("git_signature", - when = when))) - -tools::assertError(validObject(new("git_signature", - name = character(0), - email = "email", - when = when))) - -tools::assertError(validObject(new("git_signature", - name = c("name1", "name2"), - email = "email", - when = when))) - -tools::assertError(validObject(new("git_signature", - name = "name", - email = character(0), - when = when))) - -tools::assertError(validObject(new("git_signature", - name = "name", - email = c("email1", "email2"), - when = when))) +## Check printing of a class git_signature +when <- structure(list(time = 1395567947, offset = 60), + class = "git_time") + +signature <- structure(list(name = "Alice", + email = "alice@example.org", + when = when), + class = "git_signature") +signature diff -Nru r-cran-git2r-0.21.0/tests/stash.R r-cran-git2r-0.22.1/tests/stash.R --- r-cran-git2r-0.21.0/tests/stash.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/stash.R 2018-07-01 21:27:25.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -34,8 +34,16 @@ add(repo, 'test-1.txt') commit(repo, "Commit message") -## Make one more commit +## Apply stash writeLines(c("Hello world!", "HELLO WORLD!"), file.path(path, "test-1.txt")) +stash(repo) +stopifnot(identical("Hello world!", + readLines(file.path(path, "test-1.txt")))) +stash_pop(repo) +stopifnot(identical(c("Hello world!", "HELLO WORLD!"), + readLines(file.path(path, "test-1.txt")))) + +## Make one more commit add(repo, 'test-1.txt') commit(repo, "Next commit message") @@ -51,11 +59,14 @@ ## Stash stash(repo) stopifnot(identical(stash_list(repo), list())) -stash(repo, untracked=TRUE) +s <- stash(repo, untracked=TRUE) +s +summary(s) stopifnot(identical(length(stash_list(repo)), 1L)) +tree(stash_list(repo)[[1]]) ## Drop stash -stash_drop(repo, 0) +stash_drop(repo, 1) stopifnot(identical(stash_list(repo), list())) ## Check stash_drop argument diff -Nru r-cran-git2r-0.21.0/tests/tag.R r-cran-git2r-0.22.1/tests/tag.R --- r-cran-git2r-0.21.0/tests/tag.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/tag.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,55 +14,11 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() -## Check validity of S4 class git_tag -## Each slot must have length equal to one -when <- new("git_time", time = 1395567947, offset = 60) -tagger <- new("git_signature", - name = "Alice", - email = "alice@example.org", - when = when) - -tools::assertError(validObject(new("git_tag", - message = character(0), - name = "name1", - tagger = tagger, - target = "target1"))) - -tools::assertError(validObject(new("git_tag", - message = c("message1", "message2"), - name = "name1", - tagger = tagger, - target = "target1"))) - -tools::assertError(validObject(new("git_tag", - message = "message1", - name = character(0), - tagger = tagger, - target = "target1"))) - -tools::assertError(validObject(new("git_tag", - message = "message1", - name = c("name1", "name2"), - tagger = tagger, - target = "target1"))) - -tools::assertError(validObject(new("git_tag", - message = "message1", - name = "name1", - tagger = tagger, - target = character(0)))) - -tools::assertError(validObject(new("git_tag", - message = "message1", - name = "name1", - tagger = tagger, - target = c("target1", "target2")))) - ## Create a directory in tempdir path <- tempfile(pattern="git2r-") dir.create(path) @@ -83,18 +39,20 @@ ## Create tag new_tag <- tag(repo, "Tagname", "Tag message") +new_tag +summary(new_tag) ## Check tag -stopifnot(identical(lookup(repo, new_tag@sha), new_tag)) -stopifnot(identical(new_tag@name, "Tagname")) -stopifnot(identical(new_tag@message, "Tag message")) -stopifnot(identical(new_tag@tagger@name, "Alice")) -stopifnot(identical(new_tag@tagger@email, "alice@example.org")) +stopifnot(identical(lookup(repo, sha(new_tag)), new_tag)) +stopifnot(identical(new_tag$name, "Tagname")) +stopifnot(identical(new_tag$message, "Tag message")) +stopifnot(identical(new_tag$tagger$name, "Alice")) +stopifnot(identical(new_tag$tagger$email, "alice@example.org")) stopifnot(identical(length(tags(repo)), 1L)) -stopifnot(identical(tags(repo)[[1]]@name, "Tagname")) -stopifnot(identical(tags(repo)[[1]]@message, "Tag message")) -stopifnot(identical(tags(repo)[[1]]@tagger@name, "Alice")) -stopifnot(identical(tags(repo)[[1]]@tagger@email, "alice@example.org")) +stopifnot(identical(tags(repo)[[1]]$name, "Tagname")) +stopifnot(identical(tags(repo)[[1]]$message, "Tag message")) +stopifnot(identical(tags(repo)[[1]]$tagger$name, "Alice")) +stopifnot(identical(tags(repo)[[1]]$tagger$email, "alice@example.org")) ## Check objects in object database stopifnot(identical(table(odb_objects(repo)$type), @@ -112,10 +70,10 @@ ## Create tag tag(repo, "Tagname", "Tag message") -## Check tags method with missing repo argument +## Check tags method with default repo argument wd <- setwd(path) stopifnot(identical(length(tags()), 1L)) -tag_delete("Tagname") +tag_delete(name = "Tagname") stopifnot(identical(length(tags()), 0L)) if (!is.null(wd)) setwd(wd) diff -Nru r-cran-git2r-0.21.0/tests/time.R r-cran-git2r-0.22.1/tests/time.R --- r-cran-git2r-0.21.0/tests/time.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/time.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,33 +14,14 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() -## Check validity of S4 class git_time -tools::assertError(validObject(new("git_time"))) - -tools::assertError(validObject(new("git_time", - time = numeric(0), - offset = 1))) - -tools::assertError(validObject(new("git_time", - time = c(1, 2), - offset = 1))) - -tools::assertError(validObject(new("git_time", - time = 1, - offset = numeric(0)))) - -tools::assertError(validObject(new("git_time", - time=1, - offset=c(1, 2)))) - ## Test to coerce -git_t <- new("git_time", time=1395567947, offset=60) -stopifnot(identical(as(git_t, "character"), "2014-03-23 10:45:47")) -stopifnot(identical(as(git_t, "POSIXct"), as.POSIXct(1395571547, - origin="1970-01-01", - tz="GMT"))) +git_t <- structure(list(time = 1395567947, offset = 60), + class = "git_time") +stopifnot(identical(as.character(git_t), "2014-03-23 10:45:47")) +stopifnot(identical(as.POSIXct(git_t), + as.POSIXct(1395571547, origin="1970-01-01", tz="GMT"))) diff -Nru r-cran-git2r-0.21.0/tests/tree.R r-cran-git2r-0.22.1/tests/tree.R --- r-cran-git2r-0.21.0/tests/tree.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/tree.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,7 +14,7 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() @@ -37,16 +37,18 @@ commit(repo, "Commit message") ## Check tree -stopifnot(is(lookup(repo, "a0b0b9e615e9e433eb5f11859e9feac4564c58c5"), - "git_tree")) -stopifnot(is(tree(commits(repo)[[1]]), "git_tree")) +stopifnot(is_tree(lookup(repo, "a0b0b9e615e9e433eb5f11859e9feac4564c58c5"))) +stopifnot(is_tree(tree(commits(repo)[[1]]))) stopifnot(identical(lookup(repo, "a0b0b9e615e9e433eb5f11859e9feac4564c58c5"), tree(commits(repo)[[1]]))) stopifnot(identical(length(tree(commits(repo)[[1]])), 1L)) ## Coerce to a data.frame and check column names -stopifnot(identical(names(as(tree(commits(repo)[[1]]), "data.frame")), +stopifnot(identical(names(as.data.frame(tree(commits(repo)[[1]]))), c("mode", "type", "sha", "name"))) +## Check ls_tree +stopifnot(identical(ls_tree(repo = repo), ls_tree(repo = path))) + ## Cleanup unlink(path, recursive=TRUE) diff -Nru r-cran-git2r-0.21.0/tests/when.R r-cran-git2r-0.22.1/tests/when.R --- r-cran-git2r-0.21.0/tests/when.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tests/when.R 2018-06-04 05:14:13.000000000 +0000 @@ -1,5 +1,5 @@ ## git2r, R bindings to the libgit2 library. -## Copyright (C) 2013-2015 The git2r contributors +## Copyright (C) 2013-2018 The git2r contributors ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License, version 2, @@ -14,42 +14,36 @@ ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -library(git2r) +library("git2r") ## For debugging sessionInfo() ## Check when method -stopifnot(identical(when(new("git_commit", - sha = "166f3f779fd7e4165aaa43f2828050ce040052b0", - author = new("git_signature", - name = "Alice", - email = "alice@example.org", - when = new("git_time", time = 1395567947, offset = 60)), - committer = new("git_signature", - name = "Alice", - email = "alice@example.org", - when = new("git_time", time = 1395567950, offset = 60)), - summary = "A commit summary", - message = "A commit message")), - "2014-03-23 10:45:47")) - -stopifnot(identical(when(new("git_signature", - name = "Alice", - email = "alice@example.org", - when = new("git_time", time = 1395567947, offset = 60))), - "2014-03-23 10:45:47")) - -stopifnot(identical(when(new("git_tag", - sha = "166f3f779fd7e4165aaa43f2828050ce040052b0", - message = "A tag message", - name = "A tage name", - tagger = new("git_signature", - name = "Alice", - email = "alice@example.org", - when = new("git_time", time = 1395567947, offset = 60)), - target = "166f3f779fd7e4165aaa43f2828050ce040052b0")), - "2014-03-23 10:45:47")) - -stopifnot(identical(when(new("git_time", time = 1395567947, offset = 60)), - "2014-03-23 10:45:47")) +w1 = structure(list(time = 1395567947, offset = 60), + class = "git_time") +stopifnot(identical(when(w1), "2014-03-23 10:45:47")) + +s1 <- structure(list(name = "Alice", email = "alice@example.org", when = w1), + class = "git_signature") +stopifnot(identical(when(s1), "2014-03-23 10:45:47")) + +w2 = structure(list(time = 1395567950, offset = 60), + class = "git_time") +s2 <- structure(list(name = "Alice", email = "alice@example.org", when = w2), + class = "git_signature") +c1 <- structure(list(sha = "166f3f779fd7e4165aaa43f2828050ce040052b0", + author = s1, + committer = s2, + summary = "A commit summary", + message = "A commit message"), + class = "git_commit") +stopifnot(identical(when(c1), "2014-03-23 10:45:47")) + +t1 <- structure(list(sha = "166f3f779fd7e4165aaa43f2828050ce040052b0", + message = "A tag message", + name = "A tage name", + tagger = s1, + target = "166f3f779fd7e4165aaa43f2828050ce040052b0"), + class = "git_tag") +stopifnot(identical(when(t1), "2014-03-23 10:45:47")) diff -Nru r-cran-git2r-0.21.0/tools/version.c r-cran-git2r-0.22.1/tools/version.c --- r-cran-git2r-0.21.0/tools/version.c 1970-01-01 00:00:00.000000000 +0000 +++ r-cran-git2r-0.22.1/tools/version.c 2018-06-13 21:19:05.000000000 +0000 @@ -0,0 +1,9 @@ +#include + +#if LIBGIT2_VER_MAJOR == 0 +# if LIBGIT2_VER_MINOR < 26 +# error libgit2 version too old +# endif +#else +# error the libgit2 version is not compatible with git2r +#endif diff -Nru r-cran-git2r-0.21.0/tools/winlibs.R r-cran-git2r-0.22.1/tools/winlibs.R --- r-cran-git2r-0.21.0/tools/winlibs.R 2017-07-30 13:39:44.000000000 +0000 +++ r-cran-git2r-0.22.1/tools/winlibs.R 2018-05-25 05:59:51.000000000 +0000 @@ -1,25 +1,10 @@ # We need https if(getRversion() < "3.3.0") setInternet2() +VERSION <- commandArgs(TRUE) -# Download libz -if(!file.exists("../windows/libz-1.2.8/include/zlib.h")){ - download.file("https://github.com/rwinlib/libz/archive/v1.2.8.zip", "lib.zip", quiet = TRUE) - dir.create("../windows", showWarnings = FALSE) - unzip("lib.zip", exdir = "../windows") - unlink("lib.zip") -} - -# Download OpenSSL -if(!file.exists("../windows/openssl-1.0.2d/include/openssl/ssl.h")){ - download.file("https://github.com/rwinlib/openssl/archive/v1.0.2d.zip", "lib.zip", quiet = TRUE) - dir.create("../windows", showWarnings = FALSE) - unzip("lib.zip", exdir = "../windows") - unlink("lib.zip") -} - -# Download libssh2 -if(!file.exists("../windows/libssh2-1.6.0/include/libssh2.h")){ - download.file("https://github.com/rwinlib/libssh2/archive/v1.6.0.zip", "lib.zip", quiet = TRUE) +# Downloads libssh2 + dependencies +if(!file.exists(sprintf("../windows/libgit2-%s/include/git2.h", VERSION))){ + download.file(sprintf("https://github.com/rwinlib/libgit2/archive/v%s.zip", VERSION), "lib.zip", quiet = TRUE) dir.create("../windows", showWarnings = FALSE) unzip("lib.zip", exdir = "../windows") unlink("lib.zip")