gitlinker.nvim icon indicating copy to clipboard operation
gitlinker.nvim copied to clipboard

Added support for bare repositories (fixes #83)

Open lnc3l0t opened this issue 2 years ago • 0 comments

Usage:

By adding bare repository directories and their corresponding work_tree paths to config.bare_repos, users can now utilize the plugin with files tracked by those repositories. Multiple worktrees are not currently supported but can be implemented easily in the future.

Changes Made:

Added a new option to the configuration, bare_repos, which is a list of pairs {git_dir, git_work_tree}. If the plugin is used in a buffer associated with a bare repository, the first git command (git rev-parse) would fail, as the buffer is not in a regular git repo. To handle this, subsequent similar git commands are made with the --git-dir and --work-tree flags. When a buffer is identified as belonging to one of the bare repositories specified in config.bare_repos, the information is cached for subsequent calls within the same session.

Example:

A common use case is having a bare repository for managing dotfiles, that would be treated like so assuming the repo is in the .dotfiles folder and $HOME is the worktree:

config.bare_repos = {
    { "$HOME/.dotfiles", "$HOME" }
}

lnc3l0t avatar May 19 '23 07:05 lnc3l0t