Author Topic: git worktree support  (Read 429 times)

TKasparek

  • Senior Community Member
  • Posts: 204
  • Hero Points: 25
git worktree support
« on: May 22, 2019, 05:11:12 pm »
I keep getting an error in my Output window:
Quote
fatal: not a git repository (or any of the parent directories): .git

I'm assuming this is because I use worktrees to manage many changes as they are in various stages without having to do redo full long tedious builds.
In the worktree directories, the .git folder is replaced by a .git file that references the directory to find the relevant git information.
  • Is this planned on being supported?
  • Is there an easy way I can make this error go away for the time being?

TKasparek

  • Senior Community Member
  • Posts: 204
  • Hero Points: 25
Re: git worktree support
« Reply #1 on: May 22, 2019, 05:23:44 pm »
Also, right clicking on a project located in a worktree directory from the Projects window and selecting Version Control->Browse Repo produces the following Slick-C stack:
Quote
This property or method is not allowed on this object
svc.ex 10032 svc_gui_browse_repository()   p_window_id: 80   p_object: OI_TREE_VIEW   p_name: _proj_tooltab_tree

ProjectDirectory (has workspace file)
|-->head (actual git repo) (has project file for 'head' project)
|-->worktree dir from head (has project file for 'worktree 1' project)
|-->worktree dir 2 from head (has project file for 'worktree 2' project)
...
|-->workspace tags dir (keeps actual project dirs cleaner)

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2358
  • Hero Points: 131
Re: git worktree support
« Reply #2 on: May 23, 2019, 12:30:51 pm »
I keep getting an error in my Output window:
Quote
fatal: not a git repository (or any of the parent directories): .git

I'm assuming this is because I use worktrees to manage many changes as they are in various stages without having to do redo full long tedious builds.
In the worktree directories, the .git folder is replaced by a .git file that references the directory to find the relevant git information.
  • Is this planned on being supported?
  • Is there an easy way I can make this error go away for the time being?

What command did you use to make a copy of the repository this way?

Normal git commands work from that tree on a console?

If you run "git rev-parse --show-toplevel" from that path, do you get the root from the copy or the original repository?

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2358
  • Hero Points: 131
Re: git worktree support
« Reply #3 on: May 23, 2019, 12:37:12 pm »
Also, right clicking on a project located in a worktree directory from the Projects window and selecting Version Control->Browse Repo produces the following Slick-C stack:
Quote
This property or method is not allowed on this object
svc.ex 10032 svc_gui_browse_repository()   p_window_id: 80   p_object: OI_TREE_VIEW   p_name: _proj_tooltab_tree

Fixed for next hotfix or 23.0.2, whichever comes first.  If you need it immediately please PM me an email address.

Reproduced, working on it.  Tools>Version Control>Browse Repository does work if you're doing the current project.

ProjectDirectory (has workspace file)
|-->head (actual git repo) (has project file for 'head' project)
|-->worktree dir from head (has project file for 'worktree 1' project)
|-->worktree dir 2 from head (has project file for 'worktree 2' project)
...
|-->workspace tags dir (keeps actual project dirs cleaner)
« Last Edit: May 23, 2019, 01:32:58 pm by Dan »

TKasparek

  • Senior Community Member
  • Posts: 204
  • Hero Points: 25
Re: git worktree support
« Reply #4 on: May 23, 2019, 06:12:05 pm »
It's not actually creating a copy of the repository, it's putting a branch (or disconnected head) at specified path.
https://git-scm.com/docs/git-worktree
From any worktree or git clone directory:
git worktree list - will show current worktrees (identified by path) and the branch they are on
git worktree add ../<new worktree dir> <some branch that isn't being used> - will create a new worktree
Delete the folder when you are done.
git worktree prune - will update worktree list and remove tree branches that are no longer found.

So from my example, if I were in the head folder:
Code: [Select]
<drive/path to folder>/ProjectDirectory/head $ git worktree -b my_branch ../worktree1 origin/HEADwill add a new folder called worktree under ProjectDirectory with a new branch called my_branch that is based off of origin/HEAD
There will be a .git file at ProjectDirectory/worktree1/.git that contains:
gitdir: <drive/path to folder>/ProjectDirectory/head/.git/worktrees/worktree1

Quote
If you run "git rev-parse --show-toplevel" from that path, do you get the root from the copy or the original repository?

Code: [Select]
<drive/path to folder>/ProjectDirectory/worktree1 $ git rev-parse --show-toplevel
<drive/path to folder>/ProjectDirectory/worktree1

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2358
  • Hero Points: 131
Re: git worktree support
« Reply #5 on: May 24, 2019, 09:38:20 am »
We definitely want to support this.  What operation are you performing when you get this error?  So far everything I've tried has worked.

TKasparek

  • Senior Community Member
  • Posts: 204
  • Hero Points: 25
Re: git worktree support
« Reply #6 on: May 24, 2019, 01:00:24 pm »
I’m not doing anything specific. The error pops up randomly. Background task for scanning/updating file status icons in the project tree, maybe? My build process also checks out a few other projects to pull from, both git and svn.

Is there a way to get more info when the error?

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2358
  • Hero Points: 131
Re: git worktree support
« Reply #7 on: May 28, 2019, 10:42:25 am »
I’m not doing anything specific. The error pops up randomly. Background task for scanning/updating file status icons in the project tree, maybe? My build process also checks out a few other projects to pull from, both git and svn.

Is there a way to get more info when the error?

It's possible it could be that or if you have it turned on we automatically detect Git and SVN files, and that runs on a background thread as well, although if there are errors both should fail silently.

So are there one or more functionalities failing, or just an occasional error message that we aren't sure what it's tied to?