Merge pull request #4632 from pks-t/pks/v0.27.1 Bugfix release v0.27.2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 061e9a6..1c6a5eb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,31 @@
+v0.27.2
+---------
+
+### Changes or improvements
+
+* Fix builds with LibreSSL 2.7.
+
+* Fix for `git_diff_status_char()` not returning the correct mapping for
+ `GIT_DELTA_TYPECHANGE`.
+
+* Fix for the submodules API not reporting errors when parsing the ".gitmodules"
+ file.
+
+* Fix for accepting a ".gitmodules" file where two submodules have the same
+ path.
+
+* Fix for hiding references in a graph walk not always limiting the graph
+ correctly.
+
+* Fix for directory patterns with trailing spaces in attribute files not being
+ handled correctly.
+
+* Fix SSH transports not properly disconnecting from the server.
+
+* Fix reading HEAD reflog in worktrees.
+
+* Update our copy of SHA1DC to fix errors with endianess on some platforms.
+
v0.27.1
---------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ca5354..7c15902 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckStructHasMember)
INCLUDE(AddCFlagIfSupported)
-INCLUDE(FindPkgConfig)
+INCLUDE(FindPkgLibraries)
INCLUDE(FindThreads)
INCLUDE(FindStatNsec)
INCLUDE(IdeSplitSources)
diff --git a/appveyor.yml b/appveyor.yml
index 9b14a9c..f76830c 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -43,6 +43,11 @@ build_script:
if "%GENERATOR%"=="MSYS Makefiles" (C:\MinGW\msys\1.0\bin\sh --login /c/projects/libgit2/script/appveyor-mingw.sh)
test_script:
- ps: |
+ # Disable DHE key exchange to fix intermittent build failures ("A buffer
+ # provided was too small") due to SChannel bug. See e.g.
+ # - https://github.com/aws/aws-sdk-cpp/issues/671
+ # - https://github.com/dotnet/corefx/issues/7812
+ New-Item HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\KeyExchangeAlgorithms\Diffie-Hellman -Force | New-ItemProperty -Name Enabled -Value 0 -Force
$ErrorActionPreference="Stop"
Start-FileDownload https://github.com/ethomson/poxyproxy/releases/download/v0.1.0/poxyproxy-0.1.0.jar -FileName poxyproxy.jar
# Run this early so we know it's ready by the time we need it
diff --git a/cmake/Modules/FindPkgLibraries.cmake b/cmake/Modules/FindPkgLibraries.cmake
new file mode 100644
index 0000000..49311c3
--- /dev/null
+++ b/cmake/Modules/FindPkgLibraries.cmake
@@ -0,0 +1,28 @@
+INCLUDE(FindPkgConfig)
+
+# This function will find and set up a pkg-config based module.
+# If a pc-file was found, it will resolve library paths to
+# absolute paths. Furthermore, the function will automatically
+# fall back to use static libraries in case no dynamic libraries
+# were found.
+FUNCTION(FIND_PKGLIBRARIES prefix package)
+ PKG_CHECK_MODULES(${prefix} ${package})
+ IF(NOT ${prefix}_FOUND)
+ RETURN()
+ ENDIF()
+
+ FOREACH(LIBRARY ${${prefix}_LIBRARIES})
+ FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
+ IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
+ MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
+ ENDIF()
+ LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
+ ENDFOREACH(LIBRARY)
+
+ SET(${prefix}_FOUND 1 PARENT_SCOPE)
+ SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
+ SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
+ SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
+
+ MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
+ENDFUNCTION()
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 99e2ba9..ca7515e 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,4 +1,3 @@
-LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
FILE(GLOB_RECURSE SRC_EXAMPLE_GIT2 network/*.c network/*.h common.?)
diff --git a/include/git2/version.h b/include/git2/version.h
index 93aa3d5..c1b2042 100644
--- a/include/git2/version.h
+++ b/include/git2/version.h
@@ -7,10 +7,10 @@
#ifndef INCLUDE_git_version_h__
#define INCLUDE_git_version_h__
-#define LIBGIT2_VERSION "0.27.1"
+#define LIBGIT2_VERSION "0.27.2"
#define LIBGIT2_VER_MAJOR 0
#define LIBGIT2_VER_MINOR 27
-#define LIBGIT2_VER_REVISION 1
+#define LIBGIT2_VER_REVISION 2
#define LIBGIT2_VER_PATCH 0
#define LIBGIT2_SOVERSION 27
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b03b96a..4cfb2d3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,7 +17,6 @@ SET(LIBGIT2_INCLUDES
"${libgit2_SOURCE_DIR}/src"
"${libgit2_SOURCE_DIR}/include")
SET(LIBGIT2_LIBS "")
-SET(LIBGIT2_LIBDIRS "")
# Installation paths
#
@@ -109,7 +108,6 @@ IF (WIN32 AND WINHTTP)
ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/winhttp" "${libgit2_BINARY_DIR}/deps/winhttp")
LIST(APPEND LIBGIT2_LIBS winhttp)
LIST(APPEND LIBGIT2_INCLUDES "${libgit2_SOURCE_DIR}/deps/winhttp")
- LIST(APPEND LIBGIT2_LIBDIRS ${LIBWINHTTP_PATH})
ELSE()
LIST(APPEND LIBGIT2_LIBS "winhttp")
LIST(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
@@ -119,13 +117,11 @@ IF (WIN32 AND WINHTTP)
LIST(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
ELSE ()
IF (CURL)
- PKG_CHECK_MODULES(CURL libcurl)
+ FIND_PKGLIBRARIES(CURL libcurl)
ENDIF ()
-
IF (CURL_FOUND)
SET(GIT_CURL 1)
LIST(APPEND LIBGIT2_INCLUDES ${CURL_INCLUDE_DIRS})
- LIST(APPEND LIBGIT2_LIBDIRS ${CURL_LIBRARY_DIRS})
LIST(APPEND LIBGIT2_LIBS ${CURL_LIBRARIES})
LIST(APPEND LIBGIT2_PC_LIBS ${CURL_LDFLAGS})
ENDIF()
@@ -282,15 +278,13 @@ ENDIF()
# Optional external dependency: libssh2
IF (USE_SSH)
- PKG_CHECK_MODULES(LIBSSH2 libssh2)
+ FIND_PKGLIBRARIES(LIBSSH2 libssh2)
ENDIF()
IF (LIBSSH2_FOUND)
SET(GIT_SSH 1)
LIST(APPEND LIBGIT2_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${LIBSSH2_LIBRARIES})
- LIST(APPEND LIBGIT2_LIBDIRS ${LIBSSH2_LIBRARY_DIRS})
LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
- #SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}")
CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS)
@@ -404,7 +398,6 @@ ENDIF()
SET(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE)
SET(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE)
SET(LIBGIT2_LIBS ${LIBGIT2_LIBS} PARENT_SCOPE)
-SET(LIBGIT2_LIBDIRS ${LIBGIT2_LIBDIRS} PARENT_SCOPE)
IF(XCODE_VERSION)
# This is required for Xcode to actually link the libgit2 library
@@ -414,7 +407,6 @@ IF(XCODE_VERSION)
ENDIF()
# Compile and link libgit2
-LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
ADD_LIBRARY(git2 ${WIN_RC} ${LIBGIT2_OBJECTS})
TARGET_LINK_LIBRARIES(git2 ${LIBGIT2_LIBS})
diff --git a/src/attr_file.c b/src/attr_file.c
index 55d0c38..f46cce3 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -633,6 +633,11 @@ int git_attr_fnmatch__parse(
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 --git a/src/diff_print.c b/src/diff_print.c
index 28ae384..5e53548 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -130,6 +130,7 @@ char git_diff_status_char(git_delta_t status)
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 --git a/src/hash/sha1dc/sha1.c b/src/hash/sha1dc/sha1.c
index facea1b..25eded1 100644
--- a/src/hash/sha1dc/sha1.c
+++ b/src/hash/sha1dc/sha1.c
@@ -10,6 +10,9 @@
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
+#ifdef __unix__
+#include <sys/types.h> /* make sure macros like _BIG_ENDIAN visible */
+#endif
#endif
#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C
@@ -23,6 +26,13 @@
#include "sha1.h"
#include "ubc_check.h"
+#if (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_ON_INTEL_LIKE_PROCESSOR
+#endif
/*
Because Little-Endian architectures are most common,
@@ -32,29 +42,70 @@
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__)) )
+#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
+/*
+ * Should detect Big Endian under GCC since at least 4.6.0 (gcc svn
+ * rev #165881). See
+ * https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
+ *
+ * This also works under clang since 3.2, it copied the GCC-ism. See
+ * clang.git's 3b198a97d2 ("Preprocessor: add __BYTE_ORDER__
+ * predefined macro", 2012-07-27)
+ */
+#if __BYTE_ORDER__ == __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))
+/* Not under GCC-alike */
+#elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN)
+/*
+ * Should detect Big Endian under glibc.git since 14245eb70e ("entered
+ * into RCS", 1992-11-25). Defined in <endian.h> which will have been
+ * brought in by standard headers. See glibc.git and
+ * https://sourceforge.net/p/predef/wiki/Endianness/
+ */
+#if __BYTE_ORDER == __BIG_ENDIAN
#define SHA1DC_BIGENDIAN
#endif
+/* Not under GCC-alike or glibc */
+#elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN)
+/*
+ * *BSD and newlib (embeded linux, cygwin, etc).
+ * the defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) part prevents
+ * this condition from matching with Solaris/sparc.
+ * (Solaris defines only one endian macro)
+ */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define SHA1DC_BIGENDIAN
#endif
+/* Not under GCC-alike or glibc or *BSD or newlib */
+#elif (defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
+ defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \
+ defined(__sparc))
+/*
+ * Should define Big Endian for a whitelist of known processors. See
+ * https://sourceforge.net/p/predef/wiki/Endianness/ and
+ * http://www.oracle.com/technetwork/server-storage/solaris/portingtosolaris-138514.html
+ */
+#define SHA1DC_BIGENDIAN
+
+/* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */
+#elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
+/*
+ * As a last resort before we do anything else we're not 100% sure
+ * about below, we blacklist specific processors here. We could add
+ * more, see e.g. https://wiki.debian.org/ArchitectureSpecificsMemo
+ */
+#else /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <processor blacklist> */
+
+/* We do nothing more here for now */
+/*#error "Uncomment this to see if you fall through all the detection"*/
+
+#endif /* Big Endian detection */
+
#if (defined(SHA1DC_FORCE_LITTLEENDIAN) && defined(SHA1DC_BIGENDIAN))
#undef SHA1DC_BIGENDIAN
#endif
@@ -63,15 +114,8 @@
#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))
-
+#if defined(SHA1DC_FORCE_UNALIGNED_ACCESS) || defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
#define SHA1DC_ALLOW_UNALIGNED_ACCESS
-
#endif /*UNALIGNMENT DETECTION*/
@@ -918,7 +962,7 @@ static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], co
#ifdef _MSC_VER
#pragma warning(push)
-#pragma warning(disable: 4127) /* Complier complains about the checks in the above macro being constant. */
+#pragma warning(disable: 4127) /* Compiler complains about the checks in the above macro being constant. */
#endif
#ifdef DOSTORESTATE0
diff --git a/src/ignore.c b/src/ignore.c
index dddd7e8..76b9972 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -213,16 +213,6 @@ static int parse_ignore_file(
if (ignore_case)
match->flags |= GIT_ATTR_FNMATCH_ICASE;
- while (match->length > 0) {
- if (match->pattern[match->length - 1] == ' ' ||
- match->pattern[match->length - 1] == '\t') {
- match->pattern[match->length - 1] = 0;
- match->length --;
- } else {
- break;
- }
- }
-
scan = git__next_line(scan);
/*
diff --git a/src/odb_mempack.c b/src/odb_mempack.c
index a81716e..e351d4d 100644
--- a/src/odb_mempack.c
+++ b/src/odb_mempack.c
@@ -157,6 +157,7 @@ static void impl__free(git_odb_backend *_backend)
{
struct memory_packer_db *db = (struct memory_packer_db *)_backend;
+ git_mempack_reset(_backend);
git_oidmap_free(db->objects);
git__free(db);
}
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index a739c43..83174e8 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -1603,6 +1603,8 @@ static int create_new_reflog_file(const char *filepath)
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);
}
diff --git a/src/refs.c b/src/refs.c
index 550963e..c429683 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -115,6 +115,9 @@ int git_reference_dup(git_reference **dest, git_reference *source)
GITERR_CHECK_ALLOC(*dest);
+ (*dest)->db = source->db;
+ GIT_REFCOUNT_INC((*dest)->db);
+
return 0;
}
diff --git a/src/refs.h b/src/refs.h
index 5149c75..84daf8b 100644
--- a/src/refs.h
+++ b/src/refs.h
@@ -116,6 +116,10 @@ int git_reference_lookup_resolved(
* 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 --git a/src/refspec.c b/src/refspec.c
index 01a77c9..943a9c7 100644
--- a/src/refspec.c
+++ b/src/refspec.c
@@ -304,6 +304,7 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
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 @@ int git_refspec__dwim_one(git_vector *out, git_refspec *spec, git_vector *refs)
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 --git a/src/remote.c b/src/remote.c
index 4d675af..d8a6b99 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -237,7 +237,7 @@ static int create_internal(git_remote **out, git_repository *repo, const char *n
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 (repo && (error = lookup_remote_prune_config(remote, config_ro, name)) < 0)
diff --git a/src/revwalk.c b/src/revwalk.c
index b1aa8f9..eb228a5 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -375,20 +375,6 @@ static int add_parents_to_list(git_revwalk *walk, git_commit_list_node *commit,
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 @@ static int still_interesting(git_commit_list *list, int64_t time, int slop)
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 --git a/src/streams/openssl.c b/src/streams/openssl.c
index 9cbb274..adcb7f1 100644
--- a/src/streams/openssl.c
+++ b/src/streams/openssl.c
@@ -104,7 +104,8 @@ int git_openssl_stream_global_init(void)
ssl_opts |= SSL_OP_NO_COMPRESSION;
#endif
-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
+ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
#else
diff --git a/src/streams/openssl.h b/src/streams/openssl.h
index 2bbad7c..44329ec 100644
--- a/src/streams/openssl.h
+++ b/src/streams/openssl.h
@@ -31,7 +31,8 @@ extern int git_openssl__set_cert_location(const char *file, const char *path);
-# if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
+# 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)
{
diff --git a/src/submodule.c b/src/submodule.c
index 32e199c..4bf74dc 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -91,7 +91,7 @@ __KHASH_IMPL(
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);
@@ -186,6 +186,13 @@ static int load_submodule_names(git_strmap *out, git_repository *repo, git_confi
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);
@@ -544,8 +551,11 @@ int git_submodule__map(git_repository *repo, git_strmap *map)
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(
@@ -1552,7 +1562,8 @@ int git_submodule_reload(git_submodule *sm, int force)
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);
@@ -1962,32 +1973,37 @@ static int submodule_load_from_wd_lite(git_submodule *sm)
}
/**
- * 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 (mods) {
- git_config_snapshot(&snap, mods);
+ if ((error = git_config_snapshot(snap, mods)) < 0)
+ goto cleanup;
+
+ error = 0;
+
+cleanup:
+ if (mods)
git_config_free(mods);
- }
+ git_buf_free(&path);
- return snap;
+ return error;
}
static git_config_backend *open_gitmodules(
diff --git a/src/transports/local.c b/src/transports/local.c
index 740cf36..541c552 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -510,8 +510,14 @@ static int local_counting(int stage, unsigned int current, unsigned int total, v
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;
+ }
- int error = git_revwalk_hide(walk, git_reference_target(reference));
+ 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) {
diff --git a/src/transports/ssh.c b/src/transports/ssh.c
index dcd9b5e..23c6433 100644
--- a/src/transports/ssh.c
+++ b/src/transports/ssh.c
@@ -212,6 +212,7 @@ static void ssh_stream_free(git_smart_subtransport_stream *stream)
}
if (s->session) {
+ libssh2_session_disconnect(s->session, "closing transport");
libssh2_session_free(s->session);
s->session = NULL;
}
@@ -489,7 +490,7 @@ static int _git_ssh_session_create(
}
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 --git a/src/util.c b/src/util.c
index 34841df..2955b7c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -10,7 +10,12 @@
#include "common.h"
#ifdef GIT_WIN32
+# include "win32/utf-conv.h"
# include "win32/w32_buffer.h"
+
+# ifdef HAVE_QSORT_S
+# include <search.h>
+# endif
#endif
#ifdef _MSC_VER
diff --git a/src/worktree.c b/src/worktree.c
index 4b18db7..9152766 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -131,7 +131,7 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
goto out;
}
- if ((wt = git__calloc(1, sizeof(struct git_repository))) == NULL) {
+ if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
error = -1;
goto out;
}
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 775f33f..82bf6d0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -9,6 +9,7 @@ SET(CLAR_FIXTURES "${CMAKE_CURRENT_SOURCE_DIR}/resources/")
SET(CLAR_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
ADD_DEFINITIONS(-DCLAR_FIXTURE_PATH=\"${CLAR_FIXTURES}\")
ADD_DEFINITIONS(-DCLAR_TMPDIR=\"libgit2_tests\")
+ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
INCLUDE_DIRECTORIES(${CLAR_PATH} ${libgit2_BINARY_DIR}/src)
FILE(GLOB_RECURSE SRC_TEST ${CLAR_PATH}/*/*.c ${CLAR_PATH}/*/*.h)
@@ -30,7 +31,6 @@ SET_SOURCE_FILES_PROPERTIES(
${CLAR_PATH}/clar.c
PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clar.suite)
-LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
ADD_EXECUTABLE(libgit2_clar ${SRC_CLAR} ${SRC_TEST} ${LIBGIT2_OBJECTS})
diff --git a/tests/attr/ignore.c b/tests/attr/ignore.c
index d241c03..165e2ba 100644
--- a/tests/attr/ignore.c
+++ b/tests/attr/ignore.c
@@ -61,6 +61,22 @@ void test_attr_ignore__ignore_space(void)
assert_is_ignored(true, "NewFolder/NewFolder/File.txt");
}
+void test_attr_ignore__ignore_dir(void)
+{
+ cl_git_rewritefile("attr/.gitignore", "dir/\n");
+
+ assert_is_ignored(true, "dir");
+ assert_is_ignored(true, "dir/file");
+}
+
+void test_attr_ignore__ignore_dir_with_trailing_space(void)
+{
+ cl_git_rewritefile("attr/.gitignore", "dir/ \n");
+
+ assert_is_ignored(true, "dir");
+ assert_is_ignored(true, "dir/file");
+}
+
void test_attr_ignore__ignore_root(void)
{
cl_git_rewritefile("attr/.gitignore", "/\n\n/NewFolder\n/NewFolder/NewFolder");
diff --git a/tests/checkout/typechange.c b/tests/checkout/typechange.c
index 8a5110c..647b534 100644
--- a/tests/checkout/typechange.c
+++ b/tests/checkout/typechange.c
@@ -1,4 +1,5 @@
#include "clar_libgit2.h"
+#include "diff_generate.h"
#include "git2/checkout.h"
#include "path.h"
#include "posix.h"
@@ -307,3 +308,28 @@ void test_checkout_typechange__checkout_with_conflicts(void)
git_object_free(obj);
}
}
+
+void test_checkout_typechange__status_char(void)
+{
+ size_t i;
+ git_oid oid;
+ git_commit *commit;
+ git_diff *diff;
+ const git_diff_delta *delta;
+ git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
+ char expected[8] = {'M', 'M', 'R', 'T', 'D', 'R', 'A', 'R'};
+
+ git_oid_fromstr(&oid, "9b19edf33a03a0c59cdfc113bfa5c06179bf9b1a");
+ cl_git_pass(git_commit_lookup(&commit, g_repo, &oid));
+ diffopts.flags |= GIT_DIFF_INCLUDE_TYPECHANGE;
+ cl_git_pass(git_diff__commit(&diff, g_repo, commit, &diffopts));
+ cl_git_pass(git_diff_find_similar(diff, NULL));
+
+ for (i = 0; i < git_diff_num_deltas(diff); i++) {
+ delta = git_diff_get_delta(diff, i);
+ cl_assert_equal_i(expected[i], git_diff_status_char(delta->status));
+ }
+
+ git_diff_free(diff);
+ git_commit_free(commit);
+}
diff --git a/tests/diff/stats.c b/tests/diff/stats.c
index 3171a44..347d0d7 100644
--- a/tests/diff/stats.c
+++ b/tests/diff/stats.c
@@ -254,7 +254,7 @@ void test_diff_stats__rename_nochanges_no_find(void)
git_buf_free(&buf);
}
-void test_diff_stats__rename_and_modifiy_no_find(void)
+void test_diff_stats__rename_and_modify_no_find(void)
{
git_buf buf = GIT_BUF_INIT;
const char *stat =
diff --git a/tests/fetchhead/nonetwork.c b/tests/fetchhead/nonetwork.c
index 4dabb57..a639460 100644
--- a/tests/fetchhead/nonetwork.c
+++ b/tests/fetchhead/nonetwork.c
@@ -343,6 +343,29 @@ void test_fetchhead_nonetwork__unborn_with_upstream(void)
cl_fixture_cleanup("./repowithunborn");
}
+void test_fetchhead_nonetwork__fetch_into_repo_with_symrefs(void)
+{
+ git_repository *repo;
+ git_remote *remote;
+ git_reference *symref;
+
+ repo = cl_git_sandbox_init("empty_standard_repo");
+
+ /*
+ * Testing for a specific constellation where the repository has at
+ * least one symbolic reference in its refdb.
+ */
+ cl_git_pass(git_reference_symbolic_create(&symref, repo, "refs/heads/symref", "refs/heads/master", 0, NULL));
+
+ cl_git_pass(git_remote_set_url(repo, "origin", cl_fixture("testrepo.git")));
+ cl_git_pass(git_remote_lookup(&remote, repo, "origin"));
+ cl_git_pass(git_remote_fetch(remote, NULL, NULL, NULL));
+
+ git_remote_free(remote);
+ git_reference_free(symref);
+ cl_git_sandbox_cleanup();
+}
+
void test_fetchhead_nonetwork__quote_in_branch_name(void)
{
cl_set_cleanup(&cleanup_repository, "./test1");
diff --git a/tests/refs/dup.c b/tests/refs/dup.c
index 0fc635a..8a89cd9 100644
--- a/tests/refs/dup.c
+++ b/tests/refs/dup.c
@@ -21,6 +21,7 @@ void test_refs_dup__direct(void)
cl_git_pass(git_reference_dup(&b, a));
cl_assert(git_reference_cmp(a, b) == 0);
+ cl_assert(git_reference_owner(b) == g_repo);
git_reference_free(b);
git_reference_free(a);
@@ -34,6 +35,7 @@ void test_refs_dup__symbolic(void)
cl_git_pass(git_reference_dup(&b, a));
cl_assert(git_reference_cmp(a, b) == 0);
+ cl_assert(git_reference_owner(b) == g_repo);
git_reference_free(b);
git_reference_free(a);
diff --git a/tests/resources/revwalk.git/HEAD b/tests/resources/revwalk.git/HEAD
new file mode 100644
index 0000000..cb089cd
--- /dev/null
+++ b/tests/resources/revwalk.git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests/resources/revwalk.git/config b/tests/resources/revwalk.git/config
new file mode 100644
index 0000000..7c968c3
--- /dev/null
+++ b/tests/resources/revwalk.git/config
@@ -0,0 +1,6 @@
+[core]
+ bare = true
+ repositoryformatversion = 0
+ filemode = false
+ symlinks = false
+ ignorecase = true
diff --git a/tests/resources/revwalk.git/description b/tests/resources/revwalk.git/description
new file mode 100644
index 0000000..498b267
--- /dev/null
+++ b/tests/resources/revwalk.git/description
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.
diff --git a/tests/resources/revwalk.git/objects/info/packs b/tests/resources/revwalk.git/objects/info/packs
new file mode 100644
index 0000000..d8d85b8
--- /dev/null
+++ b/tests/resources/revwalk.git/objects/info/packs
@@ -0,0 +1,2 @@
+P pack-9adacb9971981a1a3264fd473da5b800f2715959.pack
+
diff --git a/tests/resources/revwalk.git/objects/pack/pack-9adacb9971981a1a3264fd473da5b800f2715959.idx b/tests/resources/revwalk.git/objects/pack/pack-9adacb9971981a1a3264fd473da5b800f2715959.idx
new file mode 100644
index 0000000..e157b38
Binary files /dev/null and b/tests/resources/revwalk.git/objects/pack/pack-9adacb9971981a1a3264fd473da5b800f2715959.idx differ
diff --git a/tests/resources/revwalk.git/objects/pack/pack-9adacb9971981a1a3264fd473da5b800f2715959.pack b/tests/resources/revwalk.git/objects/pack/pack-9adacb9971981a1a3264fd473da5b800f2715959.pack
new file mode 100644
index 0000000..2a61f94
Binary files /dev/null and b/tests/resources/revwalk.git/objects/pack/pack-9adacb9971981a1a3264fd473da5b800f2715959.pack differ
diff --git a/tests/resources/revwalk.git/packed-refs b/tests/resources/revwalk.git/packed-refs
new file mode 100644
index 0000000..905a3db
--- /dev/null
+++ b/tests/resources/revwalk.git/packed-refs
@@ -0,0 +1,7 @@
+# pack-refs with: peeled fully-peeled sorted
+3ae0f53011bdb7e68f99bde4943449f36c1c318a refs/heads/A
+061978578d7c9ff2ba92dd36d31fd8d809871030 refs/heads/B
+743398b425d6c216d6cfaae3786b5bc436393ae5 refs/heads/C
+790ba0facf6fd103699a5c40cd19dad277ff49cd refs/heads/D
+d3d783066cf7d95def6844b9c5118c1e7bcce7df refs/heads/E
+d3d783066cf7d95def6844b9c5118c1e7bcce7df refs/heads/master
diff --git a/tests/resources/revwalk.git/refs/.gitkeep b/tests/resources/revwalk.git/refs/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/resources/revwalk.git/refs/.gitkeep
diff --git a/tests/revwalk/basic.c b/tests/revwalk/basic.c
index 6a23701..1106bf4 100644
--- a/tests/revwalk/basic.c
+++ b/tests/revwalk/basic.c
@@ -555,3 +555,30 @@ void test_revwalk_basic__old_hidden_commit_two(void)
cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk));
}
+
+/*
+ * Ensure that we correctly hide all parent commits of a newer
+ * commit when first hiding older commits.
+ *
+ * % git rev-list D ^B ^A ^E
+ * 790ba0facf6fd103699a5c40cd19dad277ff49cd
+ * b82cee5004151ae0c4f82b69fb71b87477664b6f
+ */
+void test_revwalk_basic__newer_hidden_commit_hides_old_commits(void)
+{
+ git_oid oid;
+
+ revwalk_basic_setup_walk("revwalk.git");
+
+ cl_git_pass(git_revwalk_push_ref(_walk, "refs/heads/D"));
+ cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/B"));
+ cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/A"));
+ cl_git_pass(git_revwalk_hide_ref(_walk, "refs/heads/E"));
+
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ cl_assert(git_oid_streq(&oid, "b82cee5004151ae0c4f82b69fb71b87477664b6f"));
+ cl_git_pass(git_revwalk_next(&oid, _walk));
+ cl_assert(git_oid_streq(&oid, "790ba0facf6fd103699a5c40cd19dad277ff49cd"));
+
+ cl_git_fail_with(GIT_ITEROVER, git_revwalk_next(&oid, _walk));
+}
diff --git a/tests/submodule/lookup.c b/tests/submodule/lookup.c
index f84f07c..f73ca26 100644
--- a/tests/submodule/lookup.c
+++ b/tests/submodule/lookup.c
@@ -132,6 +132,27 @@ void test_submodule_lookup__foreach(void)
cl_assert_equal_i(8, data.count);
}
+static int foreach_cb(git_submodule *sm, const char *name, void *payload)
+{
+ GIT_UNUSED(sm);
+ GIT_UNUSED(name);
+ GIT_UNUSED(payload);
+ return 0;
+}
+
+void test_submodule_lookup__duplicated_path(void)
+{
+ cl_git_rewritefile("submod2/.gitmodules",
+ "[submodule \"sm1\"]\n"
+ " path = duplicated-path\n"
+ " url = sm1\n"
+ "[submodule \"sm2\"]\n"
+ " path = duplicated-path\n"
+ " url = sm2\n");
+
+ cl_git_fail(git_submodule_foreach(g_repo, foreach_cb, NULL));
+}
+
void test_submodule_lookup__lookup_even_with_unborn_head(void)
{
git_reference *head;
@@ -430,14 +451,6 @@ void test_submodule_lookup__lookup_in_bare_repository_fails(void)
cl_git_fail(git_submodule_lookup(&sm, g_repo, "nonexisting"));
}
-static int foreach_cb(git_submodule *sm, const char *name, void *payload)
-{
- GIT_UNUSED(sm);
- GIT_UNUSED(name);
- GIT_UNUSED(payload);
- return 0;
-}
-
void test_submodule_lookup__foreach_in_bare_repository_fails(void)
{
cl_git_sandbox_cleanup();
@@ -445,3 +458,19 @@ void test_submodule_lookup__foreach_in_bare_repository_fails(void)
cl_git_fail(git_submodule_foreach(g_repo, foreach_cb, NULL));
}
+
+void test_submodule_lookup__fail_invalid_gitmodules(void)
+{
+ git_submodule *sm;
+ sm_lookup_data data;
+ memset(&data, 0, sizeof(data));
+
+ cl_git_rewritefile("submod2/.gitmodules",
+ "[submodule \"Test_App\"\n"
+ " path = Test_App\n"
+ " url = ../Test_App\n");
+
+ cl_git_fail(git_submodule_lookup(&sm, g_repo, "Test_App"));
+
+ cl_git_fail(git_submodule_foreach(g_repo, sm_lookup_cb, &data));
+}
diff --git a/tests/worktree/reflog.c b/tests/worktree/reflog.c
index 6152eb3..a68e72d 100644
--- a/tests/worktree/reflog.c
+++ b/tests/worktree/reflog.c
@@ -22,6 +22,32 @@ void test_worktree_reflog__cleanup(void)
cleanup_fixture_worktree(&fixture);
}
+void test_worktree_reflog__read_worktree_HEAD(void)
+{
+ git_reflog *reflog;
+ const git_reflog_entry *entry;
+
+ cl_git_pass(git_reflog_read(&reflog, fixture.worktree, "HEAD"));
+ cl_assert_equal_i(1, git_reflog_entrycount(reflog));
+
+ entry = git_reflog_entry_byindex(reflog, 0);
+ cl_assert(entry != NULL);
+ cl_assert_equal_s("checkout: moving from 099fabac3a9ea935598528c27f866e34089c2eff to testrepo-worktree", git_reflog_entry_message(entry));
+
+ git_reflog_free(reflog);
+}
+
+void test_worktree_reflog__read_parent_HEAD(void)
+{
+ git_reflog *reflog;
+
+ cl_git_pass(git_reflog_read(&reflog, fixture.repo, "HEAD"));
+ /* there is no logs/HEAD in the parent repo */
+ cl_assert_equal_i(0, git_reflog_entrycount(reflog));
+
+ git_reflog_free(reflog);
+}
+
void test_worktree_reflog__read(void)
{
git_reflog *reflog;
diff --git a/tests/worktree/repository.c b/tests/worktree/repository.c
index 5c7595c..ca56413 100644
--- a/tests/worktree/repository.c
+++ b/tests/worktree/repository.c
@@ -27,6 +27,7 @@ void test_worktree_repository__head(void)
cl_git_pass(git_reference_lookup(&ref, fixture.repo, "refs/heads/testrepo-worktree"));
cl_git_pass(git_repository_head_for_worktree(&head, fixture.repo, "testrepo-worktree"));
cl_assert(git_reference_cmp(ref, head) == 0);
+ cl_assert(git_reference_owner(ref) == fixture.repo);
git_reference_free(ref);
git_reference_free(head);