1. 09 Nov, 2021 1 commit
  2. 17 Oct, 2021 1 commit
    • str: introduce `git_str` for internal, `git_buf` is external · f0e693b1
      libgit2 has two distinct requirements that were previously solved by
      `git_buf`.  We require:
      
      1. A general purpose string class that provides a number of utility APIs
         for manipulating data (eg, concatenating, truncating, etc).
      2. A structure that we can use to return strings to callers that they
         can take ownership of.
      
      By using a single class (`git_buf`) for both of these purposes, we have
      confused the API to the point that refactorings are difficult and
      reasoning about correctness is also difficult.
      
      Move the utility class `git_buf` to be called `git_str`: this represents
      its general purpose, as an internal string buffer class.  The name also
      is an homage to Junio Hamano ("gitstr").
      
      The public API remains `git_buf`, and has a much smaller footprint.  It
      is generally only used as an "out" param with strict requirements that
      follow the documentation.  (Exceptions exist for some legacy APIs to
      avoid breaking callers unnecessarily.)
      
      Utility functions exist to convert a user-specified `git_buf` to a
      `git_str` so that we can call internal functions, then converting it
      back again.
      Edward Thomson committed
  3. 08 Aug, 2021 1 commit
  4. 21 Nov, 2020 1 commit
  5. 07 Nov, 2020 1 commit
  6. 06 Nov, 2020 1 commit
  7. 12 Jul, 2020 4 commits
    • tests: verify renaming branch really updates worktree HEAD · ce4cb073
      In case where a branch is getting renamed, all HEADs of the main
      repository and of its worktrees that point to the old branch need to get
      updated to point to the new branch. We already do so and have a test for
      this, but the test only verifies that we're able to lookup the updated
      HEAD, not what it contains.
      
      Let's make the test more specific by verifying the updated HEAD also has
      the correct updated symbolic target.
      Patrick Steinhardt committed
    • repository: retrieve worktree HEAD via refdb · 65895410
      The function `git_repository_head_for_worktree` currently uses
      `git_reference__read_head` to directly read a given worktree's HEAD from
      the filesystem. This is broken in case the repository uses a different
      refdb implementation than the filesystem-based one, so let's instead
      open the worktree as a real repository and use `git_reference_lookup`.
      This also fixes the case where the worktree's HEAD is not a symref, but
      a detached HEAD, which would have resulted in an error previously.
      Patrick Steinhardt committed
    • repository: remove function to iterate over HEADs · d1f210fc
      The function `git_repository_foreach_head` is broken, as it directly
      interacts with the on-disk representation of the reference database,
      thus assuming that no other refdb is used for the given repository. As
      this is an internal function only and all users have been replaced,
      let's remove this function.
      Patrick Steinhardt committed
    • repository: introduce new function to iterate over all worktrees · 2fcb4f28
      Given a Git repository, it's non-trivial to iterate over all worktrees
      that are associated with it, including the "main" repository. This
      commit adds a new internal function `git_repository_foreach_worktree`
      that does this for us.
      Patrick Steinhardt committed
  8. 01 Jun, 2020 1 commit
  9. 24 Jun, 2019 1 commit
  10. 14 Feb, 2019 1 commit
  11. 16 Aug, 2018 1 commit
  12. 13 Jul, 2018 1 commit
    • treewide: remove use of C++ style comments · 9994cd3f
      C++ style comment ("//") are not specified by the ISO C90 standard and
      thus do not conform to it. While libgit2 aims to conform to C90, we did
      not enforce it until now, which is why quite a lot of these
      non-conforming comments have snuck into our codebase. Do a tree-wide
      conversion of all C++ style comments to the supported C style comments
      to allow us enforcing strict C90 compliance in a later commit.
      Patrick Steinhardt committed
  13. 29 Jun, 2018 5 commits
  14. 10 Jun, 2018 1 commit
  15. 07 May, 2018 1 commit
  16. 25 Apr, 2018 1 commit
  17. 20 Apr, 2018 2 commits
    • tests: free the worktree in add_with_explicit_branch · 25100d6d
      Valgrind log:
      
      ==2711== 305 (48 direct, 257 indirect) bytes in 1 blocks are definitely lost in loss record 576 of 624
      ==2711==    at 0x4C2CC70: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==2711==    by 0x5E079E: git__calloc (util.h:99)
      ==2711==    by 0x5E0D21: open_worktree_dir (worktree.c:134)
      ==2711==    by 0x5E0F23: git_worktree_lookup (worktree.c:176)
      ==2711==    by 0x5E1972: git_worktree_add (worktree.c:388)
      ==2711==    by 0x551F23: test_worktree_worktree__add_with_explicit_branch (worktree.c:292)
      ==2711==    by 0x45853E: clar_run_test (clar.c:222)
      ==2711==    by 0x4587E1: clar_run_suite (clar.c:286)
      ==2711==    by 0x458B04: clar_parse_args (clar.c:362)
      ==2711==    by 0x458CAB: clar_test_run (clar.c:428)
      ==2711==    by 0x45665C: main (main.c:24)
      Etienne Samson committed
    • Fix deletion of unrelated branch on worktree · fd7b5bc3
      Signed-off-by: Sven Strickroth <email@cs-ware.de>
      Sven Strickroth committed
  18. 10 Apr, 2018 1 commit
  19. 27 Mar, 2018 1 commit
  20. 09 Feb, 2018 1 commit
    • worktree: add ability to create worktree with pre-existing branch · a22f19e6
      Currently, we always create a new branch after the new worktree's name
      when creating a worktree. In some workflows, though, the caller may want
      to check out an already existing reference instead of creating a new
      one, which is impossible to do right now.
      
      Add a new option `ref` to the options structure for adding worktrees. In
      case it is set, a branch and not already checked out by another
      worktree, we will re-use this reference instead of creating a new one.
      Patrick Steinhardt committed
  21. 05 May, 2017 2 commits
    • worktree: switch over worktree pruning to an opts structure · 883eeb5f
      The current signature of `git_worktree_prune` accepts a flags field to
      alter its behavior. This is not as flexible as we'd like it to be when
      we want to enable passing additional options in the future. As the
      function has not been part of any release yet, we are still free to
      alter its current signature. This commit does so by using our usual
      pattern of an options structure, which is easily extendable without
      breaking the API.
      Patrick Steinhardt committed
    • worktree: support creating locked worktrees · 8264a30f
      When creating a new worktree, we do have a potential race with us
      creating the worktree and another process trying to delete the same
      worktree as it is being created. As such, the upstream git project has
      introduced a flag `git worktree add --locked`, which will cause the
      newly created worktree to be locked immediately after its creation. This
      mitigates the race condition.
      
      We want to be able to mirror the same behavior. As such, a new flag
      `locked` is added to the options structure of `git_worktree_add` which
      allows the user to enable this behavior.
      Patrick Steinhardt committed
  22. 02 May, 2017 1 commit
    • worktree: introduce git_worktree_add options · a7aa73a5
      The `git_worktree_add` function currently accepts only a path and name
      for the new work tree. As we may want to expand these parameters in
      future versions without adding additional parameters to the function for
      every option, this commit introduces our typical pattern of an options
      struct. Right now, this structure is still empty, which will change with
      the next commit.
      Patrick Steinhardt committed
  23. 05 Apr, 2017 2 commits
  24. 17 Mar, 2017 5 commits
    • submodule: resolve URLs relative to main worktree · b0c9bc92
      It is possible to specify submodule URLs relative to the repository
      location. E.g. having a submodule with URL "../submodule" will look for
      the submodule at "repo/../submodule".
      
      With the introduction of worktrees, though, we cannot simply resolve the
      URL relative to the repository location itself. If the repository for
      which a URL is to be resolved is a working tree, we have to resolve the
      URL relative to the parent's repository path. Otherwise, the URL would
      change depending on where the working tree is located.
      
      Fix this by special-casing when we have a working tree while getting the
      URL base.
      Patrick Steinhardt committed
    • refdb: create references in commondir · 097f0105
      References for a repository are usually created inside of its gitdir.
      When using worktrees, though, these references are not to be created
      inside the worktree gitdir, but instead inside the gitdir of its parent
      repository, which is the commondir. Like this, branches will still be
      available after the worktree itself has been deleted.
      
      The filesystem refdb currently still creates new references inside of
      the gitdir. Fix this and have it create references in commondir.
      Patrick Steinhardt committed
    • worktree: write resolved paths into link files · 8f154be3
      The three link files "worktree/.git", ".git/worktrees/<name>/commondir"
      and ".git/worktrees/<name>/gitdir" should always contain absolute and
      resolved paths. Adjust the logic creating new worktrees to first use
      `git_path_prettify_dir` before writing out these files, so that paths
      are resolved first.
      Patrick Steinhardt committed
    • worktree: parent path should point to the working dir · 20a368e2
      The working tree's parent path should not point to the parent's gitdir,
      but to the parent's working directory. Pointing to the gitdir would not
      make any sense, as the parent's working directory is actually equal to
      both repository's common directory.
      
      Fix the issue.
      Patrick Steinhardt committed
    • worktree: implement `git_worktree_open_from_repository` · 3017ba94
      While we already provide functionality to look up a worktree from a
      repository, we cannot do so the other way round. That is given a
      repository, we want to look up its worktree if it actually exists.
      Getting the worktree of a repository is useful when we want to get
      certain meta information like the parent's location, getting the locked
      status, etc.
      Patrick Steinhardt committed
  25. 15 Mar, 2017 2 commits