Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(git): support detached working trees #2597

Merged
merged 3 commits into from
Jul 14, 2023
Merged

Conversation

jamestrew
Copy link
Contributor

@jamestrew jamestrew commented Jul 9, 2023

closes #2595

Description

Adds support for detached working tree for git related pickers.
Closely follows the pattern utilized by gitsigns.nvim in lewis6991/gitsigns.nvim#600

eg use case:

require("telescope").setup({
  defaults = {
    git_worktrees = {
      {
        toplevel = vim.env.HOME,
        gitdir = vim.env.HOME .. "/.cfg",
      },
    },
  },
})

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

Tested the following pickers with detached/attached working trees and git worktrees.

  • git_files
  • git_status
  • git_stash
  • git_commits
  • git_bcommits
  • git_branches

@jamestrew jamestrew marked this pull request as ready for review July 9, 2023 18:03
@jamestrew
Copy link
Contributor Author

@Subjective can you test this branch?

@Subjective
Copy link

@jamestrew It works great now, thanks!

@Subjective
Copy link

Subjective commented Jul 10, 2023

Okay, one issue I noticed is that an error occurs if you open a file belonging to one of the detached working trees when Vim's cwd is set to another git repo and use_file_path = true. (My intended use case was to bring up a dotfile's commit history when its buffer is active, even when the cwd is set to another git repo).

Edit: Wait actually, it seems like use_file_path=true doesn't work anymore even for files opened in a normal git repo.

@jamestrew
Copy link
Contributor Author

Ahh thanks for catching that. Having dug deeper, I'm not sure use_file_path really ever worked but things should be better now.

@Subjective
Copy link

Everything seems to be working fine now, thanks!

@jamestrew jamestrew merged commit 2ea8dcd into master Jul 14, 2023
13 checks passed
aaronkollasch added a commit to aaronkollasch/telescope.nvim that referenced this pull request Jul 19, 2023
jamestrew pushed a commit that referenced this pull request Jul 22, 2023
* Filter bcommits by selection in visual mode

* Split bcommits_range into new picker

* Add option to run bcommits_range as operator

Starts operator-pending mode and shows commits in the range of lines
covered by the next text object or motion

* Rename range arguments to "first" and "last"

Can't use start/end, since end is an annoying keyword to use in lua
and start/stop doesn't fit as well

* Move operators functionality to new module

* Run bcommits if no range given to bcommits_range

* Make bcommits_range default to current line

Instead of calling bcommits

* Improve documentation of telescope.operators

* Add default value for last_operator

Default to a no-op callback

* Update bcommits_range for detached worktrees

See #2597

* Rename range arguments to "from" and "to"

* Move shared bcommits picker into single function
@Conni2461 Conni2461 deleted the feat/detached-worktrees branch October 11, 2023 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Option to disable check for git cwd
2 participants