1. 26 Mar, 2020 4 commits
  2. 25 Jan, 2019 1 commit
  3. 22 Jan, 2019 1 commit
  4. 09 Jan, 2019 1 commit
  5. 13 Nov, 2018 1 commit
    • tests: address two null argument instances · f127ce35
      Handle two null argument cases that occur in the unit tests.
      One is in library code, the other is in test code.
      
      Detected by running unit tests with undefined behavior sanitizer:
      ```bash
       # build
      mkdir build && cd build
      cmake -DBUILD_CLAR=ON -DCMAKE_C_FLAGS="-fsanitize=address \
      -fsanitize=undefined -fstack-usage -static-libasan" ..
      cmake --build .
      
       # run with asan
      ASAN_OPTIONS="allocator_may_return_null=1" ./libgit2_clar
      ...
      ............../libgit2/src/apply.c:316:3: runtime error: null pointer \
      passed as argument 1, which is declared to never be null
      ...................../libgit2/tests/apply/fromfile.c:46:3: runtime \
      error: null pointer passed as argument 1, which is declared to never be null
      ```
      Noah Pendleton committed
  6. 05 Nov, 2018 14 commits
    • apply: test re-adding a file after removing it · f8b9493b
      Ensure that we can add a file back after it's been removed.  Update the
      renamed/deleted validation in application to not apply to deltas that
      are adding files to support this.
      Edward Thomson committed
    • apply: test modifying a file after renaming it · 78580ad3
      Ensure that we cannot modify a file after it's been renamed out of the
      way.  If multiple deltas exist for a single path, ensure that we do not
      attempt to modify a file after it's been renamed out of the way.
      
      To support this, we must track the paths that have been removed or
      renamed; add to a string map when we remove a path and remove from the
      string map if we recreate a path.  Validate that we are not applying to
      a path that is in this map, unless the delta is a rename, since git
      supports renaming one file to two different places in two different
      deltas.
      
      Further, test that we cannot apply a modification delta to a path that
      will be created in the future by a rename (a path that does not yet
      exist.)
      Edward Thomson committed
    • apply: handle multiple deltas to the same file · df4258ad
      git allows a patch file to contain multiple deltas to the same file:
      although it does not produce files in this format itself, this could
      be the result of concatenating two different patch files that affected
      the same file.
      
      git apply behaves by applying this next delta to the existing postimage
      of the file.  We should do the same.  If we have previously seen a file,
      and produced a postimage for it, we will load that postimage and apply
      the current delta to that.  If we have not, get the file from the
      preimage.
      Edward Thomson committed
    • apply: handle exact renames · 6fecf4d1
      Deltas containing exact renames are special; they simple indicate that a
      file was renamed without providing additional metadata (like the
      filemode).  Teach the reader to provide the file mode and use the
      preimage's filemode in the case that the delta does not provide one.)
      Edward Thomson committed
    • apply: introduce a hunk callback · 47cc5f85
      Introduce a callback to patch application that allows consumers to
      cancel hunk application.
      Edward Thomson committed
    • apply: introduce a delta callback · af33210b
      Introduce a callback to the application options that allow callers to
      add a per-delta callback.  The callback can return an error code to stop
      patch application, or can return a value to skip the application of a
      particular delta.
      Edward Thomson committed
    • apply: move location to an argument, not the opts · 37b25ac5
      Move the location option to an argument, out of the options structure.
      This allows the options structure to be re-used for functions that don't
      need to know the location, since it's implicit in their functionality.
      For example, `git_apply_tree` should not take a location, but is
      expected to take all the other options.
      Edward Thomson committed
    • apply: use an indexwriter · 2d27ddc0
      Place the entire `git_apply` operation inside an indexwriter, so that we
      lock the index before we begin performing patch application.  This
      ensures that there are no other processes modifying things in the
      working directory.
      Edward Thomson committed
    • apply: validate workdir contents match index for BOTH · 813f0802
      When applying to both the index and the working directory, ensure that
      the index contents match the working directory.  This mirrors the
      requirement in `git apply --index`.
      
      This also means that - along with the prior commit that uses the working
      directory contents as the checkout baseline - we no longer expect
      conflicts during checkout.  So remove the special-case error handling
      for checkout conflicts.  (Any checkout conflict now would be because the
      file was actually modified between the start of patch application and
      the checkout.)
      Edward Thomson committed
    • reader: optionally validate index matches workdir · 0f4b2f02
      When using a workdir reader, optionally validate that the index contents
      match the working directory contents.
      Edward Thomson committed
    • apply: use preimage as the checkout baseline · 5b8d5a22
      Use the preimage as the checkout's baseline.  This allows us to support
      applying patches to files that are modified in the working directory
      (those that differ from the HEAD and index).  Without this, files will
      be reported as (checkout) conflicts.  With this, we expect the on-disk
      data when we began the patch application (the "preimage") to be on-disk
      during checkout.
      
      We could have also simply used the `FORCE` flag to checkout to
      accomplish a similar mechanism.  However, `FORCE` ignores all
      differences, while providing a preimage ensures that we will only
      overwrite the file contents that we actually read.
      
      Modify the reader interface to provide the OID to support this.
      Edward Thomson committed
    • apply: convert checkout conflicts to apply failures · dddfff77
      When there's a checkout conflict during apply, that means that the
      working directory was modified in a conflicting manner and the postimage
      cannot be written.  During application, convert this to an application
      failure for consistency across workdir/index/both applications.
      Edward Thomson committed
    • apply: when preimage file is missing, return EAPPLYFAIL · 5b66b667
      The preimage file being missing entirely is simply a case of an
      application failure; return the correct error value for the caller.
      Edward Thomson committed
    • apply: simplify checkout vs index application · e0224121
      Separate the concerns of applying via checkout and updating the
      repository's index.  This results in simpler functionality and allows us
      to not build the temporary collection of paths in the index case.
      Edward Thomson committed
  7. 04 Nov, 2018 6 commits
  8. 03 Nov, 2018 1 commit
  9. 10 Jun, 2018 1 commit
  10. 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
  11. 29 Dec, 2016 1 commit
  12. 14 Nov, 2016 1 commit
  13. 05 Sep, 2016 1 commit
  14. 05 Aug, 2016 1 commit
  15. 24 Jul, 2016 2 commits
  16. 26 May, 2016 3 commits