1. 09 Oct, 2012 1 commit
    • Introduce status/diff TYPECHANGE flags · bc16fd3e
      When I wrote the diff code, I based it on core git's diff output
      which tends to split a type change into an add and a delete.  But
      core git's status has the notion of a T (typechange) flag for a
      file.  This introduces that into our status APIs and modifies the
      diff code so it can be forced to not split type changes.
      Russell Belfer committed
  2. 08 Oct, 2012 2 commits
    • Add test for diffs with submodules and bug fixes · 5d1308f2
      The adds a test for the submodule diff capabilities and then
      fixes a few bugs with how the output is generated.  It improves
      the accuracy of OIDs in the diff delta object and makes the
      submodule output more closely mirror the OIDs that will be used
      by core git.
      Russell Belfer committed
    • Fix a few diff bugs with directory content · dfbff793
      There are a few cases where diff should leave directories in
      the diff list if we want to match core git, such as when the
      directory contains a .git dir.  That feature was lost when I
      introduced some of the new submodule handling.
      
      This restores that and then fixes a couple of related to diff
      output that are triggered by having diffs with directories in
      them.
      
      Also, this adds a new flag that can be passed to diff if you
      want diff output to actually include the file content of any
      untracked files.
      Russell Belfer committed
  3. 05 Oct, 2012 2 commits
    • Diff: Do not try to calculate an oid for a GITLINK. · 1dca8510
      We don't have anything useful that we could do with that oid anyway (We
      need to query the submodule for the HEAD commit instead).
      
      Without this, the following code creates the error "Failed to read
      descriptor: Is a directory" when run against the submod2 test-case:
      
          const char* oidstr = "873585b94bdeabccea991ea5e3ec1a277895b698";
          git_tree* tree = resolve_commit_oid_to_tree(g_repo, oidstr);
          git_diff_list* diff = NULL;
          cl_assert(tree);
          cl_git_pass(git_diff_workdir_to_tree(g_repo, NULL, tree, &diff));
      Sascha Cunz committed
    • Diff: teach get_workdir_content to show a submodule as text · 7e57d250
      1. teach diff.c:maybe_modified to query git_submodule_status for the
         modification state of a submodule. According to the
         git_submodule_status docs, it will filter for to-ignore states
         already.
      
      2. teach diff_output.c:get_workdir_content to check the submodule status
         again and create a line like:
      
            Subproject commit <SHA-1>\n
         or
            Subproject comimt <SHA-1>-dirty\n
      
         like git.git does.
      Sascha Cunz committed
  4. 25 Sep, 2012 3 commits
    • Add const to all shared pointers in diff API · bae957b9
      There are a lot of places where the diff API gives the user access
      to internal data structures and many of these were being exposed
      through non-const pointers.  This replaces them all with const
      pointers for any object that the user can access but is still
      owned internally to the git_diff_list or git_diff_patch objects.
      
      This will probably break some bindings...  Sorry!
      Russell Belfer committed
    • Fix bugs in new diff patch code · 64286308
      This fixes all the bugs in the new diff patch code.  The only
      really interesting one is that when we merge two diffs, we now
      have to actually exclude diff delta records that are not supposed
      to be tracked, as opposed to before where they could be included
      because they would be skipped silently by `git_diff_foreach()`.
      Other than that, there are just minor errors.
      Russell Belfer committed
    • Initial implementation of new diff patch API · 5f69a31f
      Replacing the `git_iterator` object, this creates a simple API
      for accessing the "patch" for any file pair in a diff list and
      then gives indexed access to the hunks in the patch and the lines
      in the hunk.  This is the initial implementation of this revised
      API - it is still broken, but at least builds cleanly.
      Russell Belfer committed
  5. 17 Sep, 2012 2 commits
  6. 06 Sep, 2012 1 commit
    • Implement filters for status/diff blobs · 60b9d3fc
      This adds support to diff and status for running filters (a la crlf)
      on blobs in the workdir before computing SHAs and before generating
      text diffs.  This ended up being a bit more code change than I had
      thought since I had to reorganize some of the diff logic to minimize
      peak memory use when filtering blobs in a diff.
      
      This also adds a cap on the maximum size of data that will be loaded
      to diff.  I set it at 512Mb which should match core git.  Right now
      it is a #define in src/diff.h but it could be moved into the public
      API if desired.
      Russell Belfer committed
  7. 05 Sep, 2012 1 commit
    • Diff iterators · f335ecd6
      This refactors the diff output code so that an iterator object
      can be used to traverse and generate the diffs, instead of just
      the `foreach()` style with callbacks.  The code has been rearranged
      so that the two styles can still share most functions.
      
      This also replaces `GIT_REVWALKOVER` with `GIT_ITEROVER` and uses
      that as a common error code for marking the end of iteration when
      using a iterator style of object.
      Russell Belfer committed
  8. 24 Aug, 2012 1 commit
  9. 22 Aug, 2012 1 commit
    • Minor bug fixes in diff code · 5fdc41e7
      In looking at PR #878, I found a few small bugs in the diff code,
      mostly related to work that can be avoided when processing tree-
      to-tree diffs that was always being carried out.  This commit has
      some small fixes in it.
      Russell Belfer committed
  10. 09 Aug, 2012 1 commit
  11. 24 Jul, 2012 2 commits
  12. 19 Jul, 2012 1 commit
  13. 20 Jun, 2012 1 commit
  14. 19 Jun, 2012 1 commit
    • Make index add/append support core.filemode flag · da825c92
      This fixes git_index_add and git_index_append to behave more like
      core git, preserving old filemode data in the index when adding
      and/or appending with core.filemode = false.
      
      This also has placeholder support for core.symlinks and
      core.ignorecase, but those flags are not implemented (well,
      symlinks has partial support for preserving mode information in
      the same way that git does, but it isn't tested).
      Russell Belfer committed
  15. 08 Jun, 2012 2 commits
    • Minor fixes, cleanups, and clarifications · 145e696b
      There are three actual changes in this commit:
      
      1. When the trailing newline of a file is removed in a diff, the
         change will now be reported with `GIT_DIFF_LINE_DEL_EOFNL` passed
         to the callback.  Previously, the `ADD_EOFNL` constant was given
         which was just an error in my understanding of when the various
         circumstances arose.  `GIT_DIFF_LINE_ADD_EOFNL` is deprecated and
         should never be generated.  A new newline is simply an `ADD`.
      2. Rewrote the `diff_delta__merge_like_cgit` function that contains
         the core logic of the `git_diff_merge` implementation.  The new
         version doesn't actually have significantly different behavior,
         but the logic should be much more obvious, I think.
      3. Fixed a bug in `git_diff_merge` where it freed a string pool
         while some of the string data was still in use.  This led to
         `git_diff_print_patch` accessing memory that had been freed.
      
      The rest of this commit contains improved documentation in `diff.h`
      to make the behavior and the equivalencies with core git clearer,
      and a bunch of new tests to cover the various cases, oh and a minor
      simplification of `examples/diff.c`.
      Russell Belfer committed
    • Fix filemode comparison in diffs · 0abd7244
      File modes were both not being ignored properly on platforms
      where they should be ignored, nor be diffed consistently on
      platforms where they are supported.
      
      This change adds a number of diff and status filemode change
      tests.  This also makes sure that filemode-only changes are
      included in the diff output when they occur and that filemode
      changes are ignored successfully when core.filemode is false.
      
      There is no code that automatically toggles core.filemode
      based on the capabilities of the current platform, so the user
      still needs to be careful in their .git/config file.
      Russell Belfer committed
  16. 25 May, 2012 1 commit
    • Fix bugs for status with spaces and reloaded attrs · 2a99df69
      This fixes two bugs:
      
      * Issue #728 where git_status_file was not working for files
        that contain spaces.  This was caused by reusing the "fnmatch"
        parsing code from ignore and attribute files to interpret the
        "pathspec" that constrained the files to apply the status to.
        In that code, unescaped whitespace was considered terminal to
        the pattern, so a file with internal whitespace was excluded
        from the matched files.  The fix was to add a mode to that code
        that allows spaces and tabs inside patterns.  This mode only
        comes into play when parsing in-memory strings.
      
      * The other issue was undetected, but it was in the recently
        added code to reload gitattributes / gitignores when they were
        changed on disk.  That code was not clearing out the old values
        from the cached file content before reparsing which meant that
        newly added patterns would be read in, but deleted patterns
        would not be removed.  The fix was to clear the vector of
        patterns in a cached file before reparsing the file.
      Russell Belfer committed
  17. 17 May, 2012 4 commits
    • errors: Rename error codes · 904b67e6
      Vicent Martí committed
    • global: Change parameter ordering in API · 29e948de
      Consistency is good.
      Vicent Martí committed
    • Fix status for files under ignored dirs · bd4ca902
      There was a bug where tracked files inside directories that were
      inside ignored directories where not being found by status.  To
      make that a little clearer, if you have a .gitignore with:
      
          ignore/
      
      And then have the following files:
      
          ignore/dir/tracked     <-- actually a tracked file
          ignore/dir/untracked   <-- should be ignored
      
      Then we would show the tracked file as being removed (because
      when we got the to contained item "dir/" inside the ignored
      directory, we decided it was safe to skip -- bzzt, wrong!).
      
      This update is much more careful about checking that we are
      not skipping over any prefix of a tracked item, regardless of
      whether it is ignored or not.
      
      As documented in diff.c, this commit does create behavior that
      still differs from core git with regards to the handling of
      untracked files contained inside ignored directories.  With
      libgit2, those files will just not show up in status or diff.
      With core git, those files don't show up in status or diff
      either *unless* they are explicitly ignored by a .gitignore
      pattern in which case they show up as ignored files.
      
      Needless to say, this is a local behavior difference only, so
      it should not be important and (to me) the libgit2 behavior
      seems more consistent.
      Russell Belfer committed
  18. 15 May, 2012 1 commit
    • Ranged iterators and rewritten git_status_file · 41a82592
      The goal of this work is to rewrite git_status_file to use the
      same underlying code as git_status_foreach.
      
      This is done in 3 phases:
      
      1. Extend iterators to allow ranged iteration with start and
         end prefixes for the range of file names to be covered.
      2. Improve diff so that when there is a pathspec and there is
         a common non-wildcard prefix of the pathspec, it will use
         ranged iterators to minimize excess iteration.
      3. Rewrite git_status_file to call git_status_foreach_ext
         with a pathspec that covers just the one file being checked.
      
      Since ranged iterators underlie the status & diff implementation,
      this is actually fairly efficient.  The workdir iterator does
      end up loading the contents of all the directories down to the
      single file, which should ideally be avoided, but it is pretty
      good.
      Russell Belfer committed
  19. 08 May, 2012 1 commit
  20. 04 May, 2012 1 commit
  21. 03 May, 2012 1 commit
  22. 02 May, 2012 1 commit
  23. 26 Apr, 2012 1 commit
  24. 25 Apr, 2012 2 commits
  25. 13 Apr, 2012 1 commit
  26. 11 Apr, 2012 1 commit
    • Refactor git_repository_open with new options · 7784bcbb
      Add a new command `git_repository_open_ext` with extended options
      that control how searching for a repository will be done.  The
      existing `git_repository_open` and `git_repository_discover` are
      reimplemented on top of it.  We may want to change the default
      behavior of `git_repository_open` but this commit does not do that.
      
      Improve support for "gitdir" files where the work dir is separate
      from the repo and support for the "separate-git-dir" config.  Also,
      add support for opening repos created with `git-new-workdir` script
      (although I have only confirmed that they can be opened, not that
      all functions work correctly).
      
      There are also a few minor changes that came up:
      
      - Fix `git_path_prettify` to allow in-place prettifying.
      
      - Fix `git_path_root` to support backslashes on Win32.  This fix
        should help many repo open/discover scenarios - it is the one
        function called when opening before prettifying the path.
      
      - Tweak `git_config_get_string` to set the "out" pointer to NULL
        if the config value is not found.  Allows some other cleanup.
      
      - Fix a couple places that should have been calling
        `git_repository_config__weakptr` and were not.
      
      - Fix `cl_git_sandbox_init` clar helper to support bare repos.
      Russell Belfer committed
  27. 30 Mar, 2012 1 commit
  28. 26 Mar, 2012 1 commit
    • Eliminate hairy COITERATE macro · 1db12b00
      I decided that the COITERATE macro was, in the end causing
      more confusion that it would save and decided just to write
      out the loops that I needed for parallel diff list iteration.
      It is not that much code and this just feels less obfuscated.
      Russell Belfer committed
  29. 23 Mar, 2012 1 commit
    • Fix crash in new status and add recurse option · 4b136a94
      This fixes the bug that @nulltoken found (thank you!) where
      if there were untracked directories alphabetically after the
      last tracked item, the diff implementation would deref a NULL
      pointer.
      
      The fix involved the code which decides if it is necessary
      to recurse into a directory in the working dir, so it was
      easy to add a new option `GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS`
      to control if the contents of untracked directories should be
      included in status.
      Russell Belfer committed