1. 16 Aug, 2017 7 commits
    • cmake: move regcomp and futimens checks to "features.h" · 8341d6cf
      In our CMakeLists.txt, we have to check multiple functions in order to
      determine if we have to use our own or whether we can use the
      platform-provided one. For two of these functions, namely `regcomp_l()`
      and `futimens`, the defined macro is actually used inside of the header
      file "src/unix/posix.h". As such, these macros are not only required by
      the library, but also by our test suite, which is makes use of internal
      headers.
      
      To prepare for the CMakeLists.txt split, move these two defines inside
      of the "features.h" header.
      Patrick Steinhardt committed
    • cmake: move defines into "features.h" header · a390a846
      In a future commit, we will split out the build instructions for our
      library directory and move them into a subdirectory. One of the benefits
      is fixing scoping issues, where e.g. defines do not leak to build
      targets where they do not belong to. But unfortunately, this does also
      pose the problem of how to propagate some defines which are required by
      both the library and the test suite.
      
      One way would be to create another variable keeping track of all added
      defines and declare it inside of the parent scope. While this is the
      most obvious and simplest way of going ahead, it is kind of unfortunate.
      The main reason to not use this is that these defines become implicit
      dependencies between the build targets. By simply observing a define
      inside of the CMakeLists.txt file, one cannot reason whether this define
      is only required by the current target or whether it is required by
      different targets, as well.
      
      Another approach would be to use an internal header file keeping track
      of all defines shared between targets. While configuring the library, we
      will set various variables and let CMake configure the file, adding or
      removing defines based on what has been configured. Like this, one can
      easily keep track of the current environment by simply inspecting the
      header file. Furthermore, these dependencies are becoming clear inside
      the CMakeLists.txt, as instead of simply adding a define, we now call
      e.g. `SET(GIT_THREADSAFE 1)`.
      
      Having this header file though requires us to make sure it is always
      included before any "#ifdef"-preprocessor checks are executed. As we
      have already refactored code to always include the "common.h" header
      file before any statement inside of a file, this becomes easy: just make
      sure "common.h" includes the new "features.h" header file first.
      Patrick Steinhardt committed
    • cmake: create separate CMakeLists.txt for tests · 35087f0e
      Our CMakeLists.txt is very unwieldy in its current size, spanning more
      than 700 lines of code. Furthermore, it has several issues regarding
      scoping, where for example some defines, includes, etc. from our test
      suite are also applied to our normal library code.
      
      To fix this, we can separate out build instructions for our tests and
      move them into their own CMakeLists.txt in the "tests" directory. This
      reduced complexity of the root CMakeLists.txt file and fixes the issues
      regarding leaking build context from tests into the library.
      Patrick Steinhardt committed
    • cmake: create own precompiled headers for tests · 3267115f
      As soon as we split up our CMakeBuild.txt build instructions, we will be
      unable to simply link against the git2 library's precompiled header from
      other targets. To avoid this future breakage, create a new precompiled
      header for our test suite. Next to being compatible with the split, this
      enables us to also include additional files like the clar headers, which
      may help speeding up compilation of the test suite.
      Patrick Steinhardt committed
    • cmake: create object library target · caab8270
      Currently, we're compiling our library code twice, once as part of the
      libgit2 library and once for the libgit2_clar executable. Since CMake
      2.8.8, there exists a new library type OBJECT, which represents an
      intermediate target which can then subsequently be used when linking
      several targets against the same set of objects.
      
      Use an OBJECT library to create an internal library for linking. This
      new target is only used on CMake v2.8.8 or newer. As CMake 3.0 changed
      the way how generator expressions are evaluated when accessing
      properties, we need to enable CMake policy 0051 to keep
      `IDE_SPLIT_SOURCES` functioning.
      Patrick Steinhardt committed
    • cmake: remove unused variable "CLAR_RESOURCES" · f33911e5
      Once upon a time, the `CLAR_RESOURCES` variable was intended to set
      the `CLAR_RESOURCES` define. But actually, the define uses a wrong
      variable name by accident, hinting that its value cannot actually be
      used at all, as it is empty. Searching through the code base confirms
      the guess that the define is not used at all.
      
      Remove both the variable and definition.
      Patrick Steinhardt committed
    • cmake: try to detect threads library · 096a49c0
      While we already make use of the variable `${CMAKE_THREAD_LIBS_INIT}`,
      it is actually undefined due to us never including the "FindThreads"
      module in the CMakeLists.txt. It is rather curious as to why this has
      never triggered any error up to now, but it does in fact result in
      linking errors on some Unix platforms as soon as we split up our build
      instructions into multiple files.
      
      Fix the issue now to avoid future breakage by including the
      "FindThreads" module.
      Patrick Steinhardt committed
  2. 15 Aug, 2017 1 commit
  3. 14 Aug, 2017 4 commits
  4. 11 Aug, 2017 1 commit
  5. 09 Aug, 2017 3 commits
    • oid: use memcmp in git_oid__hashcmp · c9b1e646
      The open-coded version was inherited from git.git. But it
      turns out it was based on an older version of glibc, whose
      memcmp was not very optimized.
      
      Modern glibc does much better, and some compilers (like gcc
      7) can even inline the memcmp into a series of multi-byte
      xors.
      
      Upstream is switching to using memcmp in
      git/git@0b006014c87f400bd9a86267ed30fd3e7b383884.
      Jeff King committed
    • sha1_lookup: drop sha1_entry_pos function · 9842b327
      This was pulled over from git.git, and is an experiment in
      making binary-searching lists of sha1s faster. It was never
      compiled by default (nor was it used upstream by default
      without a special environment variable).
      
      Unfortunately, it is actually slower in practice, and
      upstream is planning to drop it in
      git/git@f1068efefe6dd3beaa89484db5e2db730b094e0b (which has
      some timing results). It's worth doing the same here for
      simplicity.
      Jeff King committed
    • sha1_position: convert do-while to while · 09930192
      If we enter the sha1_position() function with "lo == hi",
      we have no elements. But the do-while loop means that we'll
      enter the loop body once anyway, picking "mi" at that same
      value and comparing nonsense to our desired key. This is
      unlikely to match in practice, but we still shouldn't be
      looking at the memory in the first place.
      
      This bug is inherited from git.git; it was fixed there in
      e01580cfe01526ec2c4eb4899f776a82ade7e0e1.
      Jeff King committed
  6. 31 Jul, 2017 2 commits
  7. 30 Jul, 2017 3 commits
  8. 28 Jul, 2017 2 commits
  9. 27 Jul, 2017 1 commit
  10. 26 Jul, 2017 6 commits
  11. 25 Jul, 2017 1 commit
  12. 24 Jul, 2017 4 commits
  13. 21 Jul, 2017 1 commit
  14. 20 Jul, 2017 1 commit
  15. 19 Jul, 2017 2 commits
  16. 15 Jul, 2017 1 commit
    • config_file: refuse modifying included variables · 1b329089
      Modifying variables pulled in by an included file currently succeeds,
      but it doesn't actually do what one would expect, as refreshing the
      configuration will cause the values to reappear. As we are currently not
      really able to support this use case, we will instead just return an
      error for deleting and setting variables which were included via an
      include.
      Patrick Steinhardt committed