1. 26 Mar, 2020 1 commit
    • patch: correctly handle mode changes for renames · 5f47cb48
      When generating a patch for a renamed file whose mode bits have changed
      in addition to the rename, then we currently fail to parse the generated
      patch. Furthermore, when generating a diff we output mode bits after the
      similarity metric, which is different to how upstream git handles it.
      
      Fix both issues by adding another state transition that allows
      similarity indices after mode changes and by printing mode changes
      before the similarity index.
      Patrick Steinhardt committed
  2. 23 Mar, 2020 1 commit
  3. 10 Mar, 2020 2 commits
  4. 08 Mar, 2020 1 commit
    • win32: clarify usage of path canonicalization funcs · fb7da154
      The path canonicalization functions on win32 are intended to
      canonicalize absolute paths; those with prefixes.  In other words,
      things start with drive letters (`C:\`), share names (`\\server\share`),
      or other prefixes (`\\?\`).
      
      This function removes leading `..` that occur after the prefix but
      before the directory/file portion (eg, turning `C:\..\..\..\foo` into
      `C:\foo`).  This translation is not appropriate for local paths.
      Edward Thomson committed
  5. 18 Feb, 2020 1 commit
  6. 07 Feb, 2020 6 commits
    • tests: diff: add test to verify behaviour with empty dir ordering · 17670ef2
      It was reported that, given a file "abc.txt", a diff will be shown if an
      empty directory "abb/" is created, but not if "abd/" is created. Add a
      test to verify that we do the right thing here and do not depend on any
      ordering.
      Patrick Steinhardt committed
    • tests: diff: verify that we are able to diff with empty subtrees · b0691db3
      While it is not allowed for a tree to have an empty tree as child (e.g.
      an empty directory), libgit2's tree builder makes it easy to create such
      trees. As a result, some applications may inadvertently end up with such
      an invalid tree, and we should try our best and handle them.
      
      One such case is when diffing two trees, where one of both trees has
      such an empty subtree. It was reported that this will cause our diff
      code to fail. While I wasn't able to reproduce this error, let's still
      add a test that verifies we continue to handle them correctly.
      Patrick Steinhardt committed
    • tests: iterator: fix iterator expecting too few items · 26b71d60
      The testcase iterator::workdir::filesystem_gunk sets up quite a lot of
      directories, which is why it only runs in case GITTEST_INVASIVE_SPEED is
      set in the environment. Because we do not run our default CI with this
      variable, we didn't notice commit 852c83ee (refs: refuse to delete
      HEAD, 2020-01-15) breaking the test as it introduced a new reference to
      the "testrepo" repository.
      
      Fix the oversight by increasing the number of expected iterator items.
      Patrick Steinhardt committed
    • tests: add missing error checks · 2e6cbff8
      We should always verify error codes returned by function calls in our
      test suite to not accidentally miss any weird results. Coverity reported
      missing checks in several locations, which this commit fixes.
      Patrick Steinhardt committed
    • tests: blame: fix conversion specifiers in format string · 7d65d4cb
      While the blame helper function `hunk_message` accepts a printf-style
      format string, we didn't add a compiler attribute to let the compiler
      check for correct conversion specifiers. As a result, some users of the
      function used wrong specifiers.
      
      Add the GIT_FORMAT_PRINTF attribute to the function and fix resulting
      warnings by using the correct specifiers.
      Patrick Steinhardt committed
    • transports: http: fix custom headers not being applied · 46228d86
      In commit b9c5b15a (http: use the new httpclient, 2019-12-22), the HTTP
      code got refactored to extract a generic HTTP client that operates
      independently of the Git protocol. Part of refactoring was the creation
      of a new `git_http_request` struct that encapsulates the generation of
      requests. Our Git-specific HTTP transport was converted to use that in
      `generate_request`, but during the process we forgot to set up custom
      headers for the `git_http_request` and as a result we do not send out
      these headers anymore.
      
      Fix the issue by correctly setting up the request's custom headers and
      add a test to verify we correctly send them.
      Patrick Steinhardt committed
  7. 31 Jan, 2020 1 commit
    • fetchhead: strip credentials from remote URL · 93a9044f
      If fetching from an anonymous remote via its URL, then the URL gets
      written into the FETCH_HEAD reference. This is mainly done to give
      valuable context to some commands, like for example git-merge(1), which
      will put the URL into the generated MERGE_MSG. As a result, what gets
      written into FETCH_HEAD may become public in some cases. This is
      especially important considering that URLs may contain credentials, e.g.
      when cloning 'https://foo:bar@example.com/repo' we persist the complete
      URL into FETCH_HEAD and put it without any kind of sanitization into the
      MERGE_MSG. This is obviously bad, as your login data has now just leaked
      as soon as you do git-push(1).
      
      When writing the URL into FETCH_HEAD, upstream git does strip
      credentials first. Let's do the same by trying to parse the remote URL
      as a "real" URL, removing any credentials and then re-formatting the
      URL. In case this fails, e.g. when it's a file path or not a valid URL,
      we just fall back to using the URL as-is without any sanitization. Add
      tests to verify our behaviour.
      Patrick Steinhardt committed
  8. 26 Jan, 2020 1 commit
    • credential: change git_cred to git_credential · 3f54ba8b
      We avoid abbreviations where possible; rename git_cred to
      git_credential.
      
      In addition, we have standardized on a trailing `_t` for enum types,
      instead of using "type" in the name.  So `git_credtype_t` has become
      `git_credential_t` and its members have become `GIT_CREDENTIAL` instead
      of `GIT_CREDTYPE`.
      
      Finally, the source and header files have been renamed to `credential`
      instead of `cred`.
      
      Keep previous name and values as deprecated, and include the new header
      files from the previous ones.
      Edward Thomson committed
  9. 24 Jan, 2020 7 commits
  10. 18 Jan, 2020 1 commit
  11. 16 Jan, 2020 1 commit
  12. 15 Jan, 2020 1 commit
    • refs: refuse to delete HEAD · 852c83ee
      This requires adding a new symbolic ref to the testrepo fixture.
      Some of the existing tests attempt to delete HEAD, expecting a different failure. Introduce and use a non-HEAD symbolic ref instead.
      Adjust a few other tests as needed.
      
      Fixes #5357
      Josh Bleecher Snyder committed
  13. 10 Jan, 2020 1 commit
    • win32: fix relative symlinks pointing into dirs · 7d55bee6
      On Windows platforms, we need some logic to emulate symlink(3P) defined
      by POSIX. As unprivileged symlinks on Windows are a rather new feature,
      our current implementation is comparatively new and still has some
      rough edges in special cases.
      
      One such case is relative symlinks. While relative symlinks to files in
      the same directory work as expected, libgit2 currently fails to create
      reltaive symlinks pointing into other directories. This is due to the
      fact that we forgot to translate the Unix-style target path to
      Windows-style. Most importantly, we are currently not converting
      directory separators from "/" to "\".
      
      Fix the issue by calling `git_win32_path_canonicalize` on the target.
      Add a test that verifies our ability to create such relative links
      across directories.
      Patrick Steinhardt committed
  14. 09 Jan, 2020 2 commits
  15. 06 Jan, 2020 1 commit
  16. 13 Dec, 2019 1 commit
    • refs: rename git_reference__set_name to git_reference__realloc · 97b8491b
      As git_reference__name will reallocate storage to account for longer
      names (it's actually allocator-dependent), it will cause all existing
      pointers to the old object to become dangling, as they now point to
      freed memory.
      
      Fix the issue by renaming to a more descriptive name, and pass a pointer
      to the actual reference that can safely be invalidated if the realloc
      succeeds.
      Etienne Samson committed
  17. 12 Dec, 2019 1 commit
  18. 10 Dec, 2019 10 commits