summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorPranav Rao <56097527+pranavrao145@users.noreply.github.com>2021-11-13 08:09:47 -0500
committerGitHub <noreply@github.com>2021-11-13 14:09:47 +0100
commit33095265665db92246165fa44db34a326e06db64 (patch)
tree898a301a9855ace79125ab7402e25e34165a63fa /lua
parentfc9ec7ffacdb9417ab2167d628af837cfbfa63e9 (diff)
feat(worktrees): added support for bare repo git operations (#1370)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/git.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/lua/telescope/builtin/git.lua b/lua/telescope/builtin/git.lua
index 7bc88cd..a7a7b43 100644
--- a/lua/telescope/builtin/git.lua
+++ b/lua/telescope/builtin/git.lua
@@ -14,6 +14,10 @@ local conf = require("telescope.config").values
local git = {}
git.files = function(opts)
+ if opts.is_bare then
+ error "This operation must be run in a work tree"
+ end
+
local show_untracked = utils.get_default(opts.show_untracked, true)
local recurse_submodules = utils.get_default(opts.recurse_submodules, false)
if show_untracked and recurse_submodules then
@@ -294,6 +298,10 @@ git.branches = function(opts)
end
git.status = function(opts)
+ if opts.is_bare then
+ error "This operation must be run in a work tree"
+ end
+
local gen_new_finder = function()
local expand_dir = utils.if_nil(opts.expand_dir, true, opts.expand_dir)
local git_cmd = { "git", "status", "-s", "--", "." }
@@ -351,9 +359,13 @@ local set_opts_cwd = function(opts)
local use_git_root = utils.get_default(opts.use_git_root, true)
if ret ~= 0 then
- local output = utils.get_os_command_output({ "git", "rev-parse", "--is-inside-work-tree" }, opts.cwd)
- if output[1] ~= "true" then
+ local in_worktree = utils.get_os_command_output({ "git", "rev-parse", "--is-inside-work-tree" }, opts.cwd)
+ local in_bare = utils.get_os_command_output({ "git", "rev-parse", "--is-bare-repository" }, opts.cwd)
+
+ if in_worktree[1] ~= "true" and in_bare[1] ~= "true" then
error(opts.cwd .. " is not a git directory")
+ elseif in_worktree[1] ~= "true" and in_bare[1] == "true" then
+ opts.is_bare = true
end
else
if use_git_root then