Open mosheavni opened 2 years ago
Honestly i dont get what you want. Stuff like this:
Expected behavior No response
Makes helping you impossible. Do you not want to see remote branches? Do you want to track remote branches because you can do that with <c-t>
. Is this a bug report a feature request?
git for-each-ref --sort=-committerdate --format="%(refname:short)" | grep -n . | sed "s?origin/??g" | sort -t: -k2 -u | sort -n | cut -d: -f2
We currently dont support piping. And changing the command is currently pretty much impossible because that would also result in changing some of the lua code. So you basically can just write your own picker.
I am tempted to close this issue as invalid based the fact that you filled out the template that bad and i will do that in the following days unless you provide more information.
I'm sorry I missed that field, I had hoped that I described the issue in a clear way. Providing a clear and tested reproduction steps:
minimal-init.lua
file:mkdir /tmp/git-branch-ts-test/
cd /tmp/git-branch-ts-test/
curl -sLO https://gist.githubusercontent.com/mosheavni/2de985493b6746b49fdf1e9ef93902b9/raw/9f7c66de2c6ce5f30c50e42ab1f03029dcdcf8ae/minimal-init.lua
cd /tmp/git-branch-ts-test/
git clone https://github.com/junegunn/fzf.git
cd fzf
nvim -nu /tmp/git-branch-ts-test/minimal-init.lua
:Telescope git_branches
and choose any branch:!git status
to see what happened at checkout:!git status
HEAD detached at origin/dependabot/github_actions/github/codeql-action-2.1.10
nothing to commit, working tree clean
Press ENTER or type command to continue
Now you can see that the HEAD is detached which is a not wanted git behaviour. When I'm checking out to a branch I want it to be a local one tracked remotely, so basically I either wouldn't want to see branches with origin/
, or having something that removes the remote prefix to check out to a local branch and not get HEAD detached at...
<C-t>
to track the branch. Does that work for you?
<C-t>
to track the branch. Does that work for you?
it does. However, I think it should be the default behaviour, no point in detaching head.
our default action does git checkout
which also doesn't do that on default so i think its sensible to copy this behavior.
We also have git switch
on <c-s>
our default action does
git checkout
which also doesn't do that on default so i think its sensible to copy this behavior.We also have
git switch
on<c-s>
Ok, is there a way to override the mappings? https://github.com/nvim-telescope/telescope.nvim/blob/39b12d84e86f5054e2ed98829b367598ae53ab41/lua/telescope/builtin/git.lua#L287 not sure by this code I can.
Also regarding the second sort question, this flag added to git for-each-rev
: --sort committerdate
better sorts the branches, but I believe that overrides it:
https://github.com/nvim-telescope/telescope.nvim/blob/39b12d84e86f5054e2ed98829b367598ae53ab41/lua/telescope/builtin/git.lua#L286
Is there a way to not sort the results? Thanks.
I'd also love to change default behavior. Rarely do I want to just checkout the commit, I most often want to switch/track.
I'd also love to change default behavior. Rarely do I want to just checkout the commit, I most often want to switch/track.
so strange that this is the default behavior they chose, so un-intuitive!
our default action does git checkout which also doesn't do that on default so i think its sensible to copy this behavior.
We also have git switch on
<c-s>
I know this is a rather trivial subject, the functionality is there and I'm happy with that, but since we're here and talking about which would be more sensible...
Since git switch
is its own command in git which was made to separate out the functionality of switching branches from git checkout
which was meant for overwriting files, wouldn't it be more sensible to follow the lead of git and separate out the behavior here as well?
Adding a Telescope switch
would be a better experience for users and follow the paradigm of git by making switch its own function rather than making switch seem more like a subset of checkout (which is the opposite of what git switch
was meant to be) by having its functionality executed by Telescope checkout
then <c-s>
I was able to override the keybinding with telescope.setup()
:
telescope.setup({
pickers = {
git_branches = {
mappings = {
i = { ["<cr>"] = actions.git_switch_branch },
},
},
},
})
+1 to this issue
+1
I agree with this guy. The default behavior should be checkout to the HEAD
of the branch, not detached.
+1 to this issue
Description
On
:Telescope git_branch
I see all branches including non-localorigin/
branches (branches I still not checked out to sincegit clone
), and when I try to checkout to this branch by pressing Enter, I get HEAD detached:Also, I want to sort based on the branches with latest push, I came up with this git command:
Which I wish I could use instead of the plugin's default git branch command, here: https://github.com/nvim-telescope/telescope.nvim/blob/d743d70292956f55f4a71f291281287d206f29f2/lua/telescope/builtin/git.lua#L199
Neovim version
Operating system and version
macOS 12.2.1
checkhealth telescope
Steps to reproduce
minimal-init.lua
file::Telescope git_branches
and choose any branch:!git status
to see what happened at checkoutNow you can see that the HEAD is detached which is a not wanted git behaviour. When I'm checking out to a branch I want it to be a local one tracked remotely, so basically I either wouldn't want to see branches with
origin/
, or having something that removes the remote prefix to check out to a local branch and not get HEAD detached at...Expected behavior
If I select a branch with name `REMOTE_NAME/XXX', I want the checkout actions to be:
Actual behavior
branches with
origin/
prefix are checked out to and HEAD detaches, behind the scenes it's probably:Minimal config
https://gist.githubusercontent.com/mosheavni/2de985493b6746b49fdf1e9ef93902b9/raw/9f7c66de2c6ce5f30c50e42ab1f03029dcdcf8ae/minimal-init.lua