1. 23 Feb, 2022 1 commit
  2. 28 Jan, 2022 1 commit
  3. 05 Jan, 2022 1 commit
  4. 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
  5. 18 May, 2021 1 commit
  6. 16 May, 2021 3 commits
  7. 12 May, 2021 2 commits
  8. 25 Nov, 2020 2 commits
  9. 25 Oct, 2020 1 commit
  10. 12 Jul, 2020 1 commit
    • branch: determine whether a branch is checked out via refdb · ac5fbe31
      We currently determine whether a branch is checked out via
      `git_repository_foreach_head`. As this function reads references
      directly from the disk, it breaks our refdb abstraction in case the
      repository uses a different reference backend implementation than the
      filesystem-based one. So let's use `git_repository_foreach_worktree`
      instead -- while it's less efficient, it is at least correct in all
      corner cases.
      Patrick Steinhardt committed
  11. 01 Jun, 2020 1 commit
  12. 07 Dec, 2019 1 commit
  13. 22 Feb, 2019 1 commit
  14. 14 Feb, 2019 3 commits
    • branch: fix `branch_is_checked_out` with bare repos · bf013fc0
      In a bare repository, HEAD usually points to the branch that is
      considered the "default" branch. As the current implementation for
      `git_branch_is_checked_out` only does a comparison of HEAD with the
      branch that is to be checked, it will say that the branch pointed to by
      HEAD in such a bare repo is checked out.
      
      Fix this by skipping the main repo's HEAD when it is bare.
      Patrick Steinhardt committed
    • branches: introduce flag to skip enumeration of certain HEADs · efb20825
      Right now, the function `git_repository_foreach_head` will always
      iterate over all HEADs of the main repository and its worktrees. In some
      cases, it might be required to skip either of those, though. Add a flag
      in preparation for the following commit that enables this behaviour.
      Patrick Steinhardt committed
    • branches: do not assert that the given ref is a branch · 788cd2d5
      Libraries should use assert(3P) only very scarcely. First, we usually
      shouldn't cause the caller of our library to abort in case where the
      assert fails. Second, if code is compiled with -DNDEBUG, then the assert
      will not be included at all.
      
      In our `git_branch_is_checked_out` function, we have an assert that
      verifies that the given reference parameter is non-NULL and in fact a
      branch. While the first check is fine, the second is not. E.g. when
      compiled with -DNDEBUG, we'd proceed and treat the given reference as a
      branch in all cases.
      
      Fix the issue by instead treating a non-branch reference as not being
      checked out. This is the obvious solution, as references other than
      branches cannot be directly checked out.
      Patrick Steinhardt committed
  15. 22 Jan, 2019 1 commit
  16. 17 Jan, 2019 1 commit
  17. 10 Jun, 2018 1 commit
  18. 19 Jan, 2018 1 commit
    • branch: refuse creating branches named 'HEAD' · a9677e01
      Since a625b092c (branch: correctly reject refs/heads/{-dash,HEAD},
      2017-11-14), which is included in v2.16.0, upstream git refuses to
      create branches which are named HEAD to avoid ambiguity with the
      symbolic HEAD reference. Adjust our own code to match that behaviour and
      reject creating branches names HEAD.
      Patrick Steinhardt committed
  19. 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
  20. 01 May, 2017 1 commit
  21. 05 Apr, 2017 1 commit
  22. 13 Feb, 2017 2 commits
  23. 29 Dec, 2016 1 commit
  24. 04 Nov, 2016 1 commit
    • branch: fix forced branch creation on HEAD of a bare repo · f9793884
      The code correctly detects that forced creation of a branch on a
      nonbare repo should not be able to overwrite a branch which is
      the HEAD reference.  But there's no reason to prevent this on
      a bare repo, and in fact, git allows this.  I.e.,
      
         git branch -f master new_sha
      
      works on a bare repo with HEAD set to master.  This change fixes
      that problem, and updates tests so that, for this case, both the
      bare and nonbare cases are checked for correct behavior.
      John Fultz committed
  25. 26 Apr, 2016 1 commit
    • annotated_commit: provide refs and description · d5592378
      Differentiate between the ref_name used to create an annotated_commit
      (that can subsequently be used to look up the reference) and the
      description that we resolved this with (which _cannot_ be looked up).
      
      The description is used for things like reflogs (and may be a ref name,
      and ID something that we revparsed to get here), while the ref name must
      actually be a reference name, and is used for things like rebase to
      return to the initial branch.
      Edward Thomson committed
  26. 12 Jul, 2015 1 commit
  27. 22 May, 2015 1 commit
    • branch: error out if we cannot find the remote · 5014fe95
      When we look for which remote corresponds to a remote-tracking branch,
      we look in the refspecs to see which ones matches. If none do, we should
      abort. We currently ignore the error message from this operation, so
      let's not do that anymore.
      
      As part of the test we're writing, let's test for the expected behaviour
      if we cannot find a refspec which tells us what the remote-tracking
      branch for a remote would look like.
      Carlos Martín Nieto committed
  28. 16 Mar, 2015 1 commit
  29. 04 Mar, 2015 3 commits
  30. 03 Mar, 2015 2 commits
    • config: borrow refcounted references · 9a97f49e
      This changes the get_entry() method to return a refcounted version of
      the config entry, which you have to free when you're done.
      
      This allows us to avoid freeing the memory in which the entry is stored
      on a refresh, which may happen at any time for a live config.
      
      For this reason, get_string() has been forbidden on live configs and a
      new function get_string_buf() has been added, which stores the string in
      a git_buf which the user then owns.
      
      The functions which parse the string value takea advantage of the
      borrowing to parse safely and then release the entry.
      Carlos Martín Nieto committed
    • branch: don't accept a reflog message override · 6bfb990d
      This namespace is about behaving like git's branch command, so let's do
      exactly that instead of taking a reflog message.
      
      This override is still available via the reference namespace.
      Carlos Martín Nieto committed