ThePrimeagen / git-worktree.nvim

714 stars 126 forks source link

Discussion: Using branch name vs path in switch/delete api #37

Open polarmutex opened 3 years ago

polarmutex commented 3 years ago

@ThePrimeagen Continuing the discussion from #29 since it was not resolved

I chose path since it matches how the git cli works. but I do see benefits to using the branch name since it is more likely to be shorter name than the path. On the other side, if you use the telescope plugin you can fuzzy over either in the current master.

Close if you are fine with the current implementation or we can look into changing it

polarmutex commented 3 years ago

do we want to support switching to a git repo when not in one? basically find the git repo in the path to switch to?

ThePrimeagen commented 3 years ago

Unsure. These are all great ideas. I'll have to think about it.

I see why path is so nice. It does fit well with the worktree style. So does branch though. I don't really think in paths as much as I think in branches. So they are both correct in some sense.

As far as detecting the git root from anywhere within the repo, I do think its a great idea that we support opening up deep within any directory, though it does not work with my workflow (I would never do such a thing). Personally, I am baffled why you would start by opening up deep within a project to begin with.

TamaMcGlinn commented 3 years ago

I am baffled why you would start by opening up deep within a project to begin with.

It's really down to using Startify, which upon selecting a file to open, also changes the directory to that of the file. Since fugitive doesn't care, and none of my other plugins care, I often leave it that way for a good while. Occasionally, I change directory to the current file's on purpose through a mapping, so that for instance I can open a split terminal in the file's directory and do something, or have my 'project-wide' search be limited to that directory. When you add up those two workflows, it turns out that I am actually quite often in some directory underneath the git root.

This is really down to me being used to fugitive's behaviour; I can change directory all I want, but all git operations operate on the file that I currently have open. So I had expected git-worktree to work the same way.

I could also solve this in my configuration, by adding one more command before worktree switch / add / delete - :Gcd sets the path to the git (worktree) root dir of the current file.

TamaMcGlinn commented 9 months ago

if you use the telescope plugin you can fuzzy over either in the current master.

that's not actually true though, is it? I'd really like it to be true, but currently in the telescope, you have to type a part of the branch name; the directory does not work, nor the commit SHA, even though both of those are shown for each line. We should change that.