1. 22 Feb, 2017 2 commits
  2. 21 Feb, 2017 3 commits
  3. 17 Feb, 2017 25 commits
  4. 15 Feb, 2017 1 commit
    • refdb: catch additional per-worktree refs · 6da6b425
      The upstream git.git project currently identifies all references inside
      of `refs/bisect/` as well as `HEAD` as per-worktree references. This is
      already incorrect and is currently being fixed by an in-flight topic
      [1]. The new behavior will be to match all pseudo-references outside of
      the `refs/` hierarchy as well as `refs/bisect/`.
      
      Our current behavior is to mark a selection of pseudo-references as
      per-worktree, only. This matches more pseudo-references than current
      git, but forgets about `refs/bisect/`. Adjust behavior to match the
      in-flight topic, that is classify the following references as
      per-worktree:
      
      - everything outside of `refs/`
      - everything inside of `refs/bisect/`
      
      [1]: <20170213152011.12050-1-pclouds@gmail.com>
      Patrick Steinhardt committed
  5. 13 Feb, 2017 9 commits
    • commit: avoid possible use-after-free · ade0d9c6
      When extracting a commit's signature, we first free the object and only
      afterwards put its signature contents into the result buffer. This works
      in most cases - the free'd object will normally be cached anyway, so we
      only end up decrementing its reference count without actually freeing
      its contents. But in some more exotic setups, where caching is disabled,
      this can definitly be a problem, as we might be the only instance
      currently holding a reference to this object.
      
      Fix this issue by first extracting the contents and freeing the object
      afterwards only.
      Patrick Steinhardt committed
    • commit: clear user-provided buffers · dc851d9e
      The functions `git_commit_header_field` and
      `git_commit_extract_signature` both receive buffers used to hand back
      the results to the user. While these functions called `git_buf_sanitize`
      on these buffers, this is not the right thing to do, as it will simply
      initialize or zero-terminate passed buffers. As we want to overwrite
      contents, we instead have to call `git_buf_clear` to completely reset
      them.
      Patrick Steinhardt committed
    • buffer: clarify how `git_buf_sanitize` handles non-NULL input · cdb2c2a0
      When `git_buf_sanitize` gets called, it converts a buffer with NULL
      content to be correctly initialized. This is done by pointing it to
      `git_buf__initbuf`. While the method's documentation states this
      clearly, it may also lead to the conclusion that it will do the same to
      buffers which do _not_ have NULL contents.
      
      Clarify behavior when passing a buffer with non-NULL contents, where
      `git_buf_sanitize` will ensure that the contents are `\0`-terminated.
      Patrick Steinhardt committed
    • worktree: compute workdir for worktrees opened via their gitdir · 39abd3ad
      When opening a worktree via the gitdir of its parent repository
      we fail to correctly set up the worktree's working directory. The
      problem here is two-fold: we first fail to see that the gitdir
      actually is a gitdir of a working tree and then subsequently
      fail to determine the working tree location from the gitdir.
      
      The first problem of not noticing a gitdir belongs to a worktree
      can be solved by checking for the existence of a `gitdir` file in
      the gitdir. This file points back to the gitlink file located in
      the working tree's working directory. As this file only exists
      for worktrees, it should be sufficient indication of the gitdir
      belonging to a worktree.
      
      The second problem, that is determining the location of the
      worktree's working directory, can then be solved by reading the
      `gitdir` file in the working directory's gitdir. When we now
      resolve relative paths and strip the final `.git` component, we
      have the actual worktree's working directory location.
      Patrick Steinhardt committed
    • repository: rename `path_repository` and `path_gitlink` · 84f56cb0
      The `path_repository` variable is actually confusing to think
      about, as it is not always clear what the repository actually is.
      It may either be the path to the folder containing worktree and
      .git directory, the path to .git itself, a worktree or something
      entirely different. Actually, the intent of the variable is to
      hold the path to the gitdir, which is either the .git directory
      or the bare repository.
      
      Rename the variable to `gitdir` to avoid confusion. While at it,
      also rename `path_gitlink` to `gitlink` to improve consistency.
      Patrick Steinhardt committed
    • repository: restrict checking out checked out branches · 384518d0
      If a branch is already checked out in a working tree we are not
      allowed to check out that branch in another repository. Introduce
      this restriction when setting a repository's HEAD.
      Patrick Steinhardt committed
    • branch: restrict branch deletion for worktrees · 143e539f
      Restrict the ability to delete branches that are checked out in
      any linked repository.
      Patrick Steinhardt committed
    • branch: implement `git_branch_is_checked_out` · e3acd37b
      Implement a new function that is able to determine if a branch is
      checked out in any repository connected to the current
      repository. In particular, this is required to check if for a
      given repository and branch, there exists any working tree
      connected to that repository that is referencing this branch.
      Patrick Steinhardt committed