1. 01 Feb, 2018 1 commit
  2. 12 Sep, 2017 1 commit
    • features.h: allow building without CMake-generated feature header · 26f531d3
      In commit a390a846 (cmake: move defines into "features.h" header,
      2017-07-01), we have introduced a new "features.h" header. This file is
      being generated by the CMake build system based on how the libgit2 build
      has been configured, replacing the preexisting method of simply setting
      the defines inside of the CMake build system. This was done to help
      splitting up the build instructions into multiple separate
      subdirectories.
      
      An overlooked shortcoming of this approach is that some projects making
      use of libgit2 build the library with custom build systems, without
      making use of CMake. For those users, the introduction of the
      "features.h" file makes their life harder as they would have to also
      generate this file.
      
      Fix this issue by guarding all inclusions of the generated header file
      by the `LIBGIT2_NO_FEATURES_H` define. Like this, other build systems
      can skip the feature header and simply define all used features by
      specifying `-D` flags for the compiler again.
      Patrick Steinhardt committed
  3. 16 Aug, 2017 2 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
  4. 03 Jul, 2017 1 commit
    • Make sure to always include "common.h" first · 0c7f49dd
      Next to including several files, our "common.h" header also declares
      various macros which are then used throughout the project. As such, we
      have to make sure to always include this file first in all
      implementation files. Otherwise, we might encounter problems or even
      silent behavioural differences due to macros or defines not being
      defined as they should be. So in fact, our header and implementation
      files should make sure to always include "common.h" first.
      
      This commit does so by establishing a common include pattern. Header
      files inside of "src" will now always include "common.h" as its first
      other file, separated by a newline from all the other includes to make
      it stand out as special. There are two cases for the implementation
      files. If they do have a matching header file, they will always include
      this one first, leading to "common.h" being transitively included as
      first file. If they do not have a matching header file, they instead
      include "common.h" as first file themselves.
      
      This fixes the outlined problems and will become our standard practice
      for header and source files inside of the "src/" from now on.
      Patrick Steinhardt committed
  5. 28 Feb, 2017 1 commit
    • odb_loose: fsync tests · e6ed0d2f
      Introduce a simple counter that `p_fsync` implements.  This is useful
      for ensuring that `p_fsync` is called when we expect it to be, for
      example when we have enabled an odb backend to perform `fsync`s when
      writing objects.
      Edward Thomson committed
  6. 17 Feb, 2017 1 commit
    • p_snprintf: no need for arguments to a format · cc172642
      `snprintf` requires a _format_ but does not require _arguments_ to the
      format.  eg: `snprintf(buf, 42, "hi")` is perfectly legal.  Expand the
      macro to match.
      
      Without this, `p_sprintf(buf, 42, "hi")` errors with:
      
      ```
      error: expected expression
                      p_snprintf(msg, 42, "hi");
                      ^
      src/unix/posix.h:53:34: note: expanded from macro 'p_snprintf'
                                       ^
      /usr/include/secure/_stdio.h:57:73: note: expanded from macro 'snprintf'
        __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str),
      __VA_ARGS__)
      ```
      Edward Thomson committed
  7. 29 Dec, 2016 1 commit
  8. 18 Nov, 2016 1 commit
    • threads: introduce `git_thread_exit` · 82f15896
      Introduce `git_thread_exit`, which will allow threads to terminate at an
      arbitrary time, returning a `void *`.  On Windows, this means that we
      need to store the current `git_thread` in TLS, so that we can set its
      `return` value when terminating.
      
      We cannot simply use `ExitThread`, since Win32 returns `DWORD`s from
      threads; we return `void *`.
      Edward Thomson committed
  9. 06 Oct, 2016 1 commit
  10. 20 Jun, 2016 5 commits
  11. 16 Mar, 2016 1 commit
  12. 25 Feb, 2016 1 commit
    • nsec: support NDK's crazy nanoseconds · 3d6a42d1
      Android NDK does not have a `struct timespec` in its `struct stat`
      for nanosecond support, instead it has a single nanosecond member inside
      the struct stat itself.  We will use that and use a macro to expand to
      the `st_mtim` / `st_mtimespec` definition on other systems (much like
      the existing `st_mtime` backcompat definition).
      Edward Thomson committed
  13. 23 Feb, 2016 1 commit
  14. 12 Feb, 2016 1 commit
  15. 30 Sep, 2015 1 commit
  16. 30 Jun, 2015 1 commit
  17. 17 Jun, 2015 1 commit
  18. 16 Jun, 2015 2 commits
    • Introduce p_utimes and p_futimes · 121c3171
      Provide functionality to set the time on a filesystem entry,
      using utimes or futimes on POSIX type systems or SetFileTime
      on Win32.
      Edward Thomson committed
    • crlf: tick the index forward to work around racy-git behaviour · c4e6ab5f
      In order to avoid racy-git, we zero out the file size for entries with
      the same timestamp as the index (or during the initial checkout). This
      is the case in a couple of crlf tests, as the code is fast enough to do
      everything in the same second.
      
      As we know that we do not perform the modification just after writing
      out the index, which is what this is designed to work around, tick the
      mtime of the index file such that it doesn't agree with the files
      anymore, and we do not zero out these entries.
      Carlos Martín Nieto committed
  19. 01 May, 2015 1 commit
  20. 03 Nov, 2014 1 commit
  21. 05 Aug, 2014 3 commits
  22. 13 Jul, 2014 1 commit
  23. 20 May, 2014 1 commit
  24. 16 May, 2014 1 commit
  25. 20 Apr, 2014 1 commit
  26. 11 Dec, 2013 1 commit
    • Test cancel from indexer progress callback · 7697e541
      This adds tests that try canceling an indexer operation from
      within the progress callback.
      
      After writing the tests, I wanted to run this under valgrind and
      had a number of errors in that situation because mmap wasn't
      working.  I added a CMake option to force emulation of mmap and
      consolidated the Amiga-specific code into that new place (so we
      don't actually need separate Amiga code now, just have to turn on
      -DNO_MMAP).
      
      Additionally, I made the indexer code propagate error codes more
      reliably than it used to.
      Russell Belfer committed
  27. 21 Apr, 2013 1 commit
  28. 15 Apr, 2013 1 commit
  29. 09 Mar, 2013 1 commit
    • Make tree iterator handle icase equivalence · e40f1c2d
      There is a serious bug in the previous tree iterator implementation.
      If case insensitivity resulted in member elements being equivalent
      to one another, and those member elements were trees, then the
      children of the colliding elements would be processed in sequence
      instead of in a single flattened list.  This meant that the tree
      iterator was not truly acting like a case-insensitive list.
      
      This completely reworks the tree iterator to manage lists with
      case insensitive equivalence classes and advance through the items
      in a unified manner in a single sorted frame.
      
      It is possible that at a future date we might want to update this
      to separate the case insensitive and case sensitive tree iterators
      so that the case sensitive one could be a minimal amount of code
      and the insensitive one would always know what it needed to do
      without checking flags.
      
      But there would be so much shared code between the two, that I'm
      not sure it that's a win.  For now, this gets what we need.
      
      More tests are needed, though.
      Russell Belfer committed
  30. 29 Jan, 2013 1 commit
  31. 08 Jan, 2013 1 commit
  32. 15 Nov, 2012 1 commit
    • Add POSIX compat lstat() variant for win32 · cccacac5
      The existing p_lstat implementation on win32 is not quite POSIX
      compliant when setting errno to ENOTDIR.  This adds an option to
      make is be compliant so that code (such as checkout) that cares
      to have separate behavior for ENOTDIR can use it portably.
      
      This also contains a couple of other minor cleanups in the
      posix_w32.c implementations to avoid unnecessary work.
      Russell Belfer committed